Hi all,

I write a small script for practice purpose. 
I have a string line in this format:
$string="password=xyz verbose=9 score=0";
I want to parse out password, verbose, and score into
one array and xyz, 9 and 0 into another array. But I
don't get what I expect. I just wonder what is wrong?

Thanks,

Li

This is my sctipt:

#!/usr/bin/perl
use warnings;
use strict;

 my $string="password=xyz verbose=9 score=0";
 my @keys=();
 my @values=();
 while ($string=~/(\w+)=(\w+)/g){

  @keys=push(@keys, $1);
  print $1, "\n";
  @values=push(@values,$2);
  print $2, "\n";
 }
print "\nThese are the keys:","@keys";

print "\nThese are the values:","@values","\n";
exit;

And these are the results after I run the script:

password
xyz
verbose
9
score
0

These are the keys:2
These are the values:2



  

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
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