Skip to content

Instantly share code, notes, and snippets.

@xtetsuji xtetsuji/
Last active Jan 1, 2016

What would you like to do? sample code of twice eval simple_replace option. see:
#!/usr/bin/env perl
use strict;
use warnings;
while(my $str = <STDIN>) {
chomp $str;
my $res = calc_strings($str);
if ( defined $res ) {
print "$res\n";
} else {
print "Input Error: $str\n";
sub calc_strings {
my $str = shift;
# 文字クラス [...] の中での - は文字コード範囲になるので端っこに置く
$str =~ s|^(\d+)\s*([-+/*])\s*(\d+)$| "$1 $2 $3" |ee
or return undef;
return $str;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.