Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The contents from {FILE} should be the filename.#!/usr/bin/perl print qq|<?xml version="1.0"?>|; print "\n"; while($_=<DATA>){ my $save; if (/^\{FILE\}/ .. /^\{NUMBER\}/) { unless (/^\{(FILE|NUMBER)\}/) { my $filename = $_; print "The filename is $filename\n"; } } open FH,">$filename.xml"; print FH '<?xml version="1.0"?>'; print FH "\n"; $_ =~ s/[\cA-\cZ]//g; if ( /^{(\w+)}/ ... /^\w+/ ) { my $tag = $1 if $1; if( ! /^{/ ){ print FH "<$tag>$_</$tag>\n"; # print FH "<\$tag\>$_\</$tag\>\n"; } } } close FH; __DATA__ ^B^B^B^B^B^B {FILE} sourcetag1 {NUMBER} 00000 {SOURCE} source1 {KEYWORD} {AUTHOR} author staff {FILE} sourcetag2 {NUMBER} 00001 {SOURCE} sourcenam {KEYWORD} {AUTHOR} author1 staff1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing to a file
by cdarke (Prior) on Aug 13, 2009 at 11:47 UTC | |
by Anonymous Monk on Aug 13, 2009 at 11:56 UTC | |
by Anonymous Monk on Aug 13, 2009 at 12:23 UTC | |
|
Re: Writing to a file
by alexm (Chaplain) on Aug 13, 2009 at 15:06 UTC | |
|
Re: Writing to a file
by Anonymous Monk on Aug 13, 2009 at 11:46 UTC | |
|
Re: Writing to a file
by alexm (Chaplain) on Aug 13, 2009 at 16:09 UTC | |
|
Re: Writing to a file
by ig (Vicar) on Aug 13, 2009 at 18:33 UTC | |
by Anonymous Monk on Aug 14, 2009 at 05:06 UTC | |
by Anonymous Monk on Aug 14, 2009 at 06:26 UTC | |
by ig (Vicar) on Aug 15, 2009 at 06:22 UTC |