It will...

#!/usr/bin/perl

my $var = "--  hellohowareyou-";


$_ = $var;
while (/(.)/g) { # . is never a newline here
        # do something with $1
        if($1 eq '-') {
                printf "HELLO";
        }
        else {
                printf "HI";
        }

    }


On Fri, 29 Oct 2004 [EMAIL PROTECTED] wrote:

> Hi All,
> I have to write a code wherein I have to access each character in a
> string and compare it with '-'
>
> $_ = $seq1[0];
> while(/./g) {
>  if($1 eq '-') {
>     $res1[0] .= '-';
>  }
>  else {
>     $res1[0] = "A";
>  }
> }
>
> I have initialised $_ with the string in which I have to search. Now I
> know that the while loop will read each and every character in the
> string. I just need to get that character read to make the comparison. I
> know $1 doesnt work because it is not :) Where is the value returned or
> how can I assign a variable the value of the condition in the while loop ?
>
> Thanks,
> Manas.
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


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