2010/1/14 Dave Cross <[email protected]>:
> But I'd probably do something like this:
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> foreach (<DATA>) {
> s/\.?0+$//;
> print;
> }
>
> __END__
> 1.20
> 1.00
> 1.25
>
>
Not sure about the '?', surely you don't want this to happen:
#!/usr/bin/perl
use strict;
use warnings;
foreach (<DATA>) {
s/\.?0+$//;
print;
}
__END__
1.20
1.00
1.25
10
To add to Jake Peavy's comment, add 0 to string representing a number:
#!/usr/bin/perl
use strict;
use warnings;
foreach (<DATA>) {
$_="$_";
print "$_";
$_=$_+0;
print "$_\n";
}
__END__
1.20
1.00
1.25
10
--
imalone
--
users mailing list
[email protected]
To unsubscribe: https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines