Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Last active December 21, 2015 05:18
Show Gist options
  • Save mamemomonga/6255794 to your computer and use it in GitHub Desktop.
Save mamemomonga/6255794 to your computer and use it in GitHub Desktop.
Windows7 x64 バッチファイルからcygwin64 PerlでHello World!
@echo off
rem ---------------------------------------------------------------------------
rem Windows7 x64 バッチファイルからcygwin64 PerlでHello World!
rem Shift_JIS(cp932)で保存すること
rem ---------------------------------------------------------------------------
set OPATH=%PATH%
set PATH=C:\cygwin64\bin;%PATH%
for /F "usebackq" %%s in (`cygpath -u %0`) do SET UPATH=%%s
perl -x -S %UPATH% %*
goto endofperl
@rem ';
#!perl
use strict;
use warnings;
use English;
# コードはShiftJIS, 入出力はUTF8
use encoding 'Shift_JIS', STDOUT=>'utf8', STDERR=>'utf8', STDIN=>'utf8';
print "Hello World!\n";
print "こんにちは\n";
foreach(qw( EXECUTABLE_NAME PERL_VERSION OSNAME )) {
print "$_: ".(eval "\$$_")."\n";
}
for(my $i=0;$i<=$#ARGV;$i++) {
print "ARGV[$i]: $ARGV[$i]\n";
}
__END__
:endofperl
set PATH=%OPATH%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment