Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hiratara/69443 to your computer and use it in GitHub Desktop.
Save hiratara/69443 to your computer and use it in GitHub Desktop.
#/usr/bin/perl
# perlのパスが違う時はここを書き換える
# 2008/12/05 コメントを新しく記述 by 高橋
# 2009/02/13 全体的にコメントが足りないので追加 by 高橋
use strict; # おまじない(どこかのサイトで見た気がします)
use warnings; # おまじない(どこかのサイトで見た気がします)
# @hello配列をmyで宣言する
my @hello;
# 配列に、Hとeとlとlとoと空白文字( )とWとrとoとlとdと改行文字(\n)を代入
push @hello, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', "\n";
# スカラ変数($hello)をmyで宣言する
# 2001年12月31日 本間 追加(高橋氏の指示による)
# 指示してない by 高橋
my $hello;
# # 配列@helloを一つずつ順番に回して処理をする
# foreach (@hello){
# # スカラ変数$helloに、1文字ずつ足して行く
# # スカラ変数$helloは一文字ずつ増えて行く 2008/12/31 by 高橋
# # $_はPerlの特殊変数で、foreachの値が代入される 2009/02/13 by 高橋
# $hello .= $_;
# }
# 2008/01/02 join関数を使った方がいいらしいので修正
# 配列に入っているHとeとlとlとoと空白文字( )とWとrとoとlとdと改行文字(\n)を
# 空文字列('')で合体させて、$hello(スカラ変数)に代入する
$hello = join '', @hello; # すごくきれいになったと思います by 高橋
# スカラ変数 $helloの値を、標準出力に書き出す(print関数を利用)
# 【print関数のperldocより利用法をコピペ】 by 高橋
# print FILEHANDLE LIST
# print LIST
# print
# Prints a string or a list of strings. Returns true if successful. FILEHANDLE may be a scalar variable name, in which case the variable contains the name of or a reference to the filehandle, thus introducing one level of indirection. (NOTE: If FILEHANDLE is a variable and the next token is a term, it may be misinterpreted as an operator unless you interpose a + or put parentheses around the arguments.) If FILEHANDLE is omitted, prints by default to standard output (or to the last selected output channel--see "select"). If LIST is also omitted, prints $_ to the currently selected output channel. To set the default output channel to something other than STDOUT use the select operation. The current value of $, (if any) is printed between each LIST item. The current value of $\ (if any) is printed after the entire LIST has been printed. Because print takes a LIST, anything in the LIST is evaluated in list context, and any subroutine that you call will have one or more of its expressions evaluated in list context. Also be careful not to follow the print keyword with a left parenthesis unless you want the corresponding right parenthesis to terminate the arguments to the print--interpose a +
# print "$hello";
# 2008年11月03日 改行が抜けていたので追加した
# print "$hello\n";
# 2009/12/03 改行が二重で出力される不具合を修正 by 高橋
print "$hello";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment