in reply to how to combine these two scripts in perl?

I see one script and not two, so your question is confusing. I think you mean you want to pass a variable between scripts without storing it in a file.

First of all, I am not sure why storing it in a file concerns you. There are several modules available to you, including Data::Dumper and Storable. Data::Dumper is core so you already have it, nothing needs to be installed.

Not using a file involves the two scripts sharing memory. Also possible, I believe, but more complicated.

But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

  • Comment on Re: how to combine these two scripts in perl?

Replies are listed 'Best First'.
Re^2: how to combine these two scripts in perl?
by dimitris852 (Acolyte) on Mar 15, 2016 at 14:20 UTC

    i could use the following factory instead of that in the 1st script,but that would give me a file(out_file)

    my $factory = Bio::Tools::Run::Alignment::Clustalw->new(-matrix => 'BLOSUM','outfile' => 'out_file','outype'=clustalw);

    This file matches to first line my $alnio = Bio::AlignIO->new('-file'=> 'out_file','-format' => 'clustalw');

    of the 2nd script,and when combining the two scripts, the whole (1+2) script works fine. But

    yeap, i want to pass a variable and have only one file produced at the end of final whole (1+2)script with my final Tree.

      If you have unwanted files left over, the solution to that is easy.

      # script 1 use strict; use warnings; use Storable; my $storable_file = 'store.file'; $var = complicated multilevel structure; store(\$var,$storable_file); # script 2 use strict; use warnings; use Storable; my $storable_file = 'store.file'; my $var = retrieve($storable_file); unlink $storable_file; open my $outfile,'>','output.file'; print $outfile $var; close $outfile;

      Only file created will be output.file.

      But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

        please excuse me for the confusion. I edited my previous comment. I have 3 different things in my mind:

        I want to highlight also that  $aln at the last line of the first script has the alignment.

        #I tried at first to pass this alignment to the my $alnio = Bio::AlignIO but didn't succeed it.

        ##My second try was changing  $factory and outputting a file(out_file) from my $factory = Bio::Tools::Run::Alignment::Clustalw->new(-matrix => 'BLOSUM','outfile' => 'out_file','outype'=clustalw); in order to use it in my $alnio = Bio::AlignIO->new('-file'=> 'out_file','-format' => 'clustalw');

        This is what I was searching to do through a variable and not a file

        ###Thrird, now I'm thinking of finding a way to delete the file out_file

        after it is used from

        my $alnio = Bio::AlignIO but seems me not the right way.