#!/usr/bin/perl use strict; use warnings; use diagnostics; PrintInRevWordOrder ("The tall brown cat walked down the alley-way."); sub PrintInRevWordOrder { my @string = split /\s+/, shift; # the problem says this is to be passed as an argument # but you are using global variable. bad practice in general. # C-stlye for loop ... usually I use more perl-esque structures, # but hey -- TMTOWTDI (there's more than one way to do it!) for (my $i = $#string; $i > 0; $i--) { print $string[$i], " "; } }