On Fri, Jul 27, 2012 at 9:04 AM, Gary Stainburn <gary.stainb...@ringways.co.uk> wrote: > 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'
Your RE is a bit odd - all that 'non-greedy *' -ness implies troubles. The first "space star ?" can be greedy, right? You want all the spaces/white space in a row, or rather don't want - as you're anchored on the end, this doesn't do anything for the actual RE work. The next "word char *" means zero or more - you want at least one, right? Word char or non-white space? The only requirement your RE looks for is the single blank between capture 1 and 2 - so Kia\tVenga won't work. Actually anything w/o a blank will fail ... don't really know enough about your data but try maybe: if ($model=~/(\S+)\s+(.*)\s*$/) { -- a Andy Bach, afb...@gmail.com 608 658-1890 cell 608 261-5738 wk -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/