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

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;

Replies are listed 'Best First'.
RE: RE: RE: RE: RE: File Input and Output
by turnstep (Parson) on May 05, 2000 at 06:46 UTC
    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...