From: Sherm Pendley on 18 Sep 2009 09:45 Sherm Pendley <spamtrap(a)shermpendley.com> writes: > Jose Luis <jose.luis.fdez.diaz(a)gmail.com> writes: > >> Given the string "one;two;three;four...", is there a easy way to >> print "one": > > perl -e "print split(';', 'one;two;three;four')[0]" Duh, stupid typos. Should be: perl -e "print ((split(';','one;two;three;four...'))[0])" sherm--
From: Tad J McClellan on 18 Sep 2009 10:27 Jose Luis <jose.luis.fdez.diaz(a)gmail.com> wrote: > > Given the string "one;two;three;four...", is there a easy way to > print "one": print "one"; -- Tad McClellan email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
From: Steve C on 18 Sep 2009 12:12 Jose Luis wrote: > Hi, > > Given the string "one;two;three;four...", is there a easy way to > print "one": > > > $ echo "one;two;three;four..."|perl -e 'while(<>){$_ =~ /^(.*)(\;)(.*) > $/ && print $1}' > one;two;three > > Use 'sed mode': echo "one;two;three;four..."|perl -pe 's/;.*//' one autosplit lets you pick other than first element: echo "one;two;three;four..."|perl -lanF';' -e'print $F[1]' two
From: Ben Morrow on 18 Sep 2009 14:27 Quoth Jose Luis <jose.luis.fdez.diaz(a)gmail.com>: > > Given the string "one;two;three;four...", is there a easy way to > print "one": > > $ echo "one;two;three;four..."|perl -e 'while(<>){$_ =~ /^(.*)(\;)(.*) > $/ && print $1}' > one;two;three ~% echo "one;two;three;four..." | perl -naF\; -le'print $F[0]' one or, if you have 5.10, ... | perl -naF\; -E'say $F[0]' Ben
First
|
Prev
|
Pages: 1 2 Prev: SIGUSR1 ignored during poll() if sleep() and warn() called? Next: decimal round off issue |