in reply to List arguments of a method

G'day perlUser9,

You have an illegal prototype in "sub allVars($no1)":

$ perl -Mstrict -Mwarnings -e 'sub allVars($no1) { 1 }' Illegal character in prototype for main::allVars : $no1 at -e line 1.

See perlsub or, if that's too heavy going, start with "perlintro: Writing subroutines".

From the first line of code in &allVars:

my ($self, $no1, $no2, $name1, $name2) = @_;

I assume you're calling it something like this:

$object->allVars(...)

You seem to understand that all the arguments are in @_; and, you've assigned the first of those to $self. Why do then say "the arguments of allVars that is - $no1, $no2, $name1 and $name2"? What happened to $self?

I suspect you've misunderstood some key concept; unfortunately, I don't know what that might be. Also, this rather looks like an "XY Problem". Perhaps it would be better to explain your problem instead of your attempted solution.

My best guess at what you want (although I strongly suspect this guess is wrong) is along these lines:

#!/usr/bin/env perl -l use strict; use warnings; package Some::Module; sub new { bless {} => shift } sub all_vars { print "all vars = @_" } package main; my $obj = Some::Module::->new; $obj->all_vars(qw{a b c d});

Output:

all vars = Some::Module=HASH(0x7fc55c003098) a b c d

By the way, lexical variables don't live in the symbol table. If you were looking for them there, you won't find them.

-- Ken