I need assistance in passing an array to a subroutine that is located in a package. Below, you will find code examples.
Package
Package Callpackage SomePackage; BEGIN { print "Beginning package ".__PACKAGE__." Error code: $?.\n"; } sub new() { my $self = {}; return bless $self; } sub DESTROY() { my $self = shift; warn "DESTROYING $self"; } sub print_filename() { my $object = {}; $object{FILES} = $_[1]; $object{PARAMETER_TWO} = $_[2]; $object{PARAMETER_THREE} = $_[3]; while(($key,$value) = each(%object)) { print "$key => $value\n"; } } END { print "Ending package ".__PACKAGE__ ." Error code: $?.\n"; } return 1;
In-depth Questionrequire "SomePackage.pl'; $SP = new SomePackage; @array = qw(one.txt two.txt three.txt); $SP->print_filename(@array,$arg1,$arg2);
How can I format the array so that I can be passed to the package's subroutine so that key PARAMETER_TWO does not equal two.txt and PARAMETER_THREE does not equal three.txt? How can I convert the array into a scalar before passing it to the package? Note: I just wrote this code on-the-fly.
Any help would be greatly appreciated! Thanks in advance.
LA
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |