Jerry Rocteur wrote:
>
> On Sunday, Dec 15, 2002, at 13:00 Europe/Brussels, John W. Krahn wrote:
> >> perl -e 'for (@ARGV) {rename $_,uc($_) unless -e "uc($_)"; } ' *
> >> What is wrong with it ???
> >
> > subs/functions don't interpolate in quoted strings.
> >
> > perl -e'-e uc||rename($_,uc)for@ARGV' *
>
> You're incredible John.. You must be Larry's brother ;-))
>
> Thanks very much..
>
> If anyone has one liners you think I could use, send them to me, I'm
> composing a list from the ones I've found, I've not tried them all yet
> but I'm working my way through them:
>
> http://www.rocteur.cc/geeklog/public_html/article.php?story=20020118223020446
I would probably write your one-liner # 10 like this so you will at
least get an error message if the word file can't be opened:
perl -nle'BEGIN{$w=join"",sort split//,shift;@ARGV="/usr/dict/english"}
print if $w eq join"",sort split//' life
Your one-liner # 12 could print out the same line ten times (that's the
way randomness works.) If you really want ten different random lines:
perl -e'$count = 10; @line = <>; print splice @line, rand @line, 1 for 1
.. $count'
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]