in reply to Re: get string between two < tags > in .js file (xml)
in thread get string between two < tags > in .js file (xml)
thank you for your reply ... Yes that would be the proper way of doing it, you are absolutely right and I will look into it. For now , here is a quick and dirty solution that solved it for me:
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 '$A +RGV[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 fil +e '$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","S +GA"); while (<$file_in>) { ## write all changes to new file print $file_out $_; # if we find a match for any Symbols if ($_ =~ m%</Name><Symbol>([^<]+)%) { my $SYMBOL; my $MATCH; $SYMBOL = $1; # and the $SYMBOL matches the array @list for active market ma +kers if (grep {$_ eq $SYMBOL} @list) { # Print and add the line marketMakerOrganization: $SYMBOL to t +he $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; }
|
|---|