Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Parse string as an option

by Anonymous Monk
on Jun 25, 2012 at 18:59 UTC ( [id://978241]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi 2 everyone. Here's the situation, I need use output from one script as an argument for couple others .One script scans DB for certain entries, if data found script should execute other scripts one by one using found data as arguments, something like this:
make_host -a data1;data 2 data 3;john.doe@example.com;1; make_group -a data1;data 2 data 3;john.doe@example.com;1;
So the question is: How to parse whole ";" delimited string as an argument in each for example inside of "make_host.pl", if this possible then how ?

Replies are listed 'Best First'.
Re: Parse string as an option
by McA (Priest) on Jun 25, 2012 at 19:29 UTC
    Hi

    I didn't really understand what you want to do. Do you have a problem parsing a ";" delimted line of output? Or is the problem related to reading line-by-line from other script?

    a) my @elements = split /;/, $line_of_output;

    b) read line-by-line from output of 'ls -l'

    open my $fh, "-|", "ls -l" or die $!; while(defined(my $line = <$fh>)) { print $line; } close $fh or die "ERROR: Couldn't read from pipe: $!";

    Is any of that helpful?
    McA

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found