Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Perl Programming guidlines/rules

by Anonymous Monk
on Nov 21, 2002 at 20:16 UTC ( [id://214896]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl Programming guidlines/rules
in thread Perl Programming guidelines/rules

do not shift subroutine arguments, use code like my( $self, $arg1, @args ) = @_; instead

May I ask why?

Replies are listed 'Best First'.
Re^3: Perl Programming guidlines/rules
by particle (Vicar) on Nov 21, 2002 at 22:31 UTC
Re: Re: Re: Perl Programming guidlines/rules
by Anonymous Monk on Nov 22, 2002 at 21:33 UTC
    It's harder to screw up when adding variables. I've done my $this = shift then tried to change it to my ($this,$x) = shift if you start with my ($this) = @_; then my ($this,$my,$something,$asdfjkksaldf) = @_; will be less error prone

      unless, of course, you add your variables by

      ## start with: my $foo = shift; ## adding $bar yields: my $foo = shift; my $bar = shift;

      it's a matter of style. if you're changing your style, it's safer to rewrite the code from scratch than to modify in place -- even (or especially) if it's only one statement.

      ~Particle *accelerates*

      Huh? I thought it was rather clear from the documentation that shift doesn't care if you're using list context. It just always takes the first element off an array and returns it. What made you think otherwise?

      my $this = shift; my $x = shift; ...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-28 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found