Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: phantom subroutine parameter values

by blahblahblah (Priest)
on Apr 14, 2008 at 23:08 UTC ( #680422=note: print w/replies, xml ) Need Help??

in reply to phantom subroutine parameter values

This will happen when you call a sub with an ampersand but without any parentheses, like the following:


Doing so makes the calling sub's @_ visible to called subroutine. To avoid this, either omit the ampersand or include empty parens when calling a sub with no args. See perlsub for more info.

Replies are listed 'Best First'.
Re^2: phantom subroutine parameter values
by rpelak (Sexton) on Apr 14, 2008 at 23:53 UTC
    Thanks guys. I knew it was something simple... That explains why a lot of my old code doesn't have ampersands... Sucks be forced to program in tcl for a few years... rpelak
      uh?! it seems a feature! in any case i like calling with the & 'cause i spot easy subroutine's calling.

      if i understand :
      sub refinemydata { my $data = shift; &is_refined:return?&rerefine;}
      could be a valid syntax too ?
      something new

        The ampersand is functional, not decorative. &func(args) is not the same as func(args). The function's prototype is ignored in the former. And &func, &func() and func() are all different. @_ is left untouched by the first.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2019-05-20 11:40 GMT
Find Nodes?
    Voting Booth?
    Do you enjoy 3D movies?

    Results (128 votes). Check out past polls.