in reply to Re: removing perldata , hashref from XML file (updated) in thread removing perldata , hashref from XML file
Many Thanks for your quick response.
My exact problem is about introducing each tag in perl code, i mean:
my $data = { employee => [ {
"************" => "M", age => { dob => "10-02-1917" },
department => { departmentname => "Operations",
title => "Manager" },
location => { town => { county => "East Ay1",
name => "Auchinleck" } },
name => { forename => "John", surname => "Doe" },
My xml file is more than 2000 lines with different tags and also it is encoded, I decode it and make it as XML file, introducing each tag in my perl code is not possible.
Re^3: removing perldata , hashref from XML file
by choroba (Cardinal) on May 13, 2020 at 11:01 UTC
|
You don't have to introduce the structure. Just use the return value of $tap3->structure.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] [select] |
|
!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;
use XML::Dumper;
use TAP3::Tap3edit;
$Data::Dumper::Indent=1;
$Data::Dumper::Useqq=1;
my $dump = new XML::Dumper;
use File::Basename;
my $perl='';
my $xml='';
my $tap3 = TAP3::Tap3edit->new();
foreach my $file(glob 'X*')
{
my $files= basename($file);
my $filename=$files.".xml\n";
print $filename;
$tap3->decode($files) || die $tap3->error;
$perl = $tap3->structure;
$dump->pl2xml($perl, $filename);
}
| [reply] [d/l] |
|
c:\@Work\Perl\monks>perl -wMstrict -e
"print map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],
+[{}],[sub{}^*ARGV,3]
"
JApH,
JApH stands for Just Another Perl Hacker. :) Please consider the advice given in the body of choroba's reply.
Give a man a fish: <%-{-{-{-<
| [reply] [d/l] [select] |
|
|
You've just re-posted the code from your first node, it looks like you haven't even tried to incorporate the suggested code. You'll tend to get better responses if you show your efforts. Also, see this: when you edit a node, make sure to mark your updates, so that replies aren't confusing.
Anyway, as choroba and I said, the code I showed is a replacement for XML::Dumper, and my example $data can be removed and your $perl variable can be used instead.
| [reply] [d/l] [select] |
|
Re^3: removing perldata , hashref from XML file
by haukex (Archbishop) on May 13, 2020 at 11:03 UTC
|
My exact problem is about introducing each tag in perl code ... introducing each tag in my perl code is not possible.
Sorry, I don't understand what you mean here. Please see Short, Self-Contained, Correct Example and I know what I mean. Why don't you?. As I said, you can adapt the code I've posted (which I just updated) however you need, but you also haven't shown your expected output.
Update: Ah, I see choroba may have interpreted your issue better than I have. Yes, my $data is meant to be the same thing as the $perl variable from your previous node.
| [reply] [d/l] [select] |
|
| [reply] |
|
|