Steve Bertrand wrote:
Hi all,
Hello,
Can someone explain to me how I can fix this up to achieve my desired
results?
my $time = (split (/:/, (grep (/^info/, @contents))))[0];
A sample snip of data:
this382:3828
info447:4729
that274:9294
...and I just want the $time to become info447.
my ( $time ) = join( "\n", @contents ) =~ /^(info\d+):/m;
Of course if you are populating @contents from a file or a pipe then you
could just slurp it in scalar context and avoid using join().
local $/;
my ( $time ) = <FILE> =~ /^(info\d+):/m;
Or:
my ( $time ) = `somecommand` =~ /^(info\d+):/m;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/