Substitute in Perl
$ft="Lindon";
$ft =~ s/i/o/;
$ft now equals London.
-The variable you named $ft contains the typoed city London.
-The s after the ~ tilde symbol means substitute.
-Between the first two slashes, you type what is to be replaced.
-Between the second two slashes, you type what to replace with.
$ft="TOKYO";
$ft =~ s/o//ig;
$ft is now equal to Tky.
-This time we replaced o's with nothing.
-The i means case-INsensitive.
-The g means change ALL the o's in $ft.
Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$ft="Lindon";
$ft =~ s/i/o/;
print "$ft ";
$ft="TOKYO";
$ft =~ s/o//ig;
print "$ft";
exit;
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | |
| | | |
HTML Gary B. Shelly, Th... | | |