Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8118321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:27:05+00:00 2026-06-06T04:27:05+00:00

I have asked this question before but did not get the satisfied answer as

  • 0

I have asked this question before but did not get the satisfied answer as i did not include the proper example to look at.

I have multiple scripts that uses xsl to print xml output from those scripts. i want to write a one master script that calls those scripts and combine the out and print one output. could someone please help me with this?

#Example Script 1

use strict;
use warnings;
use Data::Dumper;
use XML::Simple;
use Getopt::Long;

my $output = '';
my $debug = 0;
my $path;
GetOptions('path=s' => \$path,'output=s' => \$output, 'debug=i' => \$d
+ebug);

if($output eq ''){
    die ("parameter --output=s is missing");
}     
open my $xmloutput, ">", $outputFile or die "can not open $outputFile 
+";
 print $xmloutput "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-s
+tylesheet type=\"text/xsl\" href=\"book.xsl\"?>\n<Books>\n";

my $parser = new XML::Simple;
my $data = $parser->XMLin("$path");
print $xmloutput " <bookDetails> \n";
print $xmloutput "  <bookName>$data</bookName> \n";
print $xmloutput " </bookDetails> \n";
print $xmloutput " </Books> \n";
close $xmloutput;

EXAMPLE 2

EXAMPLE 2
use strict;
use warnings;
use Data::Dumper;
use XML::Simple;
use Getopt::Long;

my $output = '';
my $debug = 0;
my $path;
GetOptions('path=s' => \$path,'output=s' => \$output, 'debug=i' => \$d
+ebug);

if($output eq ''){
    die ("parameter --output=s is missing");
}     
open my $xmloutput, ">", $outputFile or die "can not open $outputFile 
+";
 print $xmloutput "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-s
+tylesheet type=\"text/xsl\" href=\"Piano.xsl\"?>\n<Piano>\n";

my $parser = new XML::Simple;
my $data = $parser->XMLin("$path");
print $xmloutput " <PianoDetails> \n";
print $xmloutput "  <PianoName>$data</PianoName> \n";
print $xmloutput " </PianoDetails> \n";
print $xmloutput " </Piano> \n";
close $xmloutput;

THIS IS WHAT I AM TRYING.

  my $output = '';


   my $example1 = `perl script1.pl --path=c:/cygwin/home/username/directory --debug=1`;
    my $example2 = `perl script2.pl --path=c:/cygwin/home/username/directory --debug=1`;

 open my $finaloutput, ">" $output or die "cant open the file";
  print $finaloutput "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet     
          type=\"text/xsl\" href=\"final.xsl\"?>\n<OutputDestination>\n";

   my @attachscript  = ($example1, $example2);

   for my $attached (@attachscript) {
     print $finaloutput "<outputgoes_here_from_script> $attached   
                         </outputgoes_here_from_script>
    }

     PRINT $finaloutput "</OutputDestination>"
     close $finaloutput;

Is there any better way of doing this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:27:06+00:00Added an answer on June 6, 2026 at 4:27 am

    If script1 and script2 can’t be converted to Perl Modules and called directly (as functions) within your wrapper (or even just rewritten into a single new script), I’d consider just doing this in the wrapper:

    open (STDOUT, ">$output") or die "Can't open STDOUT: $!";
    print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"final.xsl\"?>\n<OutputDestination>\n";
    print "<outputgoes_here_from_script>";
    `perl script1.pl --path=c:/cygwin/home/username/directory --debug=1`;
    print "</outputgoes_here_from_script>";
    print "<outputgoes_here_from_script>";
    `perl script2.pl --path=c:/cygwin/home/username/directory --debug=1`;
    print "</outputgoes_here_from_script>";
    print "</OutputDestination>";
    close(STDOUT);
    

    You might need a “print” before the back-ticked system calls, but try it that way first. But, it’s not much different than your approach, just skipping the need to save the output from each script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

another memory management question: I have asked this before, but did not really get
Fellow coders, I have asked this question before but did not get a conclusive
i have asked this question before but the answer received was not applicable in
Guys I have asked this question before but did not receive a single comment
I know that this question is being asked before but I did not get
I have asked the same question before, but did not get what I want.
I have asked this before but I didn't get the question right so the
This question may have been asked before, but I had trouble finding an answer,
I was asked this before with slight different with current question. but did not
I know this question has been asked before but the solutions did not work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.