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

Re: Default variable within loops

by stevieb (Prior)
on Jun 21, 2012 at 03:12 UTC ( #977542=note: print w/replies, xml ) Need Help??

in reply to Default variable within loops

I couldn't come up with anything shorter than muba. I tried, but you need at least one temp var (afaict), or else the $_ will confuse iteslf.

my @a = qw( a b c ); my @b = qw( a 3 c ); for my $elem (@a){ print $elem if grep { $elem eq $_ } @b; }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2016-10-21 12:15 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.