Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: var comparison

by LanX (Bishop)
on Sep 06, 2012 at 23:39 UTC ( #992210=note: print w/replies, xml ) Need Help??

in reply to Re: var comparison
in thread var comparison

carefull! better always stringify if you're not sure that its not a ref "$var" ~~ [qw/foo bar/]

Replies are listed 'Best First'.
Re^3: var comparison
by Kenosis (Priest) on Sep 07, 2012 at 00:27 UTC

    Why, with the following expected behavior?

    use Modern::Perl; my $var1 = 'foo'; my $var2 = \$var1; say $var2; # prints SCALAR(0x2590b8) say "$var2"; # prints SCALAR(0x2590b8) say $var1 ~~ [qw/foo bar/]; # is true: prints 1 say $var2 ~~ [qw/foo bar/]; # is false: prints nothing say "$var2" ~~ [qw/foo bar/]; # is false: prints nothing
        I see... Maybe "smart matching" promises to do too many things...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992210]
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-06-22 02:39 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (121 votes). Check out past polls.