Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Program unsuspectingly dies with no reason why.

by starX (Chaplain)
on Feb 13, 2008 at 20:41 UTC ( [id://667816]=note: print w/replies, xml ) Need Help??


in reply to Program unsuspectingly dies with no reason why. -FIXED!

It might have something to do with the line &clean_the_file(); The & denotes a function reference, but you're not calling the function via a reference. If you use clean_the_file(); I think it'll take care of the issue.

Update: Never mind, I'm a loser.

Replies are listed 'Best First'.
Re^2: Program unsuspectingly dies with no reason why.
by Fletch (Bishop) on Feb 13, 2008 at 20:46 UTC

    Errm, no. Something like \&clean_the_file would be a reference. While calling subs with the leading sigil does have an effect, it's not going to stop &clean_the_file() from being called in any sane circumstance. See perlsub.

    (Of course if someone has created just such a circumstance then they deserve what they get for using prototypes where they shouldn't :)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^2: Program unsuspectingly dies with no reason why.
by kyle (Abbot) on Feb 13, 2008 at 20:48 UTC

    Actually, &foo() is a call to the sub foo. To take a reference to the sub, use \&foo.

    sub foo { print "foo: ", $_[0], "\n" } &foo( 'called with &' ); foo( 'called with no &' ); my $foo_ref = \&foo; $foo_ref->( 'called via reference' ); &$foo_ref( 'called via & and reference' ); __END__ foo: called with & foo: called with no & foo: called via reference foo: called via & and reference

    The only special thing about &foo() vs. foo() is that the former will disable any prototypes the sub may have.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found