Re: Making thunderbird attachments searchable

[email protected] ("John W. Krahn") Mon, 04 Jan 2010 15:55:48 -0800
Newsgroups perl.scripts
Message-ID <[email protected]>
qoo eiji wrote:
> Okay, I wrote this script because I've been trying to find a way to
> search my attachments in Thunderbird.
> I figured I'm not the only one but it's a quick hack and not a module
> so I don't know  where to post it, so here it is:
> 
> You can do anything you want with it. It's not very polished because I
> thought I'd give myself more time before polishing it up and put
> options into it. Right now it's just a pipe - cos I can't guarantee
> that it won't kill your mbox!
> 
> After running your mbox through this code you should be able to search
> your attachment names under the tage "X-META-01".
> 
> [ SNIP ]
> 
> sub getSubValues {
>         my $value = shift @_;
>         my %subvalues = ();
>         my $initial;
>         my $oldvalue = "";
> 
>         ($initial, $value) = $value =~ m/^([^;\n\r]*)[;[:space:]\n\r]*
> (.*)/sg;

The [:space:] character class already includes the characters \n and \r.

>         $subvalues{""} = $initial;
>         while ($value) {
>                 ($key, $value) = $value =~ /([^=]*)=(.*)/s;
>                 if ($value =~ /^"/) {
>                         ($keyvalue, $value) = $value =~ /"([^"]
> *)"[[:space:]\n\r]*(.*)/s;
>                 } else {
>                         ($keyvalue, $value) = $value =~ /\s*([^;
> [:space:]]*)[;[:space:]\n\r]*(.*)/s;
>                 }
>                 $subvalues{$key} = $keyvalue;
>                 if ($oldvalue eq $value) {
>                         break;

'break' is not valid in this context, perhaps you meant 'last' instead.

>                 }
>                 $oldvalue = $value;
>         }
>         return %subvalues;
> }



John
-- 
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway