The only output to a file you have here is:
$dst ||= "$0.edit"; #in case user hits cancel
warn "dst=$dst";
open (my $fh, '>',$dst) or die "$!\n";
print $fh $sublable->get("1.0","end");
Your original file is only read:
my $fh;
open( $fh, '+<', "./test.txt" ) or die $!;
my @contents = <$fh>;
# print "@contents\n";
close( $fh );
Meaningful variable names would probably help you.
Update:
There may also be a problem here:
my $dst = $mw->getSaveFile(
-initialdir => $ENV{HOME},
-defaultextension => '.in',
-title => 'Save',
-filetypes => [
[ 'myfiles' => '.in' ],
[ 'All files' => '*' ],
],
);
Please post the output from your code. My problems in determining what's going wrong here stem from:
-
Opening the original file (./test.txt) in read-write (+<) mode but then only reading it.
-
Whether you're experiencing some confusion with using my $fh twice.
-
Your original file is in the current directory (./) but you're specifying -initialdir => $ENV{HOME}. What's the full pathnames of these?
-
The extension of your original file is .txt but you're specifying -defaultextension => '.in'
-
Your zig-zag indentation style doesn't help much either.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.