Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: File Handles Chapter(not homework)

by moritz (Cardinal)
on Aug 02, 2012 at 08:01 UTC ( #984973=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: File Handles Chapter(not homework)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2015-07-02 02:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls