in reply to Win32 File Creation Weirdness, ActivePerl 5.8.8
Your expression:
my ($id) = /(\d+)$/ || /^(\d+)/;
will not work correctly because the first regular expression is evaluated in scalar context and so will return 1 when it matches and not the id number.
This will do what you want:
my $id = ( /(\d+)$/ )[ 0 ] || ( /^(\d+)/ )[ 0 ];
Or this:
my $id = /(\d+)$/ ? $1 : /^(\d+)/ ? $1 : ();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32 File Creation Weirdness, ActivePerl 5.8.8
by missingthepoint (Friar) on Jul 07, 2009 at 09:59 UTC | |
by AnomalousMonk (Archbishop) on Jul 07, 2009 at 16:44 UTC | |
by missingthepoint (Friar) on Jul 07, 2009 at 22:23 UTC | |
by AnomalousMonk (Archbishop) on Jul 07, 2009 at 22:47 UTC |