I wrote a simple Perl script that removes a line from a file then writes it
to another file. The result that is printed to the other file is:
Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239
The last three elements are written from an array. What I would like to do
is only print the numbers
$data = "Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239";
@array = $data =~ /=(\d*)/g;
print "$array[0], $array[1], $array[2]\n";
-Original Message-
From: Alex Nelson [mailto:[EMAIL PROTECTED]]
Sent: 25 June 2001 17:07
To: [EMAIL PROTECTED]
Subject: removing A
nal Message-
> From: Alex Nelson [mailto:[EMAIL PROTECTED]]
> Sent: 25 June 2001 17:07
> To: [EMAIL PROTECTED]
> Subject: removing ASCII characters from array
>
> I wrote a simple Perl script that removes a line from a file then writes it
> to another file. The result that is
> > $data = "Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239";
> >
> > @array = $data =~ /=(\d*)/g;
> >
> > print "$array[0], $array[1], $array[2]\n";
> and for esthetics:
>
> print join ',' @array;
>
> timtowtdi =)
Or
$_ = "Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239";
PROTECTED]>
To: "Jos Boumans" <[EMAIL PROTECTED]>; "John Edwards"
<[EMAIL PROTECTED]>
Cc: "'Alex Nelson'" <[EMAIL PROTECTED]>; "Perl Beginners (E-mail)"
<[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 12:16 AM
Subj
> But that wasnt the question man =)
> you print '230107312001,32,192,239'
>
> but the question was to just have: '32,192,239'
>
> -10 cookie points! ;-)
Oops, being careless.
You could throw away .*?= first:
$_ = "Sat Jun 23 01:07:31 2001,bytes=32,time=192ms,TTL=239";
s/.*?=//g;#
> s/.*?=//g;# remove leading junk
should of course be
> s/.*?=//;# remove leading junk
Ok, ok, I accept another -10 points. :< ;>