3

When it comes to naming and parsing the parameters in a perl subroutine, is there any difference between the

@ARG and @_?

Makan Tayebi
  • 2,318
  • 4
  • 23
  • 37

2 Answers2

2

You can increase memory consumption and slowdown regular expressions in old interpreters with implicitly exported use English; versions of match variables ($`,$',$&).

This thread will be useful.

And read more about matchvars pitfalls at:

perldoc English

perldoc perlvar

perldoc perlre

I don't know about other issues.

k-mx
  • 667
  • 6
  • 17
  • 4
    That is, to use `@ARG` you enable it with `use English`. Prior to v5.20, that could slow down programs with lots of regexes because remembering `$&` is slow. That's been fixed for several year though. For older versions, you can `use English qw(-no_match_vars)`, as noted in its documentation. – brian d foy Jul 29 '20 at 15:37
1

Short answer, no. See perlvar

  • @ARG
  • @_

Within a subroutine the array @_ contains the parameters passed to that subroutine. Inside a subroutine, @_ is the default array for the array operators pop and shift.

JRFerguson
  • 7,216
  • 1
  • 30
  • 35