Created
June 7, 2016 00:53
-
-
Save ishu3101/00c296fcb04bb10f4c2d5fbff894b06a to your computer and use it in GitHub Desktop.
Revisions
-
ishu3101 created this gist
Jun 7, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # 3 ways to loop through each character in a string $text = "hello world"; for $i (0..length($text)-1){ $char = substr($text, $i, 1); print "Index: $i, Text: $char \n"; } foreach $char (split //, $text) { print "$char\n"; } foreach $char (split('', $text)) { print "$char\n"; }