Nathan Hilterbrand writes:
> On 01/25/2016 05:13 PM, lee wrote:
>> Paul Johnson writes:
>>
>>> On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote:
Paul Johnson writes:
>>> [...]
Consider with these examples that an expression like
Kent Fredric writes:
> On 26 January 2016 at 12:02, Nathan Hilterbrand wrote:
>> return wantarray() ? ($a, $b) : [$a, $b];
>>
>> In a list context, you get back a list.. otherwise you get back a reference
>> to a list. Might not be what you want,
On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote:
> Paul Johnson writes:
>
> > On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote:
> >> Hi lee,
> >>
> >> On Sun, 24 Jan 2016 13:11:37 +0100
> >> lee wrote:
> >>
> >> > Paul Johnson
On 01/25/2016 05:13 PM, lee wrote:
Paul Johnson writes:
On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote:
Paul Johnson writes:
[...]
Consider with these examples that an expression like (1, 3) might
unexpectedly evaluate to 3, and you start to think that
Shlomi Fish writes:
> Hi lee,
>
> I should note that it is my impression that you are far too needy in your
> enquiring, and I'm starting to lose patience.
>
> On Mon, 25 Jan 2016 00:11:43 +0100
> lee wrote:
>
>> Shlomi Fish
Paul Johnson writes:
> On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote:
>> Paul Johnson writes:
> [...]
>> Consider with these examples that an expression like (1, 3) might
>> unexpectedly evaluate to 3, and you start to think that you don't like
>> things
On 26 January 2016 at 12:02, Nathan Hilterbrand wrote:
> return wantarray() ? ($a, $b) : [$a, $b];
>
> In a list context, you get back a list.. otherwise you get back a reference
> to a list. Might not be what you want, though.
>
> Works with arrays, too..
>
> my @anarray =
Hi lee,
I should note that it is my impression that you are far too needy in your
enquiring, and I'm starting to lose patience.
On Mon, 25 Jan 2016 00:11:43 +0100
lee wrote:
> Shlomi Fish writes:
>
> >> >
> >> > In scalar context the comma operator
Paul Johnson writes:
> On Tue, Sep 09, 2014 at 03:12:00PM -0700, Jim Gibson wrote:
>>
>> On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote:
>>
>> > On Tue, 09 Sep 2014 23:09:52 +0200
>> > lee wrote:
>> >
>> >> my $i = 1;
>> >> my $f = 2.5;
>> >> my $s =
Hi lee,
On Sun, 24 Jan 2016 13:11:37 +0100
lee wrote:
> Paul Johnson writes:
>
> > On Tue, Sep 09, 2014 at 03:12:00PM -0700, Jim Gibson wrote:
> >>
> >> On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote:
> >>
> >> > On Tue, 09 Sep 2014 23:09:52 +0200
> >>
On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote:
> Hi lee,
>
> On Sun, 24 Jan 2016 13:11:37 +0100
> lee wrote:
>
> > Paul Johnson writes:
> > >
> > > In scalar context the comma operator evaluates its left-hand side,
> > > throws it away and returns
On Sun, 24 Jan 2016 20:03:29 +0100
Paul Johnson wrote:
> On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote:
> > Hi lee,
> >
> > On Sun, 24 Jan 2016 13:11:37 +0100
> > lee wrote:
> >
> > > Paul Johnson writes:
> > > >
> > > > In
Paul Johnson writes:
> On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote:
>> Hi lee,
>>
>> On Sun, 24 Jan 2016 13:11:37 +0100
>> lee wrote:
>>
>> > Paul Johnson writes:
>> > >
>> > > In scalar context the comma operator evaluates its
Shlomi Fish writes:
>> >
>> > In scalar context the comma operator evaluates its left-hand side,
>> > throws it away and returns the right-hand side.
>>
>> What is the useful use for this operator?
>>
>
> Well, I believe its use was originally inherited from
>
Jim Gibson jimsgib...@gmail.com writes:
On Sep 8, 2014, at 3:13 PM, lee wrote:
Shawn H Corey shawnhco...@gmail.com writes:
On Mon, 18 Aug 2014 16:17:53 +0800
# or
sub myfunc {
return [ 1, 2, 3 ];
}
Is there a difference to
sub myfunc {
return ( 1, 2, 3 );
}
The first
On Tue, 09 Sep 2014 23:09:52 +0200
lee l...@yun.yagibdah.de wrote:
my $i = 1;
my $f = 2.5;
my $s = 'string';
my $list = (1, 2, 3);
No, the count of items in the list gets stored in $list: $list == 3
my $list_reference = [(1, 2, 3)];
my $dereferenced_list = $@list_reference;
my
On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey shawnhco...@gmail.com wrote:
Lists are sequences used by Perl. They are very short lived, seldom
longer than one statement.
The way I've always liked to explain this is that arrays are the
containers you use to store a list.
As Shawn says, a list
On Sep 9, 2014, at 2:09 PM, lee wrote:
Jim Gibson jimsgib...@gmail.com writes:
On Sep 8, 2014, at 3:13 PM, lee wrote:
Shawn H Corey shawnhco...@gmail.com writes:
On Mon, 18 Aug 2014 16:17:53 +0800
# or
sub myfunc {
return [ 1, 2, 3 ];
}
Is there a difference to
sub myfunc {
On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote:
On Tue, 09 Sep 2014 23:09:52 +0200
lee l...@yun.yagibdah.de wrote:
my $i = 1;
my $f = 2.5;
my $s = 'string';
my $list = (1, 2, 3);
No, the count of items in the list gets stored in $list: $list == 3
Unless the thing on the
On 09/09/2014 06:01 PM, John SJ Anderson wrote:
On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey shawnhco...@gmail.com wrote:
Lists are sequences used by Perl. They are very short lived, seldom
longer than one statement.
The way I've always liked to explain this is that arrays are the
containers
On Tue, 9 Sep 2014 15:05:58 -0700
Jim Gibson jimsgib...@gmail.com wrote:
Some people make a distinction between 'list' and 'array'. A list is
a sequence of scalar values indexed by an integer. An array is a
variable whose value is a list (or something like that -- I don't
really distinguish
On Tue, Sep 09, 2014 at 03:12:00PM -0700, Jim Gibson wrote:
On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote:
On Tue, 09 Sep 2014 23:09:52 +0200
lee l...@yun.yagibdah.de wrote:
my $i = 1;
my $f = 2.5;
my $s = 'string';
my $list = (1, 2, 3);
No, the count of items in the
Shawn H Corey shawnhco...@gmail.com writes:
On Mon, 18 Aug 2014 16:17:53 +0800
Ken Peng o...@dnsbed.com wrote:
sub myfunc {
my @x=(1,2,3);
return \@x;
}
# or,
sub myfunc {
my @x=(1,2,3);
return [@x];
}
# or
sub myfunc {
return [ 1, 2, 3 ];
}
Is there a difference
On Sep 8, 2014, at 3:13 PM, lee wrote:
Shawn H Corey shawnhco...@gmail.com writes:
On Mon, 18 Aug 2014 16:17:53 +0800
Ken Peng o...@dnsbed.com wrote:
sub myfunc {
my @x=(1,2,3);
return \@x;
}
# or,
sub myfunc {
my @x=(1,2,3);
return [@x];
}
# or
sub myfunc {
On Tue, 09 Sep 2014 00:13:13 +0200
lee l...@yun.yagibdah.de wrote:
Shawn H Corey shawnhco...@gmail.com writes:
On Mon, 18 Aug 2014 16:17:53 +0800
Ken Peng o...@dnsbed.com wrote:
sub myfunc {
my @x=(1,2,3);
return \@x;
}
# or,
sub myfunc {
my @x=(1,2,3);
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]
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;
30 matches
Mail list logo