http://qs1969.pair.com?node_id=10024


in reply to RE: File Input and Output
in thread File Input and Output

root just forgot that you don't need to escape less-than and greater-than signs inside <CODE> tags. Obviously, it should read:
while(<FILE>)

Replies are listed 'Best First'.
RE: RE: RE: RE: File Input and Output
by Anonymous Monk on May 05, 2000 at 05:31 UTC
    So, in summary, here's how you deal with open():

    #!/usr/bin/perl print"Gimmie a filename to examine: "; $filename=<STDIN>; open(FILE,$filename); while(<FILE>) { chomp; print "Found $_ in $filename" } close FILEDESC;
      Actually, it should be:
      print "Gimme a filename to examine: "; chop($filename=<STDIN>); ## Not many filenames have a newline... open(FILE, $filename) || die "Could not open $filename: $!\n"; while(<FILE>) { chomp; print "Found $_ in $filename\n" ## Need a newline here! } close(FILE); ## not FILEDESC...