Thanks for answering David, Jeff and Beau. My script works like a charm
now.
Ken
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Here's the flip side of yesterday's array question. Now that I know how
to pass associative arrays out of a routine, I'm having trouble trying
to use them in other routines. The best I can figure from reading is
that I need to pass them by reference, but in practice, the terminal
always fills
On Sunday, June 1, 2003, at 03:27 PM, Ken Tozier wrote:
my $description = DescribeCritter(\% wombatStats);
This is passing a hash to a hash. No reference required for that.
Just drop the \. I also believe you have a space after the % that
shouldn't be there.
Hope that helps.
James
--
To
On Sunday, June 1, 2003, at 04:35 PM, James Edward Gray II wrote:
On Sunday, June 1, 2003, at 03:27 PM, Ken Tozier wrote:
my $description = DescribeCritter(\%wombatStats);
This is passing a hash to a hash. No reference required for that.
Just drop the \. I also believe you have a space after
On Sunday, June 1, 2003, at 04:12 PM, Ken Tozier wrote:
No luck. Dropping the \ in 'my $description =
DescribeCritter(\%wombatStats);' didn't fix the problem.
You're right. I was dumb. Let me try again...
my $description = DescribeCritter(\% wombatStats);
Drop the backslash and space here,
Ken Tozier [EMAIL PROTECTED] wrote:
:
: my %wombatStats = GetWombat();
: my $description = DescribeCritter(\% wombatStats);
my $description = DescribeCritter(\%wombatStats);
I didn't try it but I don't think the space after
'%' is a good idea. It is a good idea to get in the
habit of passing
On Sun, Jun 01, 2003 at 04:20:28PM -0500 James Edward Gray II wrote:
On Sunday, June 1, 2003, at 04:12 PM, Ken Tozier wrote:
No luck. Dropping the \ in 'my $description =
DescribeCritter(\%wombatStats);' didn't fix the problem.
You're right. I was dumb. Let me try again...
my
I'm sure this is an easy one but after Googling for hours, I still
don't get it. Given the following subroutine, how do I return the
result array? Nothing I try works.
sub GetMarmots
{
@result = ();
$result{'steppe marmot '} = 4;
$result{'himalayan marmot'} = 3;
Ken, your mixing your @ with your %
Try this:
#!/usr/bin/perl
GetMarmots;
sub GetMarmots {
%result = ();
$result{'steppe marmot'} = 4;
$result{'himalayan marmot'} = 3;
$result{'mongolian marmot'} = 1;
$result{'woodchuck'} = 6;
return %result;
}
foreach (keys %result)
- Original Message -
From: Ken Tozier [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, May 31, 2003 5:24 PM
Subject: Returning arrays from subroutines... how?
I'm sure this is an easy one but after Googling for hours, I still
don't get it. Given the following subroutine, how
jeff loetel [EMAIL PROTECTED] wrote:
: Try this:
:
: #!/usr/bin/perl
:
: GetMarmots;
:
: sub GetMarmots {
: %result = ();
: $result{'steppe marmot'} = 4;
: $result{'himalayan marmot'} = 3;
: $result{'mongolian marmot'} = 1;
: $result{'woodchuck'} = 6;
: return %result;
David Newman wrote:
Greetings. I have a newbie question about passing arrays into a subroutine
(and getting return values as well).
Hi David,
I can't help much as far as passing or returning whole arrays, but there is a much
better way to access arrays from inside a function. I'll show you
Greetings. I have a newbie question about passing arrays into a subroutine
(and getting return values as well).
My script uses arrays for various values -- one array each for TCP port
numbers, UDP port numbers, and the different bytes of IP addresses.
Since I have to populate each of these
You need to pass the array to the function by reference, here's the fix.
spin([EMAIL PROTECTED]);
sub spin
{
$arr = shift;
for (; $count 0; $count--)
{
push(@$arr, $start++);
}
}
but if all you want to do is to populate your array with value between
1025 to 1035, here's a
Hi Guys
I was wondering if you could help me.
I have a multi-dimensional array and I would like to pass it to a subroutine
as follows :
my multi_array = ([1,2,3,4], [5,6,7,8]);
my result = process_array(multi_array);
print The result is : result\n;
sub process_array {
my
, July 17, 2002 11:43 AM
To: '[EMAIL PROTECTED]'
Subject: Multi-dimensional arrays and subroutines
Hi Guys
I was wondering if you could help me.
I have a multi-dimensional array and I would like to pass it to a
subroutine as follows :
my @multi_array = ([1,2,3,4], [5,6,7,8]);
my
On Jul 17, Ho, Tony said:
$sth-bind_param(1, @$_-[0]);
You've already fixed your problem, so that's good, but I would use
$sth-bind_param(1, $_-[0]);
instead of
$sth-bind_param(1, @$_-[0]);
Yours works by some bizarre coincidence of Perl's parsing. It should be
considered a
Hi
How can I pass two arrays as subroutine arguments?
thanks in advances
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Hello Diego,
Thursday, July 26, 2001, Diego Riaño [EMAIL PROTECTED] wrote:
DR How can I pass two arrays as subroutine arguments?
passing arrays as arguments is bad idea; you should use references.
my_sub(\@array1, \@array2);
sub my_sub
{
my ($ref1,$ref2) = @_;
print $$ref1[0], $$ref2[0];
}
19 matches
Mail list logo