the line $str->$str1($regexp); always passes $str as parameter to the subroutine.
$str is passed as first argument to the subroutine because you are using method invocation syntax. In particular, you are using the arrow operator: ->.
If you don't want $str passed as the first argument, you could use a symbolic reference:&{"${str}::${str1}"}($regexp).
use strict; use warnings; package XXX; sub YYY { my ($x) = @_; print "hi there $x\n"; } package main; my $str = 'XXX'; my $str1 = 'YYY'; { no strict "refs"; &{"${str}::${str1}"}(10); }
In reply to Re: invoking subroutines
by ig
in thread invoking subroutines
by anitsahu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |