Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

File Input and Output

by root (Scribe)
on Nov 10, 1999 at 02:36 UTC ( #960=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    open(FILE, "data.txt");          #opens data.txt in read-mode
    while(<FILE>){                   #reads line by line from FILE which i
    +s the filehandle for data.txt
    ...
       print "Saw $_ in data.txt\n"; #shows you what we have read
    }
    close FILE;                      #close the file.
    
  2. or download this
    open FILE, ">keylogger.dat";  #opens file to be written to
    while(<>){                    #while we're getting input from the keyb
    +oard
       print FILE $_;             #write it to our file
    }
    close FILE;                   #then close our file.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://960]
help
Chatterbox?
[erix]: I'm a bit stuck with regex capturing. Anyone wants to ahve a look at my [erix://pad | scratchpad ? (it's the little test program at the top there)]
[erix]: hm [erix://pad]
[erix]: pad::/erix
[erix]: erix's scratchpad
[erix]: ah! ;)
[erix]: I'm trying to capture some detail from user input I'm pretty sure I have done this before
[Discipulus]: sorry, not able to help erix.. ;=(

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-01-19 08:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (216 votes). Check out past polls.

    Notices?