Re: groups of values from an array
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Tue, 29 Jan 2008 11:04:13 -0500
On Jan 29, 2008 10:28 AM, Horvath, Peter <phorvath@xxxxxxxxxxxx> wrote:
You are correct. It is a command that I put to an array. I try to worksnip
with the while loop. Thank you for the guidance.
I assume by "a command that I put to an array" you mean you are doing
something like
my @lines = `somecommand`;
To get a file handle for this do
open my $fh, "-|", "somecommand"
or die "could not get a file handle for the command somecommand: $!";
After that point you can use the code I sent you (if you replace DATA
with $fh). You may also find it useful to access your records as a
hash like this
#!/sur/bin/perl
use strict;
use warnings;
open my $fh, "-|", "somecommand"
or die "could not get a file handle for the command somecommand: $!";
{
local $/ = ("=" x 80) . "\n"; #set the record separtor
while (my $rec = <$fh>) {
chomp($rec); #remove record separator
next unless length($rec); #skip empty records
my %record = map { /(.*?):\s+(.*)/ } split /\n/, $rec;
print "$record{'media ID'} is in pool $record{'volume pool'}\n"
}
}
.
- References:
- groups of values from an array
- From: Peter Horvath
- Re: groups of values from an array
- From: Chas. Owens
- RE: groups of values from an array
- From: Peter Horvath
- groups of values from an array
- Prev by Date: Re: groups of values from an array
- Next by Date: Reference and assignment question
- Previous by thread: RE: groups of values from an array
- Next by thread: Re: groups of values from an array
- Index(es):
Relevant Pages
|