Muthukumar wrote:
> 
> Hai all.

Hello,

> I want to make a script which converts like (pErl1234test = perl).I
> wrote like
> 
> #!/usr/bin/perl
> print "Enter ur name"
> $name = <STDIN>
> $org_name = $name
> $name =~ s/\W.*//;      #change 1

The \W character class includes every character that is NOT a-z and A-Z
and 0-9 and _.  If you just want to keep only the letters at the
beginning of the string:

$name =~ s/[^a-zA-Z].*//;

Or:

$name =~ s/[^[:alpha:}].*//;

Or:

$name = $1 if $org_name =~ /^([a-zA-Z]+)/;

etc.


> $name =~ tr/A-Z/a-z/;  #change  2

You can also use the lc() function for that.

$name = lc $name;


> print "Old = $org_name\n";
> print "New = $name\n";
> 
> But i can not get a change on the change 1 and 2 lines.



John
-- 
use Perl;
program
fulfillment

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