For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2004 > AW: Reading from a filehandle in while-loop









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author AW: Reading from a filehandle in while-loop
Bastian Angerstein

2004-10-27, 8:55 am

Yes it should, but not on my system.

Thanks for your comments.

-----Ursprüngliche Nachricht-----
Von: Bob Showalter [mailto:Bob_Showalter@taylorwhite.com]
Gesendet: Dienstag, 26. Oktober 2004 16:00
An: 'David le Blanc'
Cc: beginners@perl.org
Betreff: RE: Reading from a filehandle in while-loop


David le Blanc wrote:
....
> You are making the assumption that '<TEST>' sets '$_' which is not
> true. Oddly, perl makes '<>' set $_, but not <FILE>... dunno why


Sorry, but that's just not correct.

while (<TEST> )

DOES set $_, as documented in perldoc perlop under the secion "I/O
Operators"

The OP has some other problem.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Chasecreek Systemhouse

2004-10-27, 8:55 pm

On Wed, 27 Oct 2004 10:43:46 +0200, Bastian Angerstein
<ang@nmc-m.dtag.de> wrote:
> Yes it should, but not on my system.
>
> Thanks for your comments.
>


So, you are saying this doesnt work?

#!/usr/bin/perl -w

use strict;
use warnings;
use diagnostics;

open (TEST,"STDIN") or die "cannot read input file.";

while(<TEST> ) {

s/\W//g; # Clean out non-Alphanumeric...

my $input = ' ';
$input = $_ if length;

# Do other things with $input...
print "Seen $input\n";
}

__END__

???

--
WC -Sx- Jones
http://youve-reached-the.endoftheinternet.org/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com