tcf22 has asked for the wisdom of the Perl Monks concerning the following question:
Which returns undef if there is no match but 1 if there is a 5 or 9 digit match. I triedmy ($zip_match) = $card_zip =~ /(12345)\-?(6789)?/;
and @zip_match was populated correctly ['12345', undef] for a 5 digit match ['12345', '6789'] for a 9 digit match so why doesn't it return the number of elements in scalar context. I've also tried stuff like this, but to no avail:my (@zip_match) = $card_zip =~ /(12345)\-?(6789)?/g;
I've figured out ways around this, but it is bothering me that I can't get this to work.my ($zip_match) = scalar($card_zip =~ /(12345)\-?(6789)?/);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Zipcode Regex Help
by dws (Chancellor) on Jun 25, 2003 at 21:26 UTC | |
by tcf22 (Priest) on Jun 25, 2003 at 21:31 UTC | |
by Abigail-II (Bishop) on Jun 26, 2003 at 01:39 UTC | |
|
Re: Zipcode Regex Help
by Abigail-II (Bishop) on Jun 26, 2003 at 01:33 UTC | |
|
Re: Zipcode Regex Help
by PodMaster (Abbot) on Jun 25, 2003 at 21:29 UTC | |
by tcf22 (Priest) on Jun 25, 2003 at 21:42 UTC | |
by PodMaster (Abbot) on Jun 25, 2003 at 21:50 UTC | |
by tcf22 (Priest) on Jun 25, 2003 at 21:57 UTC |