[EMAIL PROTECTED] wrote:

> is there a safer way than chop to remove the end character in a registry 
> entry string?
> 
> 
> this section:
> 
> ---------------------------------------
>   # retrieve the registry value(s)
>   $regval = $Registry ->  {"$regpth/SeaNotify/"} -> 
> GetValue("SeaNotifyFiles");
> 
>   # 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;
> #    chop($val);
> 
>     if(-f $val){ push @watch, $val; }
> # || (-d $val)){ push @watch, $val; }
>     $regval=$3;
>   }
>   # get the final value
>   if(-f $regval){
>     # || (-d $regval)){
> #    chop($regval);
> #    chop($regval);

You can use chomp to safely remove a newline from the end (even if
there isn't one).  If you want to remove something else like say
whitespace from the end, you can use a RE:

        $regval =~ s/\s+$//;
using a character class:
        $regval =~ s/[\t ]+$//;

You can adjust the character class to whatever characters you want
to remove from the end.

>     push @watch, $regval; }
> 
>   # also get SeaNotifyAdditionalDirs
>   # retrieve the registry value(s)
>   $regval = $Registry ->  {"$regpth/SeaNotify/"}
>     -> GetValue("SeaNotifyAdditionalDirs");
> 
>   # debug call
>   if($verb>1){ &rep("Found in registry: $regval",$verb); }
> 
> 
>   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); }
>     }
>   }
> ---------------------------------------
> causes this output
> ---------------------------------------
> C:\Documents and Settings\jperlmutter.GRANITE_ENG\My 
> Documents\perl\test_scripts\SeaNotify>perl tsnt.pl -l trials.txt -iter 1 
> -verb
>  -verb -verb -verb -verb -verb -verb
> Sea Notify test started at Fri Aug 19 08:13:52 2005
> Using Windows version of SeaNotify....registry interaction started
> Setting Delimiter
> Setting registry path short to 
> HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/
> Found in registry: C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\testfile.txt C:\Documents and 
> Settings\jperlmutter.GRA
> NITE_ENG\Desktop\random2ndfiile.txt C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\My Documents E:\temp\tester.txt 
> C:\Documents
> and Settings\jperlmutter.GRANITE_ENG\My Documents\rndtstfile.txt
> Found in registry:
> Found file C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\testfile.txt |<-
> Found file C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\random2ndfiile.txt |<-
> Found file E:\temp\tester.txt |<-
> Found file C:\Documents and Settings\jperlmutter.GRANITE_ENG\My 
> Documents\rndtstfile.txt  |<-
> ---------------------------------------
> and un-commenting the chops causes
> ---------------------------------------
> C:\Documents and Settings\jperlmutter.GRANITE_ENG\My 
> Documents\perl\test_scripts\SeaNotify>perl tsnt.pl -l trials.txt -iter 1 
> -verb -verb -verb -verb -verb -verb -verb
> Sea Notify test started at Fri Aug 19 08:13:52 2005
> Using Windows version of SeaNotify....registry interaction started
> Setting Delimiter
> Setting registry path short to 
> HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/
> Found in registry: C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\testfile.txt C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\random2ndfiile.txt C:\Documents 
> and Settings\jperlmutter.GRANITE_ENG\My Documents E:\temp\tester.txt 
> C:\Documents and Settings\jperlmutter.GRANITE_ENG\My 
> Documents\rndtstfile.txt
> Found in registry:
> Found file C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\testfile.txt|<-
> Found file C:\Documents and 
> Settings\jperlmutter.GRANITE_ENG\Desktop\random2ndfiile.txt|<-
> Found file E:\temp\tester.txt|<-
> Found file C:\Documents and Settings\jperlmutter.GRANITE_ENG\My 
> Documents\rndtstfile.txt|<-
> ---------------------------------------
> i would like something safer but cannot find anything that works. i could 
> try a loop of chopping until i find a \w, however i can see that failing 
> since ~ and _  and - are all legal characters that could be in the name at 
> the end for various reasons.
> 
> i would like to thank those who have helped so far for their time and 
> patience
> 
> -josh
> 
> ps: if you owould like i will send the code for you to look at


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to