Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: <p>string variable</p>

by daxim (Chaplain)
on Jul 24, 2013 at 10:59 UTC ( #1046072=note: print w/ replies, xml ) Need Help??


in reply to <p>string variable</p>

You're asking about varvarnames. Read that article and the following ones to understand why we can't recommend that.

Instead just use a hash!

my @slots = qw(option color whom); my $message = 'If you choose a yellow car everyone will follow you!'; my $my_trigger = qr/If you (.*) a (.*) car (.*) will follow you!/; my %hash; if (@hash{@slots} = $message =~ /$my_trigger/) { for my $slot (@slots) { print "$slot: $hash{$slot}\n"; } }


Comment on Re: <p>string variable</p>
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (19)
As of 2014-09-17 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (79 votes), past polls