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

Re: Basic file processing

by ibanix (Hermit)
on Feb 01, 2003 at 00:24 UTC ( [id://231764]=note: print w/replies, xml ) Need Help??


in reply to Basic file processing

Hi AnonyMonk,

You'll want to start writing some code. Here's something to get you started:
# Set your input and output file my $inputfile = "input.txt"; my $outputfile = "output.txt"; # Open your input file open(my $input, $inputfile); # Open your output file, for writing open(my $output, ">$outputfile"); # Read each line in, one at a time while(<$input>) { # Here's where you put your personal logic # When you need to print to the output file, do this # The $_ means, in this case only, "current line" print $output "Hey, I found $_\n"; } # Close your files when done! close($input); close($output);
There is plenty of online documentation to get you started. You may also want to read the introduction to Perl.

Good luck. If you have more questions, post them here, and please include your code.

Cheers,
ibanix

$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found