Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Strange behaviour of m and $_

by Fletch (Chancellor)
on Oct 17, 2006 at 22:20 UTC ( #578913=note: print w/ replies, xml ) Need Help??


in reply to Strange behaviour of m and $_

Subroutine invocations don't interpolate in double quoted strings (of which m// is a special kind). Either store the results from your function in a scalar and let that interpolate, or use something like /@{[ test_reg1() ]}/ instead.

And an aside, don't use the leading ampersand on subroutine calls; it does things to how the sub is called and unless you specifically have a reason to (and know why you're doing it) you should just omit it.


Comment on Re: Strange behaviour of m and $_
Select or Download Code
Re^2: Strange behaviour of m and $_
by ysth (Canon) on Oct 18, 2006 at 00:10 UTC
    And an aside, don't use the leading ampersand on subroutine calls; it does things to how the sub is called
    Slight clarification: that only applies when no () follow the sub name.
      ...except
      $\=$/; sub print { CORE::print("[$_[0]]"); } print('foo'); # foo &print('bar'); # [bar]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-07-07 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls