On Mar 29, 2004, at 3:35 AM, MuthuKumar wrote:

Hai all.

Howdy.


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

You are missing semi-colons on all three lines above.


$name =~ s/\W.*//; #change 1

In English, that says, "Find a non-word character followed by zero or more anything characters and delete them." Perl's idea of non-word characters is anything not in the set [A-Za-z0-9_]. You don't have any non-word characters in your sample string, so it does not match.


I believe you wanted:

$name =~ s/[^A-Za-z].*//;

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

The above line looks like it should be lowercasing everything to me, though I would probably write it as:


$name = lc $name;

Hope that helps.

James

        print "Old = $org_name\n";
        print "New = $name\n";

But i can not get a change on the change 1 and 2 lines.

    Regards,
    Muthukumar.




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