in reply to Re: No grokkage on regex search/replace
in thread No grokkage on regex search/replace

Oh, and I also came up with this as another method. It uses the 'reverse' function (search for it here if you can't figure it out).
#!/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+/, reverse shift; print reverse($_) . " " for @string; }
And, quite embarisingly, I made the classic off by one mistake in my previous code. I *did* test it, ... but not closely enough, apparently! The first word never appears, because the for statement needs to read "<= 0" instead of "< 0" -- I guess that's what I get for going to C-like syntax, which I did since I figure you'd be more familiar with it. Pooh! :P