Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Default variable within loops

by stevieb (Vicar)
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; }

Comment on Re: Default variable within loops
Download Code

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 imbibing at the Monastery: (5)
As of 2015-11-26 12:40 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (698 votes), past polls