Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

rtfm moment...

by nop (Hermit)
on Mar 08, 2001 at 20:11 UTC ( #62980=perlmeditation: print w/replies, xml ) Need Help?? there i was, degugging away, and i needed a subroutine to dump the whole state of my application to some files (using storable, etc)... and so i write the subroutine and fold into my code... and then my application suddenly starts "terminating abnormally" on my new subroutine... i am totally befuddled... cannot see anything wrong with the code... how utterly mysterious!
### dump everything to a file sub dump { my (%params) = @_; # blah blah } dump(-file=>"foo.txt", -code=>"full", -blah=>"etc");
...then my RTFM flash of light... perhaps dump wasn't the wisest choice for a subroutine name. duh. well, learn something new every day...


yeah, i know  &dump(-file=>"foo.txt", -code=>"full", -blah=>"etc"); would have been ok with the &

Replies are listed 'Best First'.
Re: rtfm moment...
by turnstep (Parson) on Mar 08, 2001 at 21:54 UTC
    You know, if you had said...
    &dump(-file=>"foo.txt", -code=>"full", -blah=>"etc");

    ...your script would have worked just fine. Yet another reason to use the unloved ampersand in front of a subroutine call. :)

    Hrmm, should perl -w say something when you make a pseudo-ambiguous call to a built-in function? Probably not: that's why I always use the ampersand to disambiguate things.

    (Of course, sometimes you *want* function calls to appear a bit ambiguous :)

      Actually, I think much better advice is to view this as a good reason to always use mixed case in your subroutine names!

      When the "style" shifted from &sub() [Perl4] to just sub() [Perl5], I don't think the documentation and warnings caught up with the problems that resulted. There are probably some warnings that should be added, like you noted, and some advice that needs to be updated and strenthened in the docs.

              - tye (but my friends call me "Tye")
Re: rtfm moment...
by merlyn (Sage) on Mar 08, 2001 at 21:06 UTC
    ... i needed a subroutine to dump the whole state of my application to some files...
    Well, it was a single file, and the subroutine was already written for you. Perl was just being helpful.

    -- Randal L. Schwartz, Perl hacker

      You know the line: "Hey, I wanted you to do what I meant, not what I said!"
      Also reminds me of this old joke...
Re: rtfm moment...
by Jouke (Curate) on Mar 08, 2001 at 20:23 UTC
    I think every good programmer learns all the time. I thought even merlyn wrote somewhere sometime ago he still learns new stuff every day. At least I don't know any programmer who thinks he knows everything...

    Jouke Visser, Perl 'Adept'
Re: rtfm moment...
by chipmunk (Parson) on Mar 08, 2001 at 20:51 UTC
    I learned exactly this lesson recently. The builtin dump function is used so rarely, no wonder we forget it exists!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://62980]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2018-06-18 02:46 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.