Tseng, Joe [CONTRACTOR] wrote:
> I have mostly figured out how to add files to a zip archive using 
> Archive::Zip::addTreeMatching but I'm getting hung up on what seems to 
> be a subtle point.  I have a line that adds files to an archive 
> directory if they're text or INI files:
>  
> $objZip->addTreeMatching( $workingdir, 'config', "\.(ini|txt)");
>  
> But the following line doesn't work for adding what is remaining to 
> another archive directory :
>  
> $objZip->addTreeMatching( $workingdir, 'results', "!\.(ini|txt)");
> I'm sure I'm overlooking something minor; assistance is always greatly 
> appreciated!

Just adding a "!" onto the front of a regex doesn't negate it. It's not always 
easy to write negative regexes, but addTree and addTreeMatching support an 
optional variable at the end to do decision-making.

So you can actually use a !, but what you want to do is negate the result of a 
regex, like so:


$objZip->addTree( $workingdir, 'results', sub { !/\.(ini|txt)$/ } );


There, the regex matches *.ini and *.txt, and then the ! (note that it's 
outside of the regex) negates the match.

Also, I added a "$", because regexes are always faster when you give it a 
position to start (or end) from.


-- 
Mike Gillis
Languages Development            [EMAIL PROTECTED]
ActiveState Software             http://www.activestate.com/languages
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to