Hi folks.
I'm struggling to see what I'm doing wrong. I have the following code in one
of my programs but it isn't working as it should.
print STDERR "enqmake='$enqmake' model='$model'\n";
if (!$enqmake && $model) { # extract make
print STDERR "About to split '$model'\n";
if ($model=~/ *?(\w*) (.*?) *$/) {
$enqmake=lc($1);
$model=$2;
print STDERR "model split into '$enqmake' '$model'\n";
}
} # extract make
This generates:
enqmake='' model='Kia Venga'
About to split 'Kia Venga'
I have a test script which works fine. Can anyone see what I'm doing wrong?
#!/usr/bin/perl -w
use warnings;
use strict;
my $t='Kia Venga';
if ($t=~/ *?(\w*) (.*?) *$/) {
print "1='$1' 2='$2'\n";
}
[root@ollie exim]# ~/t
1='Kia' 2='Venga'
[root@ollie exim]#
--
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/