#!/usr/bin/env perlusestrict;usewarnings;# Perl入学式 2018 第2回 練習問題# https://github.com/perl-entrance-org/workshop-2018/blob/master/2nd/slide.md# 練習問題(split.pl)# "There's more than one way to do it." という文字列を作り、split関数で" "(半角スペース)ごとに分割して配列 @array に格納し、出力してください。# 好きな文字列を作り、好きな要素で区切って配列 @array2 に格納し、出力してください。# 日本語や数字を混ぜてもよいでしょう。# わからないところがあれば、サポーターに聞いてみましょう!print"Question1\n";my$str="There's more than one way to do it.";my@array=split/ /,$str;formy$element(@array){print"$element\n"}print"----------\n";print"Question2\n";useutf8;# スクリプト中に日本語を書く場合は宣言するmy$pangram="The-quick-brown-fox-jumps-over-the-lazy-dog";my@array2=split/-/,$pangram;formy$element(@array2){print$element,"\n"}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.