perltips
Hits : 11,098
Perl Tips
Search & Replace and Write
perl -p -i -e 's/Nov/Dec/g' file
Delete line from a file matching regular expression
Split an mbox into numbered individual message files
( from http://www.perlmonks.org/?node_id=152279 )
Convert a mbox to maildir
http://batleth.sapienti-sat.or[...]2md/mb2md-3.20.pl.gz[link1]
find_badblocks
http://www.orcaware.com/svn/re[...]nk/find_badblocks.pl[link2]
top
How to remove a specific mail from a mbox
top
Remove duplicate mails from mailbox
top
DSL PERL GENERATOR
#!/usr/bin/perl -w
my $class_a = "2";
foreach ( 84 .. 85) {
my $cl_b = $_;
foreach ( 0 .. 255 ) {
my $cl_c = $_;
foreach ( 0 .. 255 ) {
print "$class_a.$cl_b.$cl_c.$_\n";
}
}
}
top
Decode any subject encoding to utf8 with perl
top
#!/bin/sh
/usr/bin/perl -w \
-M'Encode' \
-M'Mail::MboxParser' \
-M'MIME::Base64 qw(decode_base64)' \
-e 'BEGIN {
$mb = Mail::MboxParser->new( $ARGV[0] );
}' \
-ne ' my $s = $mb->next_message->header->{subject} || "( empty subject )" ;
if ( $s =~ /^\=\?/ ) {
my @values = split ("\?", $s ) ;
$s = decode ( $values[1] , decode_base64( $values[3] ) ) ;
}
binmode STDOUT, ":utf8";
print $s . "\n" ;
' mbox
- [link1] http://batleth.sapienti-sat.org/projects/mb2md/mb2md-3.20.pl.gz
- [link2] http://www.orcaware.com/svn/repos/find_badblocks/trunk/find_badblocks.pl