http://www.perlmonks.org?node_id=984973


in reply to File Handles Chapter(not homework)

Write a program that opens a file with STDIN

What does that mean? Open a file with a name read from STDIN? If so,

use autodie; my $filename = <STDIN>; chomp $filename; # remove trailing newline character open my $handle, '>', $filename; # ^ if you want to write to that file
how do I parse a file line by line?
use autodie; open my $handle, '<', 'yourfile.txt'; while (my $line = <$handle>) { chomp $line; # remove trailing newline # do something with $line here. }

See also: perlintro, perlopentut.