Skip to content

Instantly share code, notes, and snippets.

@JFFail
Created July 1, 2015 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JFFail/be688d53384a5a9dbc3a to your computer and use it in GitHub Desktop.
Save JFFail/be688d53384a5a9dbc3a to your computer and use it in GitHub Desktop.
Reddit Snake Challenge in Perl
#!/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