Hello monks,

I have been trying to get this short script to print out a suffix tree to a .txt file, so that I might process the tree (looking for the longest repeated subsequence). On Windows XP:

#!/usr/bin/perl; use SuffixTree; use warnings; use strict; my $filename7 = "C:\\MB\\Cp\\mississippi_out_7.txt"; open(MY7, ">>$filename7") or die "Unable to open $filename7: $!\n"; my $str="catgatgttttccctatgggatttttgaa"; my $tree=create_tree($str); print_tree($tree); my $position = find_substring($tree, "ttttg"); printf("\nPosition of (ttttg) in the sequence is %ld.\n\n", $p +osition); print MY7 "$tree"; #tried to output to .txt print MY7 "${$tree}"; #tried to dereference exit 0;
The script comes packaged (as a Synopsis) with davido's SuffixTree.pm. It works fine but outputs only to the screen. I tried to print $tree to a .txt file as shown above, and got this output:
_p_SUFFIX_TREE=SCALAR(0x224fa4)
The attempt to dereference and output yielded:
2273160
to <STDIN> and to the output file.

Is there a simple way to do this?

Many thanks,

fdillon


In reply to Printing out to a .txt file. by fdillon

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, details, 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, summary, 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.