.say for =$fh;
####
print while <$fh>; # assuming $\="\n"
####
pugs> sub postfix: (Int $n) { [*] 1..$n }
undef
pugs> say $_! for ^6
1
1
2
6
24
120
undef
####
From: Abigail
Subject: Re: I find the perl syntax easier than python
Message-ID:
Date: 03 May 2007 19:21:12 GMT
Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXCII September
MCMXCIII in :
\\
\\ Since I mentioned Perl 6 above, in it eventually we will have more
\\ convenient ways and less ambiguity in passing parameters. We will
\\ still be able to use @_ & C. but who does really need them when you
\\ can do
\\
\\ sub addprint ($n,$m) { say $n+$m } # ?
And this is an advantage? Limiting yourself to two arguments?
In Perl5, you aren't tempted to use named variables, so you get
your arguments in an array. And given an array, it's natural to
allow a variable number of arguments:
sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
####
From: "David Formosa (aka ? the Platypus)"
Subject: Re: I find the perl syntax easier than python
Message-ID:
Date: Thu, 03 May 2007 21:02:45 GMT
On 03 May 2007 19:21:12 GMT, Abigail wrote:
> In Perl5, you aren't tempted to use named variables, so you get
> your arguments in an array. And given an array, it's natural to
> allow a variable number of arguments:
>
>
> sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}
So you do something like this
sub addprint (*@num) { say [+] @num };
####
From: Abigail
Subject: Re: I find the perl syntax easier than python
Message-ID:
Date: 03 May 2007 21:12:37 GMT
David Formosa (aka ? the Platypus) (dformosa@usyd.edu.au) wrote on
MMMMCMXCIII September MCMXCIII in :
^^ On 03 May 2007 19:21:12 GMT, Abigail wrote:
^^
^^ > In Perl5, you aren't tempted to use named variables, so you get
^^ > your arguments in an array. And given an array, it's natural to
^^ > allow a variable number of arguments:
^^ >
^^ >
^^ > sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}
^^
^^ So you do something like this
^^
^^ sub addprint (*@num) { say [+] @num };
Yeah, but that's only on the second try. ;-)
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/
####
From: "David Formosa (aka ? the Platypus)"
Subject: Re: I find the perl syntax easier than python
Message-ID:
Date: Fri, 04 May 2007 12:41:14 GMT
On 03 May 2007 21:12:37 GMT, Abigail wrote:
> David Formosa (aka ? the Platypus) (dformosa@usyd.edu.au) wrote on
> MMMMCMXCIII September MCMXCIII in :
> ^^ On 03 May 2007 19:21:12 GMT, Abigail wrote:
[...]
> ^^ > sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}
> ^^
> ^^ So you do something like this
> ^^
> ^^ sub addprint (*@num) { say [+] @num };
>
> Yeah, but that's only on the second try. ;-)
But mine is more elegant.
####
From: Michele Dondi
Subject: Re: I find the perl syntax easier than python
Message-ID:
Date: Thu, 03 May 2007 23:45:03 +0200
On Thu, 03 May 2007 21:02:45 GMT, "David Formosa (aka ? the Platypus)"
wrote:
>So you do something like this
>
>sub addprint (*@num) { say [+] @num };
D'Oh, you beat me. But in my example I showed our friend Abigail that
if you really want you still have @_.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^##
From: Michele Dondi
Subject: Re: I find the perl syntax easier than python
Message-ID:
Date: Thu, 03 May 2007 23:41:26 +0200
On 03 May 2007 19:21:12 GMT, Abigail wrote:
>\\ sub addprint ($n,$m) { say $n+$m } # ?
>
>And this is an advantage? Limiting yourself to two arguments?
Well, you know perfectly well that this is an *artificial* example to
mimic the OP's one. But yes, it's there for those cases in which I
*do* want to limit myself to two arguments, and perhaps type check
them.
>In Perl5, you aren't tempted to use named variables, so you get
>your arguments in an array. And given an array, it's natural to
I can't believe you're implicitly assuming that those guys aren't
thinking of letting you do that in Perl 6 too, and more.
>allow a variable number of arguments:
>
> sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}
Funny, in Perl 6 that could be
sub addprint {say [+] @_}
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^