in reply to Splitting 2 different patterns
Yet another alternative, the "defensive programming" style:
use Data::Dumper; my @intf_list = ("xe-1/2/0", "xe-2/2/0", "xf-3/2/a"); foreach my $myint (@intf_list) { my @outputlist = $myint=~/^(\w+)-(\d+)\/(\d+)\/(\d+)$/ or die "Couldn't match \"$myint\""; print Dumper(\@outputlist); } __END__ $VAR1 = ['xe', '1', '2', '0']; $VAR1 = ['xe', '2', '2', '0']; Couldn't match "xf-3/2/a" at - line 4.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting 2 different patterns
by karlgoethebier (Abbot) on Mar 17, 2015 at 12:03 UTC | |
by AnomalousMonk (Archbishop) on Mar 17, 2015 at 12:18 UTC | |
by choroba (Cardinal) on Mar 17, 2015 at 12:21 UTC | |
by karlgoethebier (Abbot) on Mar 17, 2015 at 13:08 UTC |