On Jun 20, Balint, Jess said: >Are these -l and -n flags specific to perl 5.6? I am using 5.005 and they >don't work as illustrated:
The -l and -n flags have been with Perl for quite some time. >% perl -e 'while{print if(.45909592993094279021 < rand);}' db_mlb_undup.dat Uh, you're missing something on your while loop. perl -e 'while (<>) { print if .4590959 < rand }' db_mlb_undup.dat >% cat db_mlb_undup.dat | perl -e 'while(<>){print if(.45909592993094279021 < >rand);}' | head -1 >100000127| Again, no need for 'cat' here; you can put it at the end of the invokation of 'perl' as you did above. >% cat db_mlb_undup.dat | perl -el 'while(<>){print if(.45909592993094279021 >< rand);}' | head -1 Ah. ;) >% cat db_mlb_undup.dat | perl -en 'print if(.45909592993094279021 < rand);' >| head -1 Heh. A tricky problem, I'll warrant. The problem you're having is that you're putting the -l and the -n ON the -e flag. perl -eprint+pop 10 20 30 prints 30, because it's like saying perl -e 'print pop @ARGV' 10 30 30 Anyway, the -e is biblical in nature, as it says to other command-line flags "get thee behind me". ;) perl -le 'print if /foo/' file prints lines of 'file' that have 'foo' on them, whereas perl -el 'print if /foo/' file executes the statement 'l', and stores 'print if /foo/' and 'file' in @ARGV, where they get bored. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]