09-09-2008
you can use perl :xml parser to parse this file
Sample perl code.
#!/usr/bin/perl
use XML::Simple;
use Data:
umper;
my $config = XMLin('new.xml');
print Dumper($config);
i/p:
<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
<LogItems>
<log logid="83efeae5190809080000080410">
<category>Upstream.TEL</category>
<operation>MAKE</operation>
<target>mms</target>
<user>purple</user>
<starttime>20080908000008.985701</starttime>
<stoptime>20080908000009.293774</stoptime>
<status>OKAY</status>
</log>
</LogItems>
Output:
$VAR1 = {
'log' => {
'status' => 'OKAY',
'stoptime' => '20080908000009.293774',
'target' => 'mms',
'starttime' => '20080908000008.985701',
'user' => 'purple',
'category' => 'Upstream.TEL',
'operation' => 'MAKE',
'logid' => '83efeae5190809080000080410'
}
};
your perl script will return hashmap some thing like above.You just need to make key as column name and value value for the coulum and insert using perl DBI module
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
how the hell do you put wine in because i don't know i have mandrake please tell how to put in (1 Reply)
Discussion started by: amicrawler
1 Replies
2. Shell Programming and Scripting
Hello,
Sir's,
I would like to ask for help. This is my problem, i am working for a mbs for aix,hp-ux and solaris. And i am making a script that will automatically implement the said mbs.
For example it will automatically change the permmisions of /usr/bin, /etc/passwd and so on. . . .... (7 Replies)
Discussion started by: invinzin21
7 Replies
3. UNIX for Dummies Questions & Answers
Hi Guys,
I'm a new to the UNIX. Let say I have a 1 simple script to stop and start vnc service. I want to use that script for support because my network connection to my client side is not stable and every time I have to use a long command to restart vnc.
Where should I put that script?... (3 Replies)
Discussion started by: akuslive
3 Replies
4. Shell Programming and Scripting
Hi guys
Iam looking for a small help.I wrote a script. in that iam trying to take the default value ,when we press enter.this part iam struggling can somebody help please
Example:
do u need this server:
For this one if we press enter it has to take server name as... (4 Replies)
Discussion started by: coolkid
4 Replies
5. Shell Programming and Scripting
Simple question ..What is the easiest way to list my output in a column
like so
dddd dddd dddd dddd
output
dddd
dddd
dddd
dddd
Thanks (3 Replies)
Discussion started by: bombcan
3 Replies
6. UNIX for Dummies Questions & Answers
original content:
0000000000 TIAA-CREF
0000000000 CAREMARK
all said and done, i'd like to look like this:
$00,000,000.00 TIAA-CREF
$00,000,000.00 CAREMARK (2 Replies)
Discussion started by: tjmannonline
2 Replies
7. UNIX for Advanced & Expert Users
How to get to know, where are the current logs been updated in the system
or most recently updated logs in the system.
consider /usr/abc/def
and inside the def folder , i have many subfolders
The command out put ,need to give me the log files and there location , which are... (7 Replies)
Discussion started by: sidharthmellam
7 Replies
8. Solaris
Hello every one ,
I am just trying to sort df -h out in a particular order to differentiate SAN disks and local disks .. does any body have any script or any useful command ??
thanks in advance .. (8 Replies)
Discussion started by: new2uniks
8 Replies
9. Shell Programming and Scripting
Hi guys,
I want to write script so that i can put semicolon after every numeric
e.g
input would be like that
50060E80058F49A4
Output should be
50:06:0E:80:05:8F:49:A4
Please help
Thanks & Regards
Nirjhar (11 Replies)
Discussion started by: nirjhar17
11 Replies
10. Shell Programming and Scripting
Hi,
ServerA (SFTP server)
ServerB (SFTP client)
ServerB:> sftp user@ServerA
ServerB:> put sample.txt
ServerB:> get sample2.txt
My question is that which machine will encrypt the sample.txt and sample2.txt files.
Thanks (8 Replies)
Discussion started by: Arpit Narula
8 Replies
LEARN ABOUT MOJAVE
data::dumper::concise::sugar
Data::Dumper::Concise::Sugar(3) User Contributed Perl Documentation Data::Dumper::Concise::Sugar(3)
NAME
Data::Dumper::Concise::Sugar - return Dwarn @return_value
SYNOPSIS
use Data::Dumper::Concise::Sugar;
return Dwarn some_call(...)
is equivalent to:
use Data::Dumper::Concise;
if (wantarray) {
my @return = some_call(...);
warn Dumper(@return);
return @return;
} else {
my $return = some_call(...);
warn Dumper($return);
return $return;
}
but shorter. If you need to force scalar context on the value,
use Data::Dumper::Concise::Sugar;
return DwarnS some_call(...)
is equivalent to:
use Data::Dumper::Concise;
my $return = some_call(...);
warn Dumper($return);
return $return;
If you need to force list context on the value,
use Data::Dumper::Concise::Sugar;
return DwarnL some_call(...)
is equivalent to:
use Data::Dumper::Concise;
my @return = some_call(...);
warn Dumper(@return);
return @return;
If you want to label your output, try DwarnN
use Data::Dumper::Concise::Sugar;
return DwarnN $foo
is equivalent to:
use Data::Dumper::Concise;
my @return = some_call(...);
warn '$foo => ' . Dumper(@return);
return @return;
If you want to output a reference returned by a method easily, try $Dwarn
$foo->bar->{baz}->$Dwarn
is equivalent to:
my $return = $foo->bar->{baz};
warn Dumper($return);
return $return;
If you want to format the output of your data structures, try DwarnF
my ($a, $c) = DwarnF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy;
is equivalent to:
my @return = ($awesome, $cheesy);
warn DumperF { "awesome: $_[0] not awesome: $_[1]" } $awesome, $cheesy;
return @return;
If you want to immediately die after outputting the data structure, every Dwarn subroutine has a paired Ddie version, so just replace the
warn with die. For example:
DdieL 'foo', { bar => 'baz' };
DESCRIPTION
use Data::Dumper::Concise::Sugar;
will import Dwarn, $Dwarn, DwarnL, DwarnN, and DwarnS into your namespace. Using Exporter, so see its docs for ways to make it do something
else.
Dwarn
sub Dwarn { return DwarnL(@_) if wantarray; DwarnS($_[0]) }
$Dwarn
$Dwarn = &Dwarn
$DwarnN
$DwarnN = &DwarnN
DwarnL
sub Dwarn { warn Data::Dumper::Concise::Dumper @_; @_ }
DwarnS
sub DwarnS ($) { warn Data::Dumper::Concise::Dumper $_[0]; $_[0] }
DwarnN
sub DwarnN { warn '$argname => ' . Data::Dumper::Concise::Dumper $_[0]; $_[0] }
Note: this requires Devel::ArgNames to be installed.
DwarnF
sub DwarnF (&@) { my $c = shift; warn &Data::Dumper::Concise::DumperF($c, @_); @_ }
TIPS AND TRICKS
global usage
Instead of always just doing:
use Data::Dumper::Concise::Sugar;
Dwarn ...
We tend to do:
perl -MData::Dumper::Concise::Sugar foo.pl
(and then in the perl code:)
::Dwarn ...
That way, if you leave them in and run without the "use Data::Dumper::Concise::Sugar" the program will fail to compile and you are less
likely to check it in by accident. Furthmore it allows that much less friction to add debug messages.
method chaining
One trick which is useful when doing method chaining is the following:
my $foo = Bar->new;
$foo->bar->baz->Data::Dumper::Concise::Sugar::DwarnS->biff;
which is the same as:
my $foo = Bar->new;
(DwarnS $foo->bar->baz)->biff;
SEE ALSO
You probably want Devel::Dwarn, it's the shorter name for this module.
perl v5.18.2 2013-12-31 Data::Dumper::Concise::Sugar(3)