in reply to split string using regex
Which outputsuse Data::Dumper; my $inp = 'AAA * BBB CCC * * "2000 01 00 00 00" "2004 01 00 00 00"'; $inp =~ s/(\d) (\d)/$1-$2/g; my @fields = split /\s+/, $inp; print Dumper(\@fields);
However, this assumes that the other fields don't start/end with a number. I'm only going off your example above.$VAR1 = [ 'AAA', '*', 'BBB', 'CCC', '*', '*', '"2000-01-00-00-00"', '"2004-01-00-00-00"' ];
---
echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split string using regex
by Anonymous Monk on Jun 25, 2013 at 06:20 UTC | |
by hdb (Monsignor) on Jun 25, 2013 at 07:03 UTC |