Hi,
  There is something that's bothering me for so long
regarding the use of $_ variable.

for example:
here is my string:
$_ = "but";
s/u/a/g;
print $_;

This will simply print "bat"

My problem is using a variable in place of $_.
how will I tell that the one i'm going to substitute
is the $string;
Ex:
  my $string = "but";
   s/u/a/g;
   print $string;

and I get this error when i run it.

Use of uninitialized value in substitution (s///) at
substitute line 6.

I don't have any trouble with regex matching using $_
or any varible because I can always say:
if $variable =~/\d/  instead of:
if(/\d/)   which is equivalent to $_=~/\d/;

I don't know how to do it with substitutions.


any idea?
thanks







                
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

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