Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: "uninitialized value in subroutine exit" warning from CGI.pm

by NetWallah (Canon)
on Nov 10, 2017 at 03:36 UTC ( #1203098=note: print w/replies, xml ) Need Help??


in reply to "uninitialized value in subroutine exit" warning from CGI.pm

I was able to reproduce the problem you describe:
perl -wE 'sub x{say qq|X Called|}; x substr(undef,0,4)'
Basically, when substr(undef,..) is called as a parameter to a sub{},
it behaves differently than when called without that context.

I.E. it complains when called "solo", but suppresses the warning when called as a parameter.

That's all I have.
No idea on WHY the behaviour is different. I'm sure monks with more (perl) guts will come forth.

                All power corrupts, but we need electricity.

Replies are listed 'Best First'.
Re^2: "uninitialized value in subroutine exit" warning from CGI.pm
by dave_the_m (Prior) on Nov 10, 2017 at 09:44 UTC
    No idea on WHY the behaviour is different. I'm sure monks with more (perl) guts will come forth.
    Args to subs are treated as lvalues (sort of) because they can be modified within the sub, e.g.
    sub f { $_[0] = "abc" } $s = "1234"; f(substr($s, 0, 1)); # $s is now abc234

    Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1203098]
help
Chatterbox?
and God said, "Let Newton be!"...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2018-01-17 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (206 votes). Check out past polls.

    Notices?