>>>> <LabelResponse> >>>>> <Label> >>>>> <Image Number="1">base64datahere</Image> >>>>> <Image Number="2">base64datahere</Image> >>>>> <Image Number="3">base64datahere</Image> >>>>> </Label> >>>>> </LabelResponse> >>>>> > >>> #!/usr/bin/perl >>> >>> use strict; >>> use warnings; >>> use XML::Simple; >>> >>> my $data = XMLin($path_to_file); >>> >>> foreach my $image (@{$data->{Label}->{Image}}) { >>> print "$image->{content}\n"; >>> } > >> Thanks Erez, I will stick with XML::Simple for now. I need to save >> each set of base64data to a separate variable, so I can save each to a >> separate file. How can I save each to a separate variable? > > if you need to save the content to a file, you can already do that > inside the loop, using, in the example above the "$image->{content}" > as the files content. You'd need to generate different file names, > Similar to: > > foreach my $image (@{$data->{Label}->{Image}}) { > my $filename = "image".$image->{Number}; #value of "Number" attribute > open my $FH, '>', $filename or die $!; > flock $FH, LOCK_EX or die $!; > print $FH $image->{content} or die $!; > close FH or die $!; > }
Thank you, I've adapted that and will test ASAP. I'd like to use a filename like: my $filename = $var_name"_static_portion_"$image->{Number}.pdf where $var_name is the name of a variable. Is my above syntax correct? - Grant -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/