Re: Regex confusion...



On Sep 27, 6:43 pm, s...@xxxxxxxxxxxxxx wrote:
On Fri, 28 Sep 2007 00:10:42 +0100, Ben Morrow <b...@xxxxxxxxxxxx> wrote:

...

This can be simplified to

if (
my ($t, $zip, $type) =
$img =~ /^(\d)-(\d+)-(\w+)$/
) {

which avoids the need to use the $N variables altogether.

Ben

It might be quicker to check for sucess first then do the asignment

$_ = "......";
if ( /^(\d)-(\d+)-(\w+)$/ )
{
#use $1,2,3 or asign
($t, $zip, $type) = ($1, $2,
^^^^^^^^^^^^^^^^^^^^^^^^^^

Are you sure... wouldn't your solution require an extra copy from
$N.

--
Charles DeRykus


.