Corrceted One:

@myarra = ("test","error","block");

$file = 'sorted'; # File contain records xxx.xxx.xxx
# i need last symbols after last -> .
open(FILE, $file);
while ($data = <FILE>) {
    $backupdata = $data;
    $data =~ s/^(\S+)\.//g; # Remove xxx.xxx. get last 2 or 3 symbols
#chomp($data);

    $data = lc($data); # make $data to lowercast
    for ($i = 0; $i < 3; ++$i)
    {
 if ($data =~ /$myarra[$i]/){ # this not work
    # $data contain -> est
    # $myarra[$i] -> test
    # and script say equal but not.
print "------\n";
print "$data\n";
print "$i\n";
print "$myarra[ $i ]\n";
print "$backupdata\n"; # print $backupdata if
# $data equal to @myarra[$i], in this case test = test, error = error
# etc.
print "------\n";
        }
    }
}

close (FILE);


----- Original Message ----- 
From: "John Doe" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 14, 2004 2:13 AM
Subject: Problem compare string with array


> Hello all,
> i have problem, and i don't know where is my mistake.
> 
> ---
> #!/usr/bin/perl
> 
> @myarra = ("test","error","block");
> 
> $file = 'sorted'; # File contain records xxx.xxx.xxx
> # i need last symbols after last -> .
> open(FILE, $file);
> while ($data = <FILE>) {
>     $backupdata = $data;
>     $data =~ s/^(\S+)\.//g; # Remove xxx.xxx. get last 2 or 3 symbols 
> after last -> .
>     $data = lc($data); # make $data to lowercast
>     for ($i = 0; $i < 3; ++$i)
>     {


>       if ($data eq $myarra[$i]) # no any outputs :(

 if ($data eq $myarra[$i]) { # no any outputs :(

> # if ($data =~ /$myarra[$i]/) # this not work
>     # $data contain -> est
>     # $myarra[$i] -> test
>     # and script say equal but not.

remove the following brace.

>         {

> print "------\n";
> print "$data\n";
> print "$i\n";
> print "$myarra[ $i ]\n";
> print "$backupdata\n"; # print $backupdata if
> # $data equal to @myarra[$i], in this case test = test, error = error
> # etc.
> print "------\n";
>         }
>     }
> }
> 
> close (FILE);
> -----
> 
> Any body can help me ? i read some documentation but unable
> to fix problem.
> 
> Regards,
> John
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.665 / Virus Database: 428 - Release Date: 4/23/2004

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