#!/usr/bin/perl -w use 5.016; # rounded-1079543.pl - Round to 2 decimal places using regexen # (even though printf/sprintf would be preferred) # update 2: as Laurent_R notes, this is truncation, not rounding. # but it is what OP asked for. my $num = 3.333333333; $num =~ /(\d*\.\d{2})/; my $roundednum = $1; say $roundednum; # or my $num2 = 5.5555555; $num2 =~ s/(\d*\.)(\d)(\d).*/$1$2$3/; my $rounded2 = $num2; say $rounded2; =head execution: C:>rounded-1079543.pl 3.33 5.55 =cut