From: P. J. McDermott Date: Sun, 22 Sep 2013 19:10:54 +0000 (-0400) Subject: Support "-" file names (STDIN and STDOUT). X-Git-Tag: ssic/1.0.0~34 X-Git-Url: https://jxself.org/git/?p=ssic.git;a=commitdiff_plain;h=e09c119b75cfd9f6e62f50083edf4a812be66134;ds=sidebyside Support "-" file names (STDIN and STDOUT). --- diff --git a/src/ssic.pl b/src/ssic.pl index db7a39f..e5fa2be 100644 --- a/src/ssic.pl +++ b/src/ssic.pl @@ -112,11 +112,19 @@ sub compile error(4, "Input and output files are equal\n"); } - if (not open($input_fh, "<", $input)) { - error(4, "%s: %s\n", $input, $!); + if ($input eq "-") { + $input_fh = *STDIN; + } else { + if (not open($input_fh, "<", $input)) { + error(4, "%s: %s\n", $input, $!); + } } - if (not open($output_fh, ">", $output)) { - error(4, "%s: %s\n", $output, $!); + if ($output eq "-") { + $output_fh = *STDOUT; + } else { + if (not open($output_fh, ">", $output)) { + error(4, "%s: %s\n", $output, $!); + } } %ENV = (