J
Jockser
Hello I have a XML doc that I'm processing. I'm down to the point where in
the for loop I need to check to see if 'type' is set to 'a' or 'b'.
Using print Dumper( $temp ) gives me this:
$VAR1 = {
'lname' => 'Smith',
'fname' => 'John',
'address1' => '2500 Lemon St.',
'type' => 'a'
};
1st question: Is this a Hash? I haven't been sucessful in accessing it
like a hash, ofcourse this is the first time I've delt with Hashes.
2nd question: How can I check to see if 'type' is = to 'a' or 'b' ?
Code here:
use strict;
use warnings;
use Template;
use XML::Simple;
use Data:
umper;
my $cust_xml = XMLin('./test2.xml'); #, ForceArray => 1);
my $input = 'temp_a.tt';
my $tt = Template->new( );
for my $temp (@{$cust_xml->{template}}) {
# Need some code here to test the value of 'type', if it is 'a' or 'b'
# I can then do an if statement to change the $input file
# $input = 'temp_b.tt';
$tt->process($input, $temp)
|| die $tt->error( );
print Dumper( $temp );
}
print "\n";
#print XMLout($cust_xml);
print "\n";
Thanks!
the for loop I need to check to see if 'type' is set to 'a' or 'b'.
Using print Dumper( $temp ) gives me this:
$VAR1 = {
'lname' => 'Smith',
'fname' => 'John',
'address1' => '2500 Lemon St.',
'type' => 'a'
};
1st question: Is this a Hash? I haven't been sucessful in accessing it
like a hash, ofcourse this is the first time I've delt with Hashes.
2nd question: How can I check to see if 'type' is = to 'a' or 'b' ?
Code here:
use strict;
use warnings;
use Template;
use XML::Simple;
use Data:
my $cust_xml = XMLin('./test2.xml'); #, ForceArray => 1);
my $input = 'temp_a.tt';
my $tt = Template->new( );
for my $temp (@{$cust_xml->{template}}) {
# Need some code here to test the value of 'type', if it is 'a' or 'b'
# I can then do an if statement to change the $input file
# $input = 'temp_b.tt';
$tt->process($input, $temp)
|| die $tt->error( );
print Dumper( $temp );
}
print "\n";
#print XMLout($cust_xml);
print "\n";
Thanks!