-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, August 19, 2005 10:07 AM
To: [email protected]
Subject: Re: trouble cleaning a registry pull (solution!)
Incase people are interested....
chomp wasn't working since it removes new-lines (was my first thought)
chop worked but i couldn't verify i wasn't taking off too much
someone here has a byte dumping program in hex. he asked that i log the
ending character. after doing so he ran it through the program it turns
out the registry separates values using the NULL character.
the problem I found with this is that it ONLY works in a m// or s///
context when it is the LONE item in the part to be matched (that or the
s/// context will work if i spend more time with it)
the solution I found was to change the chunk of code sent last time to:
# retrieve the registry value(s) of the files to watch
# also get SeaNotifyAdditionalDirs
$regval = $Registry -> {"$regpth/SeaNotify/"} ->
GetValue("SeaNotifyFiles");
$regval .= $Registry -> {"$regpth/SeaNotify/"}
-> GetValue("SeaNotifyAdditionalDirs");
# debug call
if($verb>1){ &rep("Found in registry: $regval",$verb); }
while($regval =~ m/(\w:)(.+?)(\w:.*)/){
# convert to one value per line in 2 steps
# 1: put the path together
# 2: remove first piece
my $val=$1.$2;
# remove the null(s) on the end
while(my $q = chop($val)){
unless($q =~ m/\0/){
$val.=$q;
last;
}
}
# add ONLY files and directories (sym links et al will be ignored
for
now)
if(-f $val){ push @watch, $val; }
# || (-d $val)){ push @watch, $val; }
$regval=$3;
}
# get the final value
if(-f $regval){
# || (-d $regval)){
# remove the null(s) on the end
while(my $q = chop($regval)){
unless($q =~ m/\0/){
$regval.=$q;
last;
}
}
push @watch, $regval; }
if($verb>1){
foreach my $val (@watch){
if(-f $val){
&rep("Found file $val|<-",$verb); }
elsif(-d $val){ &rep("Found directory $val|<-",$verb); }
else{ &rep("How did this get in here? val is: $val|<-", $verb); }
}
}
i dont know how many will find this usable news, but i figure it cannot
hurt to inform the list the solution that I found
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Chop returns the character chopped.
$a = "abc";
while (length($a)) {
$b = chop $a;
print "b=$b\n";
}
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs