Top > CGI(perl) > split


split( /区切り文字/ , 分割したい対象 )

#!/usr/bin/perl

$before = "acha , porute , piipo";
@after = split( /,/ , $before );

print "Content-type:text/html\n\n";

print "変更前 = $before<br>";
print "変更後 = @after<br>";

●出力結果
変更前 = acha , porute , piipo
変更後 = acha porute piipo

「,(カンマ)」区切りの1文字を、「,」で区切って3つの文字に分けた例です。
「=」「@」「.」などでも区切れます。
HTMLのログ解析、メールのヘッダー解析など、解析でよく使用させて頂きました。



Copyright © 2015 AchaPorutePiipo All Rights Reserved.