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