Skip to content

Instantly share code, notes, and snippets.

View maxgoren's full-sized avatar

Max Goren maxgoren

View GitHub Profile
@ishu3101
ishu3101 / loop_string.pl
Created June 7, 2016 00:53
3 ways to loop through each character in a string in Perl
# 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) {