Public Scratchpad | Download, Select Code To D/L |
Next up: More new prefix tags...
Current task list:
Also, /me wonders what people think of these as new link tags:
10 Jul 2002: The lastest Consideration rant has been posted, primarily because the issue came up in the ChatterBox.
09 Jul 2002: The Tutorials update has been checked in. Please go there for the latest.
13 Nov 2001: The documentation for New Prefix tags has been checked in. For more information, please see What shortcuts can I use for linking to other information?
Earlier: I'm no longer confused about regex parsing of white space, puncuation, and words. See below.
#!/usr/bin/perl -w use strict; my $sentence = "I am Sam. Sam I am."; my @words = ( $sentence =~ /(\w+|\s+|[[:punct:]]+)/g ); my $element; my $count = 0; foreach $element (grep { !/\s/ } @words) { print "Element ", sprintf( "%02d", $count++ ), ": $element\n"; }
works as desired. It yields:
(thanks, tye and zaxo)Element 00: I Element 01: am Element 02: Sam Element 03: . Element 04: Sam Element 05: I Element 06: am Element 07: .