I need to pass an array as one of three arguments to a subroutine.
Once inside the subroutine, the array contains only the first item (index
0) instead of the whole array. It is the third argument, so I have attempted
to retrieve the array's elements by assigning @_[2] to another array
variable
When calling the subroutine, you pass the array as reference:
subroutine( \@array, $param2, $param3 );
sub subroutine {
my ($array, $param2, $param3) = @_;
my $My3rdValue = $array-[2];# reference have the third item of array
}
Note this is the same way
Charles,
You could tryr a pointer/reference to the array...
Parent script...
snip
# PARSE: Parse out the CGI parameters...
parseArgs(*cgiArgs);
/snip
Then within the sub, just setup a local variable to grab the pointer...
snip
#
sub parseArgs {
local (*argsCGI) = @_ if @_;
local
Charles Knell:
# I need to pass an array as one of three arguments to a subroutine.
# Once inside the subroutine, the array contains only the first
# item (index
# 0) instead of the whole array. It is the third argument, so I
# have attempted
# to retrieve the array's elements by assigning @_[2]
Charles,
I think that you will want to pass the list or array using a reference. Here is a code
example:
sub Depth($)
{
my $Self = shift;
my @List = ();
_Depth($Self,\@List); # Pass as a reference
return(@List);
}
sub _Depth($$)
{
unless (ref $_[1] eq 'ARRAY')
How about something like this:
# Notice the function prototype specifies a scalar
# followed by two arrays.
sub doit ($\@\@) {
my ($arg1, $aref, $bref) = @_;
for (@$aref) {
# loop over all elements of the array pointed to by $aref
}
# Example of referencing a specific element in an
If you have the NT Reskit available, you should be
able to do this with the instsrv tool.
--- Fifield, Mike [EMAIL PROTECTED] wrote:
Does anyone know of a perl mod that allows you to
delete a winnt service?
The only thing close that I could find was
win32::service but this only
allows you
I am having problems with the following perl script
print Content-type: text/html\n\n;
print Convert file; system c:\\progra~1\\adlib\\adlibs~1\\adlibsentinel.exe
/process f:\\ticket\\temp\\black.gif f:\\ticket\\temp\\black.pdf; print ;
What are the first two arguments? How is your code
configured currently?
The best way is probably passing by reference, as
noted by others. But one thing to note is that @_[2]
is one element of the @_ array (ok, technically it's a
slice, which consists only of the element with index 2
(aka the
Eric,
My first gut feeling on this is folder security.
I would check that the IUSR_servername and/or Guest access for the folders
and subfolders for the adlibsentinal.exe program has at least Read access.
Where servername is the name of the machine...I could be wrong about the
exact name of the
From: Fifield, Mike [EMAIL PROTECTED]
Does anyone know of a perl mod that allows you to delete a winnt
service? The only thing close that I could find was win32::service but
this only allows you to stop start and get status.
Win32::Daemon
Jenda
=== [EMAIL
From: Charles Knell [EMAIL PROTECTED]
I need to pass an array as one of three arguments to a subroutine.
Once inside the subroutine, the array contains only the first item
(index 0) instead of the whole array. It is the third argument, so I
have attempted to retrieve the
Thank you all for your helpful and speedy replies. I sent the message
and then had to go out to do some errands. Somewhere in the back of my
head I could detect a faint echo about how putting an array in a second
array caused the first array to flatten and I did have some notion
about using the
It's not clear exactly what your having problems with. Include example
code if you want better advice.
You'll need to use references or prototypes if you're trying to pass
multiple arrays and/or hashes to a subroutine. Chapter 2 of the camel
book (pp 111-121 in my copy) goes into details
If that's the case, I'll have the right to slam you and say YOU are too lazy
to look things up yourself the next time you post a question that even looks
the slightest bit trivial (and which you can find an answer for in a book or
online or anywhere else).
How many trivial questions are posted
Probably a stupid newbie question, but if you have to pass a reference to an
array, why not just make the array global?
Bill.
_
Chat with friends online, try MSN Messenger: http://messenger.msn.com
bill skipton:
# Probably a stupid newbie question, but if you have to pass a
# reference to an
# array, why not just make the array global?
func(\@a);
func(\@b);
func(\@c);
--Brent Dax
[EMAIL PROTECTED]
Parrot Configure pumpking and regex hacker
Check out the Parrot FAQ:
17 matches
Mail list logo