#!/usr/bin/perl -- use strict; use warnings; use Test::More qw( no_plan ); Main(@ARGV); exit(0); sub writeoff { my ( $prefix, $last ) = shift()=~ /^(.+)(.)$/; $last = $last < 5 ? 0 : 5; return "$prefix$last"; } sub Main { my @input = qw( 9.91 9.92 9.95 9.99 ); my @wanted_output = qw( 9.90 9.90 9.95 9.95 ); my @got = map { writeoff($_) } @input; is_deeply( \@got, \@wanted_output, "@wanted_output" ); } __END__ ok 1 - 9.90 9.90 9.95 9.95 1..1
In reply to Re: write off function using regex
by Anonymous Monk
in thread write off function using regex
by suhailck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |