Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hi poj,

Thanks for your suggestions and for showing 11 changes in my script. The script now works but in the result part, many unwanted combinations are found along with the desired 6-letter combinations. The 6-letter combinations are correct and this is only what I need in the result. How can I get only the desired 6-letter combinations in the result?

Here goes the script again:

#!/usr/bin/perl #1 add use strict use strict; use warnings; #2 add '' use File::Glob('bsd_glob'); ############################################ ## Output to a TEXT File using file handle: ############################################ my $output="Joint.txt"; open (my $fh,">",$output) or die"Cannot open file '$output'.\n"; #3 declare variables my (@array,@DNA,@list); my ($filename,$combi,$entry,$number,$DNA); do { print"\n\n Press 1 to Enter New File or 2 to Combine: "; $entry=<STDIN>; chomp $entry; if ($entry==1) { print"\n\n Enter New File Name (.txt): "; $filename = <STDIN>; chomp $filename; unless ( open(FILE, $filename) ) { print "Cannot open file \"$filename\"\n\n"; exit; } @DNA= <FILE>; close FILE; #5 add chomp chomp(@DNA); #6 add join by comma $DNA = join(',',@DNA); push @array, $DNA; #7 not needed array1=array; } elsif ($entry==2) { # Curly brace for entry2 starts $number=@array; print"\n\n No. of Elements in Joined Array: $number\n"; print $fh "\n\n No. of Elements in Joined Array: $number\n"; + # To produce all possible combinations of different elements: #10 use simple $_ on @array $combi = join('',map {'{'.$_.'}'} @array); @list = bsd_glob($combi); print"\n Results:\n"; print $fh "\n Results:\n"; #11 print each element on new line print join "\n",@list; print $fh join "\n",@list; } # Curly brace for Entry 2 ends: } until ($entry==2); # Square bracket for do-until: close $output; exit;

Here goes the result of cmd and of output file Joint.txt:

No. of Elements in Joined Array: 3 Results: A1T1C1G1A1C1 # This is correct A1T1C1G1 A1T1C1G1 A1T1C1G1 A1T1C1G1 A1T1C1G1 A1T1C1G1 A1T1C1G1 A1T1C1G2A1C1 # This is correct A1T1C1G2 A1T1C1G2 A1T1C1G2 A1T1C1G2 A1T1C1G2 A1T1C1G2 A1T1C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C1G2 C1G2 C1G2 C1G2 C1G2 C1G2 C2G1A1C1 C2G1 C2G1 C2G1 C2G1 C2G1 C2G1 C2G1 A1C1 A1C1 A1C1 A1C1 A1C1 A1C1

In reply to Re^6: How can one get all possible combinations of elements of different arrays using File::Glob(bsd_glob)? by supriyoch_2008
in thread How can one get all possible combinations of elements of different arrays using File::Glob(bsd_glob)? by supriyoch_2008

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2018-06-21 18:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?



      Results (118 votes). Check out past polls.

      Notices?