Re: about substring

2005-05-10 Thread Ing. Branislav Gerzo
John Doe [JD], on Tuesday, May 10, 2005 at 09:22 (+0200) made these points: JD> Or, shorter (no need to use while _and_ //g): JD> use warnings; JD> use strict; JD> $_ = 'atom 12 N VAL A 1 12.435 13.66 34.6 32.1 32 a N'; JD> my @decimals= /(\d+\.?\d*)/g; JD> print "@decimals\n"; very nice

Re: about substring

2005-05-10 Thread FreeFall
On Tue, 10 May 2005 09:22:31 +0200 John Doe <[EMAIL PROTECTED]> wrote: > my @decimals= /(\d+\.?\d*)/g; cool! Thanks! -- Whatever you do will be insignificant,but the important is you do it! It doesn't matter who you are, it's what you do that takes you far! -- To unsubscribe, e-mail: [EMAI

Re: about substring

2005-05-10 Thread John Doe
Am Dienstag, 10. Mai 2005 09.14 schrieb FreeFall: > use warnings; > use strict; > > my @decimals; > $_ =  'atom 12 N  VAL  A  1  12.435  13.66 34.6  32.1 32   a N'; > push @decimals,$1 while (/(\d+\.?\d*)/g); > > print "@decimals\n"; Or, shorter (no need to use while _and_ //g): use warnings; use

Re: about substring

2005-05-10 Thread FreeFall
Or you can try: __BEGIN__ #!/usr/bin/perl use warnings; use strict; my @decimals; $_ = 'atom 12 N VAL A 1 12.435 13.66 34.6 32.1 32 a N'; push @decimals,$1 while (/(\d+\.?\d*)/g); print "@decimals\n"; __END__ On Mon, 9 May 2005 19:04:08 +0530 Aditi Gupta <[EMAIL PROTECTED]> wrote: > H

Re: about substring

2005-05-09 Thread Edward WIJAYA
After second thought This line: my @y = grep { $_ if ($_ =~ /\d+/)} @list; could be simplified with this: my @y = grep { /\d+/ } split(/\s+/,$file); Since grep { $_ if /\d+/ } wouldn't match on 0, but grep /\d+/ would. I'm still wondering how can I do that with "unpack" :-( -- Regards, Edward WIJAY

Re: about substring

2005-05-09 Thread Edward WIJAYA
On Mon, 09 May 2005 21:34:08 +0800, Aditi Gupta <[EMAIL PROTECTED]> wrote: Can we use substr function for a string like: $file = atom 12 N VAL A 1 12.435 13.66 34.6 32.1 32 a N can the decimal numbers be extracted using $x= substr($file, offset, length) (the exact field lenghts of each f

Re: about substring

2005-05-09 Thread Wiggins d'Anconia
Aditi Gupta wrote: > Hi everybody, > > Can we use substr function for a string like: > $file = atom 12 N VAL A 1 12.435 13.66 34.6 32.1 32 a N > can the decimal numbers be extracted using > $x= substr($file, offset, length) > (the exact field lenghts of each field are known). > > Thanks

about substring

2005-05-09 Thread Aditi Gupta
Hi everybody, Can we use substr function for a string like: $file = atom 12 N VAL A 1 12.435 13.66 34.6 32.1 32 a N can the decimal numbers be extracted using $x= substr($file, offset, length) (the exact field lenghts of each field are known). Thanks in advance.. -- To unsubscribe, e-ma