use strict; use warnings; use File::Basename; use Text::ParseWords; if ($#ARGV == 0) { open my $file_in, "<", $ARGV[0] or die "Couldn't open file '$ARGV[0]': $! \nDid you specify a valid file?"; # open up a new file to write the changes made to open my $file_out, ">", "$ARGV[0].new" or die "Can't write new file '$ARGV[0].new' : $! \nDo you have write permissions?"; # these are our currently active market makers my @list=("BNP","CBK","CIT","NDS","OHD","OHM","RBN","RBS","SEK","SGA"); while (<$file_in>) { ## write all changes to new file print $file_out $_; # if we find a match for any Symbols if ($_ =~ m%([^<]+)%) { my $SYMBOL; my $MATCH; $SYMBOL = $1; # and the $SYMBOL matches the array @list for active market makers if (grep {$_ eq $SYMBOL} @list) { # Print and add the line marketMakerOrganization: $SYMBOL to the $file_out print $file_out "\t\tmarketMakerOrganization:\"$SYMBOL\",\n"; } } } } else { print "You need to specify an input file \n"; print "\n"; print "They are usually located here : \n"; print "/PATH/orderbooks-xx-hostname-yy.x.xxx.xx.js"; print "\n"; print "Usage : ".basename($0)." difffile.txt \n"; print "\n"; exit; }