[Chicago-talk] Sharing my pain

Andy_Bach at wiwb.uscourts.gov Andy_Bach at wiwb.uscourts.gov
Fri Oct 13 13:33:05 PDT 2006

> it was clear what was going on.

Okay, not to me but .... -
   $sproketAccum =~ s![\n\s\t]!!g;
     @tmp = split(/\+;/, $sproketAccum);
     foreach (@tmp) {
         unless (m!foobar!) { s!^foo!!g }

Um, delete all white space, split on '+;' and then, unless the word is 
"foobar" remove the prefix 'foo' (w/  the '^' anchor, the 'g' is 
unneeded)?   Note that's using the $_ alias, so it alters @tmp.
    my $sp;
     foreach $sp (@tmp) {
         $sp =~ s!\\!!g;
         $sp =~ s!\n!!g;

         if ($sprokets) { $sprokets .= ' ' }
         $sprokets .= $sp;

okay, remove backslashes, '\n's (again) and append w/ a blank - so now 
we've got non-foo, non-whitespace 'sprokets' in a whitespace delim string. 

my $tmp = findSprokets();
@sprokets = reverse sort( split(/ /, $tmp) );

Reverse sort the result.  Weird data.  One guess for 
         $sp =~ s!\\!!g;
         $sp =~ s!\n!!g;

is that some sql results will backslash embedded delims (like a pipe)  or 
\n in the data, so its harder to just split it up into records and then 
fields on naive split/matches using '\n' and the delim char.

Something like:
$sproketAccum =~ s/[\w\\]+//g;  # remove whitespace/back slashes
$sproketAccum =~ s/\bfoo(?!bar)//g;  # remove non-foobar 'foo'
$sproketAccum =~ s/\+;/ /g;        # change separators



Andy Bach, Sys. Mangler
Internet: andy_bach at wiwb.uscourts.gov 
VOICE: (608) 261-5738  FAX 264-5932

"The whole point of reserving these namespaces is not to prevent users 
misusing them, but to ensure that when we eventually get around to using a 

particular block name, and those same users start screaming about it, we 
mournfully point to the passage in the original spec and silently shake 
heads. ;-)"

Damian Conway, P6 list

More information about the Chicago-talk mailing list