Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Corrupt Data?

by spickles (Scribe)
on Jul 14, 2008 at 19:46 UTC ( [id://697551]=note: print w/replies, xml ) Need Help??


in reply to Re: Corrupt Data?
in thread Corrupt Data?

Thanks for your posts, guys! Almut - I thought that the variable @_ would take whatever was passed to it, even for a subroutine without any explicit arguments? Therefore, I should be able to pass either a scalar or an array, without having to explicitly define arguments. friedo - Thanks for your help in finding out how I was corrupting my own data. Regards, Scott

Replies are listed 'Best First'.
Re^3: Corrupt Data?
by almut (Canon) on Jul 14, 2008 at 20:13 UTC
    I thought that the variable @_ would take whatever was passed to it, even for a subroutine without any explicit arguments?

    Thing is that if you declare sub convert () {...} you're telling Perl that the routine takes no arguments... In other words, if you're then going to call the routine with any arguments, you'll just get the error Too many arguments for main::convert ...

    Without any prototype, however, Perl already does exactly what you want, i.e. you can pass one or several arguments...

Re^3: Corrupt Data?
by ikegami (Patriarch) on Jul 14, 2008 at 20:22 UTC

    even for a subroutine without any explicit arguments

    I don't know where you got the term explicit or what you want it means in this context, but what almut meant was that the "()" in "sub foo () { ... }" means the subroutine takes no arguements. Drop the "()": "sub foo { ... }".

    Update: Too slow and credited the wrong monk. Fixed the latter.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found