Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Reading a file

by danger (Priest)
on Mar 07, 2001 at 00:01 UTC ( [id://62564]=note: print w/replies, xml ) Need Help??


in reply to Reading a file

It really depends on what you mean by passing each line to another program: 1)Do you mean, call another program with each line as the arguments? or 2) Do you mean, pipe each line to another program's standard input? (or do you mean something altogether different?)

# 1 #!/usr/bin/perl -w use strict; my $other_program = 'echo'; while(<>){ chomp; system($other_program, $_); } __END__ # 2 #!/usr/bin/perl -w use strict; my $other_program = 'tr [a-z] [A-Z]'; open(OTHER, "|$other_program") || die "Kant: $!"; while(<>){ print OTHER $_; } close OTHER; __END__

Replies are listed 'Best First'.
Re: Re: Reading a file
by ep (Initiate) on Mar 08, 2001 at 01:34 UTC
    Thanks for everyone's help...I'm where I need to be. There were some questions about what I'm wanting to with the data from the file. I would like to take each record of the file (one at a time) and pass that record as an argument to another perl script, shell script, etc. that performs data extraction based on the argument being passed in (i.e. zip code). Hope this clears up any of the confusion! Thanks- ep

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-23 06:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found