Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- #
- # Extract code v0.1
- # Luca Francesca
- #
- use strict;
- # For colored output
- my $green="\e[32m";
- my $red="\e[31m";
- my $yellow="\e[33m";
- #Making sure of the parameters
- if ($ARGV[0] eq "") {
- print "Usage: $0 <file>\n";
- exit -1;
- }
- # Read input file...
- open INF, "< $ARGV[0]" or die "Error in program: $!";
- my @lines = <INF>;
- close INF;
- print "$yellow Loading data... \n\n";
- print "$yellow Begin report... \n \n";
- # .. and work with it
- foreach(@lines) {
- #chomp($_);
- my $cmd = "$_";
- $cmd =~
- /
- GSMC(SC|AS) # first, check the type
- /x;
- my $type = $1;
- if ($type eq "SC") {
- $cmd =~
- /
- GSMCSC
- \@ # delimiter
- GSM
- \@
- (\d+) # param
- \@
- (\d+) # opt
- \@
- (\d+) # data
- \@
- (\d+) # priority
- /x;
- my $param = $1;
- my $opt = $2;
- my $data = $3;
- my $priority = $4;
- print "$green Record type GSMCSC\n";
- printf "%-15s %s\n", 'Parameter', $param;
- printf "%-15s %s\n", 'Opt', $opt;
- printf "%-15s %s\n", 'Data', $data;
- printf "%-15s %s\n", 'Priority', $priority;
- print "## \n \n";
- } elsif ($type eq "AS") {
- $cmd =~
- /
- GSMCAS
- \@ # delimiter
- GSM
- \@
- (\d+) # service
- \@
- (\d+) # data
- \@
- (\d+) # priority
- /x;
- my $service = $1;
- my $data = $2;
- my $priority = $3;
- print "$green Record type GSMCAS\n";
- printf "%-15s %s\n", 'Service', $service;
- printf "%-15s %s\n", 'Data', $data;
- printf "%-15s %s\n", 'Priority', $priority;
- print "#-# \n \n";
- }
- }
- print "$red Report done!\n";
- print ""
- #@
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement