Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Comparison between a string and an array

by jdporter (Paladin)
on Sep 26, 2016 at 01:55 UTC ( [id://1172590]=note: print w/replies, xml ) Need Help??


in reply to Re: Comparison between a string and an array
in thread Comparison between a string and an array

my$match,$res;

my has higher precedence than comma, so $res is an undeclared variable there. And since you're not using strict, why bother declaring at all?

Replies are listed 'Best First'.
Re^3: Comparison between a string and an array
by sir_jeff (Initiate) on Sep 26, 2016 at 10:53 UTC

    I thought my$match,$res; the same as writing

    my$match; my$res;

    I'm just declaring both on one line.
    Anyway it was just a rough (working) code fart. If I was gonna bother with strict then I'd even add the shebang! and a "use warning" , but yeah nah, point taken. I'll leave out the local or global declarations next time to make it more obvious, cheers -SJ-

      my ($match,$res);

      would do what you were trying to do.

      But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

        Declaring (not assigning) $match & $res as local vars. Just a habit (I always write it this way). The long way would be :
        my $match; my $res;
        or to declare and assign :
        my $match=""; my $res="";
        But as I said earlier - I won't use "my" if it's just rough code (as it's not a Strict script - just example code)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-16 19:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found