Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Find and replace from metatag using perl scrip
jyotirmani
Metadata :
<metadata>
Title
string
123.pdf
date
string
08-20-2010
Keywords
string
test
_filename
string
secured_site/doc/mani1.pdf
Summary
string
test 6756756776
workgroup
string
ARPrinciple
I want to find and replace value of _filename from these metadata. and tried with following but no work
my $search = "\n_filename\nstring\n$filename\n\n";
my $replace= "\n_filename\nstring\n$UpdateFilename\n\n";
$mt_data =~ s/$search/$replace/g;
Could you please help someone.
Find more posts tagged with
Comments
Rick Poulin
The issue is that your $search string is going to be interpreted as a regex, not as a literal string, so any special characters in $filename are going to throw off your search, if not crash your script. You might also want to be less specific with your match, by doing things like replacing \n with \s* in case the format of your XML doesn't come out quite like you'd expect.
Reghunath
use this format
$mt_data =~ s,$search,$replace,g;