Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • If # do stuff modifies $_ then foreach aliasing will try to modify the relevant entry in @_.

    That's unlikely to be desired, and I think will cause a crash if the caller passed a constant in.

    • Since the code is using while rather than foreach and more importantly shift rather than aliasing, this isn't going to be the bug in this code. When we shift, we copy, so changes (in this case) to $_ won't change @_.

      Having said that, I'd much prefer the original code to say:

      sub import {
          my $class = shift;
          foreach my $arg (@_) {
              # do stuff

      But then changing $arg would hit the problems you're thinking of.