In case no one has mentioned it, there are good reasons for
using '-w' and "use strict;" in your perl code....

On Monday, April 15, 2002, at 05:16 , Daniel Falkenberg wrote:
[..]
> $string = "$20.90";
>
> $string =~ s/$//; <-- I figured this would work fine?
[..]

if you had used '-w' and strict you would have recieved
perl junk.pl
Use of uninitialized value in concatenation (.) at junk.pl line 3.
we is :.90:

from code of the form:
        #!/usr/bin/perl -w
        use strict
        my $string = "$20.90";  #<where perl will first freak
        $string =~ s/$//;
        print "we is :$string:\n";

hence noticed first that " " allows interpolation, and should
have used '$20.90' to prevent the system from trying to find
where you had set the $20 variable...

but you would be at:

        perl junk.pl
        we is :$20.90:

$ is reserved

hence try

$string =~ s/\$// ;

and presto you would get:

        perl junk.pl
        we is :20.90:

and our junk.pl script now reads as:
        #!/usr/bin/perl -w
        use strict
        my $string = '$20.90';  #< where perl does not freak
        $string =~ s/\$//;              #< how to sub out the $ token
        print "we is :$string:\n";



ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to