XML Simple + parsing inner loop elements + help

2015-12-07 Thread perl kamal
Hi,

I am trying to parse the inner loop elements of the attached input xml elements.
The below code doesn't retrieve the inner loop() elements if
the properties tag contains more than one item. Will you please  point
the error and correct me.
Please find the attached input xml file. Thanks.

use strict;
use XML::Simple;
use Data::Dumper;

die "Usage: perl $0  path output_file\n" unless @ARGV == 2;

my $path = shift;
my $output_file = shift;
my ($name,$url,$value,$password,$user,$prop_name,$string);

opendir (DIR, "$path") or die "Can't open the dir: $!\n";
my @files = grep (/\.xml$/, readdir(DIR));
 open(CSV, '>', "$output_file") or die "Can't open the file:$!\n";

my $header = "Name,Data Source,URL,Password\n";
print CSV $header;

foreach my $file(@files) {
print "Processing the file:$file\n";

($name,$url,$value,$password) = undef;


my $file_path = $path .'/'. $file;
my $jdbc_data_source = XMLin($file_path);

$name = "$jdbc_data_source->{'name'}";
$url = "$jdbc_data_source->{'jdbc-driver-params'}->{'url'}";
$password = 
"$jdbc_data_source->{'jdbc-driver-params'}->{'password-encrypted'}\n";

if (ref($jdbc_data_source->{'jdbc-driver-params'}->{'properties'}) =~ /ARRAY/) {
#print Dumper($jdbc_data_source);

foreach my $property
(@{$jdbc_data_source->{'jdbc-driver-params'}->{'properties'}})
{
#print Dumper($property);
# $prop_name = {$property}->[0];
#$prop_name = {$property}->[1];
#No need to capture the value if pop_name eq user;
# next if $prop_name eq 'user';
 $string .= "$name,$value,$url,$password\n";
 print "$string";
}
}
 else {
$prop_name =
$jdbc_data_source->{'jdbc-driver-params'}{'properties'}{'property'}{'name'}
;
#unless ($prop_name eq 'user'){
$value = 
$jdbc_data_source->{'jdbc-driver-params'}{'properties'}{'property'}{'value'}
;
#}

 $string .= "$name,$value,$url,$password\n";
}
#print "$string";
print CSV $string;
}

http://xmlns.oracle.com/weblogic/jdbc-data-source"; xmlns:sec="http://xmlns.oracle.com/weblogic/security"; xmlns:wls="http://xmlns.oracle.com/weblogic/security/wls"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://xmlns.oracle.com/weblogic/jdbc-data-source http://xmlns.oracle.com/weblogic/jdbc-data-source/1.2/jdbc-data-source.xsd";>
  AllocationImport Data Source
  
test url 1
name 1

  
den_alien
ben1
  
  
v$session.program
ALIMP-OSB-11G
  


  
user
ben_alimp_sb
  
  
v$session.program
ALIMP-OSB-11G
  

{encrypted password 1}=
  
  
600
true
SQL SELECT 1 FROM DUAL
  
  
jdbc/AllocationImportServiceDS
TwoPhaseCommit
  

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
On Mon, Dec 7, 2015 at 6:41 PM, Brock Wilcox  wrote:
> I don't know. But I think that worst case you can just download the single
> file from this library and add it to your application directly. It requires
> no compilation or anything.
>
> https://metacpan.org/source/MJD/Devel-Trace-0.12/Trace.pm
>
> --Brock
>
> On Mon, Dec 7, 2015 at 9:39 PM, Kenneth Wolcott 
> wrote:
>>
>> On Mon, Dec 7, 2015 at 6:33 PM, Brock Wilcox 
>> wrote:
>> > Give devel::trace or devel::tracemore a try :)
>>
>> Is it possible to install this from Active State repository without
>> having an-up-date ActiveState Perl DevKit license?

  Hi Brock;

  Thanks so much for the tip!

  It helps a lot!

  I think I'll have to thank the author directly.

  Now if the code was only in Perl instead of a chain of bash to Perl
to bash to Perl calls :-)

Thanks,
Ken

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Brock Wilcox
I don't know. But I think that worst case you can just download the single
file from this library and add it to your application directly. It requires
no compilation or anything.

https://metacpan.org/source/MJD/Devel-Trace-0.12/Trace.pm

--Brock

On Mon, Dec 7, 2015 at 9:39 PM, Kenneth Wolcott 
wrote:

> On Mon, Dec 7, 2015 at 6:33 PM, Brock Wilcox 
> wrote:
> > Give devel::trace or devel::tracemore a try :)
>
> Is it possible to install this from Active State repository without
> having an-up-date ActiveState Perl DevKit license?
>
> Thanks,
> Ken Wolcott
>


Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
On Mon, Dec 7, 2015 at 6:33 PM, Brock Wilcox  wrote:
> Give devel::trace or devel::tracemore a try :)

Is it possible to install this from Active State repository without
having an-up-date ActiveState Perl DevKit license?

Thanks,
Ken Wolcott

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
On Mon, Dec 7, 2015 at 6:31 PM, Kenneth Wolcott
 wrote:
> Hi;
>
>   I've inherited a lot of Perl [mostly ActiveState] (and bash) scripts
> were the former writers and maintainers did not use "use strict" and
> "use warnings" and have other "less than Best Practices".  Most of the
> scripts are executed on Windows and some of them are executed on a Mac
> and some are executed on Linux.  There is apparently a massive amount
> of dead code and duplicate code.  There are weird dependencies here
> and there on Cygwin.  Apparently there was an earlier (still present?)
> dependency on MKTools.  Some scripts need to be modified prior to
> first build on a new branch.  The builds sometimes work fine and
> sometimes fail in strange ways.
>
>   It would be nice if there was a trace facility built-in to Perl that
> I could enable that would tell me each line number of each script that
> was currently executing.
>
>   I'd love to replace all the Active State Perl code with either
> Cygwin Perl or Strawberry Perl.  Of course I'd like to replace the
> Windows machines with Linux, but that's not going to happen :-)
>
>   One of the strange things I see happening is that a path construct
> of "c:\\dir1\\dir2\\filename" (not quoted in the script is being
> parsed as "c:\dir1\di2filename" which seems strange.  Another
> situation that seems strange is the use of three backslashes together.
> I thought that if you had to backslash a backslash it would always
> come in pairs.  What is strange is that this thing works sometimes and
> then doesn't work sometimes.
>
>   Now I'm here late at work trying to figure out why the build
> infrastructure is broken.
>
> Thanks,
> Ken Wolcott

Of course we don't have the Active State Perl Debugger activated, as
apparently that requires a license, which apparently is too expensive.

Would be nice to be able to use Cygwin Perl or Strawberry Perl or even
Linux Perl so that I'd have a debugger.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Brock Wilcox
Give devel::trace or devel::tracemore a try :)
On Dec 7, 2015 21:32, "Kenneth Wolcott"  wrote:

> Hi;
>
>   I've inherited a lot of Perl [mostly ActiveState] (and bash) scripts
> were the former writers and maintainers did not use "use strict" and
> "use warnings" and have other "less than Best Practices".  Most of the
> scripts are executed on Windows and some of them are executed on a Mac
> and some are executed on Linux.  There is apparently a massive amount
> of dead code and duplicate code.  There are weird dependencies here
> and there on Cygwin.  Apparently there was an earlier (still present?)
> dependency on MKTools.  Some scripts need to be modified prior to
> first build on a new branch.  The builds sometimes work fine and
> sometimes fail in strange ways.
>
>   It would be nice if there was a trace facility built-in to Perl that
> I could enable that would tell me each line number of each script that
> was currently executing.
>
>   I'd love to replace all the Active State Perl code with either
> Cygwin Perl or Strawberry Perl.  Of course I'd like to replace the
> Windows machines with Linux, but that's not going to happen :-)
>
>   One of the strange things I see happening is that a path construct
> of "c:\\dir1\\dir2\\filename" (not quoted in the script is being
> parsed as "c:\dir1\di2filename" which seems strange.  Another
> situation that seems strange is the use of three backslashes together.
> I thought that if you had to backslash a backslash it would always
> come in pairs.  What is strange is that this thing works sometimes and
> then doesn't work sometimes.
>
>   Now I'm here late at work trying to figure out why the build
> infrastructure is broken.
>
> Thanks,
> Ken Wolcott
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
Hi;

  I've inherited a lot of Perl [mostly ActiveState] (and bash) scripts
were the former writers and maintainers did not use "use strict" and
"use warnings" and have other "less than Best Practices".  Most of the
scripts are executed on Windows and some of them are executed on a Mac
and some are executed on Linux.  There is apparently a massive amount
of dead code and duplicate code.  There are weird dependencies here
and there on Cygwin.  Apparently there was an earlier (still present?)
dependency on MKTools.  Some scripts need to be modified prior to
first build on a new branch.  The builds sometimes work fine and
sometimes fail in strange ways.

  It would be nice if there was a trace facility built-in to Perl that
I could enable that would tell me each line number of each script that
was currently executing.

  I'd love to replace all the Active State Perl code with either
Cygwin Perl or Strawberry Perl.  Of course I'd like to replace the
Windows machines with Linux, but that's not going to happen :-)

  One of the strange things I see happening is that a path construct
of "c:\\dir1\\dir2\\filename" (not quoted in the script is being
parsed as "c:\dir1\di2filename" which seems strange.  Another
situation that seems strange is the use of three backslashes together.
I thought that if you had to backslash a backslash it would always
come in pairs.  What is strange is that this thing works sometimes and
then doesn't work sometimes.

  Now I'm here late at work trying to figure out why the build
infrastructure is broken.

Thanks,
Ken Wolcott

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/