#!/usr/bin/perl # baled #Before and After Line EDitor #This script is used to do edit of file with before and after insert # Default is before line # option -a is after # # usefull to make xml / html listing of commands for instance # ls -1 | baled.pl '' -a '' # my $flag="Pre"; LOOP: while ( $n=shift ) { if ( !$n ) { print "Do I get here at all ? \n"; last LOOP ; } if ( $n eq "-a" ) { $flag = "Post"; next ; } if ( $n eq "-r" ) { $rflag = "YES"; next ; } if ( $flag eq "Pre" ) { $prefix .=" ".$n; }else { $postfix .=" ".$n; } } #print "trace print prefix is $prefix\n"; while ( <>) { chomp; if ( ! $rflag ) { print "$prefix $_ $postfix \n"; } else { print "$prefix $_ $postfix $_ \n"; } }