in reply to convert to XML

SHORT ANSWER: Search for an appropriate module on CPAN (or PPM if using Windows and ActiveState).

STANDARD ANSWER: What have you tried? Show us the code and tell us how it's failing.

FOOD-FOR-THOUGHT ANSWER: Your question can be answered in a simple minded way, assuming what you litterally asked is really what you want, with appropriate Regular Expressions or in half a dozen other ways. But what do you want to happen if your source looks like this?

[DATA] data1 [ENTRY] entry here [STORY] story details [DATA] [ENTRY] another entry here [STORY] another story

You'll get better help here if your question is precise and well-bounded...and when you show your efforts.

Replies are listed 'Best First'.
Re^2: convert to XML
by Anonymous Monk on Aug 12, 2009 at 07:01 UTC
    #!/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
      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>