> I have a variable: > $NUM = '14.45905495'; > and I want to remove the trailing digits and only leave 2 > after the period > so it ends up > > '14.45' > > I've tried to do this but it appears to return as an array > and always prints > out "1". > > #!perl -w > > $NUM = '14.45905495'; > @POST = ($NUM =~ /\d\.\d{2}/); > print "new value is $POST[0]\n";
if you just want to print the string with the unwanted numbers truncated: printf ("%.5s", $NUM) or if you want to print a floating point that rounds: printf ("%4.2f", $NUM); or you could use perldoc -f : sprintf rindex substring -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]