in reply to Re: No grokkage on regex search/replace
in thread No grokkage on regex search/replace
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#!/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; }
|
|---|