in reply to Re: convert to XML
in thread convert to XML

#!/usr/bin/perl print qq|<?xml version="1.0"?>|; print "\n"; while($_ = <DATA>){ if (/^\[\w+\]/ .. /^\[\w+\]/) { $save = $_; $save =~ s/\[/</g; $save =~ s/\]/>/g; print $save; } }
__DATA__ [DATA] data1 [ENTRY] entry here [STORY] story details [DATA] [ENTRY] another entry here [STORY] another story
I have tried sometime like this. But I am not able to store the values in a variable

Replies are listed 'Best First'.
Re^3: convert to XML
by rovf (Priest) on Aug 12, 2009 at 08:58 UTC
    I am not able to store the values in a variable

    See perlre, in particular how to use $1 and its cousins, to extract matching parts from a regexp.

    -- 
    Ronald Fischer <ynnor@mm.st>