Jeff Pan <mailto:[EMAIL PROTECTED]> wrote:

: Charles wrote:
: :
: :     my @array = ( $1, $2, $3, $4 );
: :
: :     Or this:
: :
: :     my @array = //;
:
:
: Sorry, when I use the second way u mentioned,it can't work.

    Works for me.

use strict;
use warnings;
use Data::Dumper 'Dumper';

my $host = 'rocket';
while ( <DATA> ) {
    next unless /^$host/o and
/\((\D),\s*(\d{1,2})\)\s*\((\D),\s*(\d{1,2})\)/;
    my @c = //;
    print Dumper [EMAIL PROTECTED];
}

__END__
foo
bar
meteor    (L, 4) (G,24)
rocket    (J,19) (D,35)
aulan     (E,28) (E, 2)
baz
aupbx     (B,32) (O,10)


: the code:
: while(<>)
: {
:     next unless /$host/;
:     $_=~/\((\w+)\,\s*(\d+)\)\s+\((\w+)\,\s*(\d+)\)/;
: #    my @array=("$1","$2","$3","$4");
:     my @array=qw/$1 $2 $3 $4/;

    Huh? That's not what I wrote.

    my @array = ( $1, $2, $3, $4 );

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to