Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

RE: regexp's

by Anonymous Monk
on Oct 03, 2000 at 20:25 UTC ( [id://35133]=note: print w/replies, xml ) Need Help??


in reply to regexp's

Well, this is one way: foreach (@array) { my ($key,$val); /\w+$/ and $key = $&; /^\d+/ and $val = $&; $hash{$key} = $val; } This will slow down all your pattern matches because of using $&. The alternative, if you don't use $& or similar variables elsewhere, would be $key = $_; $val = $_; and then some kind of substitution. It also assumes that numbers are always,er, numbers and the names are always one word. If not, you could use \b for boundary-matching dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://35133]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-25 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found