Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Some assistance with splitting variables

by ww (Bishop)
on Apr 05, 2013 at 21:53 UTC ( #1027224=note: print w/replies, xml ) Need Help??

in reply to Some assistance with splitting variables

  1. Sometimes, using multiple regexen is easier or clearer than trying to do all the work with one (more complex) regex
  2. Captures the first element OP wanted; also perhaps somewhat easier to read.
#!/usr/bin/perl use 5.016; # 1027211 use Data::Dumper; my @info; my $info = '19476 2013-04-05,12:10:51.909293 host:internal.machine44.c main INFO Running normally with ACTION=<processing> FAN_A= +<OK> FAN_B=<OK> SEND=<Sent mail (221 2.0.0 Service closing transmissi +on channel)> FAILURE=<2> '; if ($info =~ /\d+\s(\d\d\d\d-\d\d-\d\d,\d\d:\d\d:\d\d\.\d+) / ) { # ex +cessively detailed. push @info, $1; # A +well written # ch +ar_class would be # an + improvement, as } # wu +d using quantifiers while ( $info=~ /(\w+=<.*?)>/g) { push @info, $1; } say Dumper @info;
$VAR1 = '2013-04-05,12:10:51.909293'; $VAR2 = 'ACTION=<processing'; $VAR3 = 'FAN_A=<OK'; $VAR4 = 'FAN_B=<OK'; $VAR5 = 'SEND=<Sent mail (221 2.0.0 Service closing transmission chann +el)'; $VAR6 = 'FAILURE=<2';

If you didn't program your executable by toggling in binary, it wasn't really programming!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027224]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2016-10-27 03:30 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (352 votes). Check out past polls.