Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Perl

Journal Journal: Perl script for finding patterns

Ok, I reallt needed a bash command that could list the index of every occurance of a pattern in a file. I found this one-liner before:

perl -0777 -ne 'print index $_, "\x5d\x00\x00\x80\x00\x00"' afile.bin

This locates the first LZMA header in a file, but I need to find ALL headers, not just the first... Ok, I'm no perl specialist, but I came up with this:

#!/usr/bin/perl
use strict;
use warnings;

Slashdot Top Deals

"You don't go out and kick a mad dog. If you have a mad dog with rabies, you take a gun and shoot him." -- Pat Robertson, TV Evangelist, about Muammar Kadhafy

Working...