in reply to Re^4: Turning regex capture group variables into arrays, then counting the number of objects in the array
in thread Turning regex capture group variables into arrays, then counting the number of objects in the array
I used the filehandle DATA as a convenient way to include some test lines in a Simple, Self Contained Example. You can either do as markong suggested and populate an array with your output
my @output = `bpdbjobs`; #while (<DATA>){ for (@output) { # process lines }
or if you have the output in a text file, open a filehandle to that
my $filename = 'output.txt'; open my $fh,'<',$filename or die "Could not open $filename : $!"; while (<$fh>){ # process lines }
or you may be able to pipe the output directly from your program. see Calling External Commands More Safely
Updated ; last example corrected backticks to single quote pojopen my $fh, '-|', 'bpdbjobs' or die $!; while (<$fh>){ # process lines } close $fh or die $! ? $! : $?;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Turning regex capture group variables into arrays, then counting the number of objects in the array
by Djay (Novice) on Dec 06, 2018 at 11:20 UTC | |
by hippo (Archbishop) on Dec 06, 2018 at 12:31 UTC | |
by Djay (Novice) on Dec 06, 2018 at 13:06 UTC | |
by poj (Abbot) on Dec 06, 2018 at 12:53 UTC |