develooper Front page | | Postings from July 2002

Re: a little shorter please?

Thread Next
Steffen Mueller
July 22, 2002 11:51
Re: a little shorter please?
Message ID:
Crossposted to perl.fwp and Reply to set to Hope the
newsreader won't fsck it up. :)

"Aaron J Mackey" <> 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]

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.

@n=(544290696690,305106661574,116357),$b=16,@c=' ,JPacehklnorstu'=~
push@p,map{$c[$_]}@c[c($b..$#c)];$#c=$b-1}print@p;sub'c{reverse @_}

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About