Created
July 1, 2015 01:04
-
-
Save JFFail/be688d53384a5a9dbc3a to your computer and use it in GitHub Desktop.
Reddit Snake Challenge in Perl
This file contains 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 characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
my $base_word = "SHENANIGANS SALTY YOUNGSTER ROUND DOUBLET TERABYTE ESSENCE"; | |
my @word_array = split(/\s+/, $base_word); | |
my $counter = 0; | |
my $spaces = ""; | |
foreach my $word(@word_array) { | |
if($counter % 2 == 0) | |
{ | |
print $spaces; | |
print "$word\n"; | |
$spaces = $spaces . " " x (length($word)-1); | |
} | |
else | |
{ | |
my @char_array = split("", $word); | |
foreach my $letter(@char_array) { | |
print $spaces; | |
print "$letter\n"; | |
} | |
} | |
$counter++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment