How to solve the following?
use 5.014;
use warnings;
use Test::Simple tests => 4;
ok( doit(0123) == 83, "arg as octal number" );
ok( doit(83) == 83, "arg as decimal number" );
ok( doit('0123') == 83, "arg as string with leading zero" );
ok( doit('123') == 83, "arg as string without leading zero" );
sub doit {
my $x = shift;
return $x; # how to replace this line
#return got_the_arg_as_string ? oct($x) : $x; # with something like this
}
E.g. If i pass to the doit
sub any string - mean quoted value - (with or without the leading zero), it should be converted to octal value. Otherwise, it is just an number.