develooper Front page | perl.golf | Postings from July 2002

Re: a little shorter please?

Thread Next
From:
Steffen Mueller
Date:
July 22, 2002 11:51
Subject:
Re: a little shorter please?
Message ID:
20020722185114.23585.qmail@onion.perl.org
[
Crossposted to perl.fwp and perl.golf. Reply to set to perl.golf. Hope the
newsreader won't fsck it up. :)
]

"Aaron J Mackey" <ajm6q@virginia.edu> schrieb...

> I can't seem to get this any shorter: I want the second through the
> next-to-last elements of @F joined by " ", and then the last item of @F.
>
> perl -ape '$,=" ";s//>@F[1..$#F-1]\n$F[$#F]/'
>
> or (no join, but same general idea):
>
> perl -pe 's/\s+(\S+)$/\n$1/;s/^\S+\s+/>/;'

perl -ae 'print"@F[1..$#F-1]
$F[$#F]"'

To be honest, I haven't tested this, but it looks like it should work just
fine. IIRC, "@ary" will be interpolated to ""

Of course, I regularily miss obvious things. This should give you some
ideas, though.

Steffen
--
@n=(544290696690,305106661574,116357),$b=16,@c=' ,JPacehklnorstu'=~
/./g;for$n(@n){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}c(0..9);
push@p,map{$c[$_]}@c[c($b..$#c)];$#c=$b-1}print@p;sub'c{reverse @_}


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About