I am having problems with one of my regexp substitutions not matching the first line 
returned in a set, and I'm having trouble figuring out why.  I figure there's probably 
a hidden system character or something of the sort that is causing my regexp to fail.

Here's the scenario:

I'm forking off children from a parent, calling a remote script in each child.  The 
remote script sends its results to STDOUT, which I'm capturing via pipes.  The data 
from each child needs to be kept separate, so I'm prepending a tag to each line before 
printing to STDOUT ($servers[$c] spits out the server name):

        print "%%%%" . $servers[$c] . "%%%%" . $_;

Output from all children is captured into an array, and then split out into arrays 
based on each server name, removing the custom tag ($1 is the server name):

        while(<READER>) {
                if ($_ =~ s/^%%%%(\w+)%%%%//) {
                        push @{$1}, $_;
                }
        }

I then proceed to format my output and print results on a per-server basis.  The 
problem is that it appears that the first line returned to the parent array does not 
match my substitution regexp above, and the custom tag remains in place.  
Additionally, this only happens when more than one child process is spawned - with 
just one child, it works fine.  Reading what I just wrote, maybe it's the first line 
returned from children finishing 2nd or later.

If I change the substitution regexp to:

        if ($_ =~ s/^.*%%%%(\w+)%%%%//)

everything works perfectly.  The only thing I can think of is that some system 
character is hiding between the ^ and my custom tag, but I can't seem to figure out 
what it is.  Is there a way I can view system characters in a variable?

Probably not the best explanation, but hopefully that all makes sense.  Any input as 
to what the issue might be, or how I might idendify or fix it?

Thanks.

Jason

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to