Posts Tagged ‘Perl’

Code formating script

Posted: 4th April 2013 by Babar Shafiq in Programming, System Administration, Tips
Tags: , , ,

#!/usr/bin/perl -w my $ifile = shift; my $blank = 0; my $indent = 2; open(IFILE, “$ifile”) or die “Cannot open $ifile\n”; while(my $line = ) { if($line =~ /^\s*else/i or $line =~ /^\s*end/i ) { #reduce indent before xxx $blank = $blank – 2; } if($blank > 0) { print ” ” x $blank; #print […]

Simple Construction of a RAW TCP/IP Packet

Posted: 11th August 2010 by Babar Shafiq in Programming
Tags: , , ,

#!/usr/local/bin/perl use Socket; $src_host = $ARGV[0]; # The source IP/Hostname $src_port = $ARGV[1]; # The Source Port $dst_host = $ARGV[2]; # The Destination IP/Hostname $dst_port = $ARGV[3]; # The Destination Port. if(!defined $src_host or !defined $src_port or !defined $dst_host or !defined $dst_port) { print “Usage: $0 <source host> <source port> <dest host> <dest port>\n”; exit; […]