Skip to content

Instantly share code, notes, and snippets.

@joet3ch
Created September 17, 2010 03:40
Show Gist options
  • Save joet3ch/583632 to your computer and use it in GitHub Desktop.
Save joet3ch/583632 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
#Parser
use warnings;
use strict;
my $output_filename='output_parser.log'; #file where you want the output
die "\n\t$output_filename file already exists!\n\n" if (-e $output_filename);
sub output {
open OUTPUTFILE, ">> $output_filename";
print OUTPUTFILE "$_\n";
}
my @input_file=<>;
chomp @input_file;
print "\n\n\tParsing file now ...\n";
my $counter=0;
foreach (@input_file) {
$counter++;
print "\t\tLine #$counter\n";
my $line=$_;
if (/CABLE/i) { # input the regex to match here!
&output($1);
}
}
print "\n\nFinished! (Check the file $output_filename for the results)\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment