Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: get string between two < tags > in .js file (xml)

by jethro (Monsignor)
on Jul 03, 2012 at 11:20 UTC ( #979650=note: print w/replies, xml ) Need Help??


in reply to get string between two < tags > in .js file (xml)

You need m%%, the regular expression search operator instead of s%%%, the regular expression substitute operator. The code below should give you a start, more you can find out in the perl documentation perlre

my ($result)= m%</Name><Symbol>([^<]*)</Symbol>%;

Replies are listed 'Best First'.
Re^2: get string between two < tags > in .js file (xml)
by kamchez (Initiate) on Jul 03, 2012 at 12:19 UTC

    great ! thanks a lot this is what I've got :

    use strict; use warnings; use File::Basename; use Text::ParseWords; if ($#ARGV == 0) { open my $file, "<", $ARGV[0] or die "Couldn't open file '$ARGV +[0]': $! \nDid you specify a valid file?"; while (<$file>) { if ($_ =~ m%</Name><Symbol>([^<]+)%) { my $SYMBOL; $SYMBOL = $1; print "NEWCOLUMN:\"$SYMBOL\"\n"; } } }

    Next part ... print all matches and insert them into each field

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979650]
help
Chatterbox?
[shmem]: push returns the number of elements in @foo, the assignment returns all the elements in the (renewed) @foo
[Lady_Aleena]: Sanity check please? push @line, ref($list_addition ) eq 'ARRAY' ? @$list_addition : $list_addiction; # so I don't have the change existing uses of the sub.
[shmem]: $list_addiction should be $list_addition
Discipulus loose the tozzetto party!
[shmem]: .oO( addition of cookies for addiction to cookies )
[Lady_Aleena]: Other than my typos shmem. 8)
[shmem]: otherwise fine
[Discipulus]: tozzetti & vinsanto
[Lady_Aleena]: The whole line is push @line, ref($list_addition ) ? @$list_addition : $list_addition if $list_addition;
[Lady_Aleena]: And I forgot to do the array check, I'm such a doofus today.

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-04-27 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (503 votes). Check out past polls.