Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Write a Perl script that uses <> to read STDIN such that you can pipe the output of the previous program into it and then sort the cut fragments by length, try doing this using split and storing matches in an array. For example, splitting the sting at the ^ character into a single array variables.
The output of the previous code looks like this...
AAAAAAAAGACGT^CTTTTTTTAAAAAAAAGACGT^CTTTTTTTand so the array for this sectionwould look like
("AAAAAAAAGACGT","CTTTTTTTAAAAAAAAGACGT","CTTTTTTT")I am not quite sure how to do this... I imagine the sort function would be used
sort { length($a) <=> length($b)and
split(/\^/and on the command line I would put previous_script.pl text.txt | new_script
Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating array from previous script using split
by stevieb (Canon) on Oct 22, 2015 at 17:36 UTC | |
|
Re: Creating array from previous script using split
by ww (Archbishop) on Oct 22, 2015 at 22:03 UTC |