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 (1, 3) might
unexpectedly evaluate to 3, and you
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, though.
>>
>> Works with arrays, too..
>>
>> my
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 = ()
> return wanta
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 you don't like
things like
s
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 writes:
>>
>> >> >
>> >> > In scalar context the comma operator evalu
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 like
>>
>>
>> sub s {
>> my
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 writes:
> >> > >
> >> > > In scalar context the com
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 evaluates its left-hand side,
> >> > throws
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 left-hand side,
>> > > throws it away and returns
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
> https://en.wikipedia.org/wiki/C_
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 scalar context the comma operator evaluates its lef
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 the right-hand side.
> >
> > W
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
> >> > lee wrote:
> >> >
> >> >> my
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 = 'string';
>> >> my $list = (1, 2, 3);
>>
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 = 'string';
> >> my $list = (1, 2, 3);
> >
> > No, the count of items in the
On Tue, 9 Sep 2014 15:05:58 -0700
Jim Gibson 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 the two myself.)
On 09/09/2014 06:01 PM, John SJ Anderson wrote:
On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey 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 li
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 = '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 right-hand-side of t
On Sep 9, 2014, at 2:09 PM, lee wrote:
> Jim Gibson writes:
>
>> On Sep 8, 2014, at 3:13 PM, lee wrote:
>>
>>> Shawn H Corey writes:
>>>
On Mon, 18 Aug 2014 16:17:53 +0800
# or
sub myfunc {
return [ 1, 2, 3 ];
}
>>>
>>> Is there a difference to
>>>
>>> sub my
On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey 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 is usually pretty ep
On Tue, 09 Sep 2014 23:09:52 +0200
lee 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 @dereferenced_list = @$li
Jim Gibson writes:
> On Sep 8, 2014, at 3:13 PM, lee wrote:
>
>> Shawn H Corey 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 example r
On Tue, 09 Sep 2014 00:13:13 +0200
lee wrote:
> Shawn H Corey writes:
>
> > On Mon, 18 Aug 2014 16:17:53 +0800
> > Ken Peng wrote:
> >
> >> sub myfunc {
> >> my @x=(1,2,3);
> >> return \@x;
> >> }
> >>
> >> # or,
> >>
> >> sub myfunc {
> >> my @x=(1,2,3);
> >> return [@x];
> >> }
> >
On Sep 8, 2014, at 3:13 PM, lee wrote:
> Shawn H Corey writes:
>
>> On Mon, 18 Aug 2014 16:17:53 +0800
>> Ken Peng wrote:
>>
>>> sub myfunc {
>>> my @x=(1,2,3);
>>> return \@x;
>>> }
>>>
>>> # or,
>>>
>>> sub myfunc {
>>> my @x=(1,2,3);
>>> return [@x];
>>> }
>>
>> # or
>>
>> sub myfu
Shawn H Corey writes:
> On Mon, 18 Aug 2014 16:17:53 +0800
> Ken Peng 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 to
su
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]
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
- 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
>
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) {
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;
$
30 matches
Mail list logo