Thanks for pointing them out. I have fixed those errors as you suggested. However ...

How did you fix them?

Here is how I fixed them

#!/usr/bin/perl -- ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::NoteBook; my $mw = MainWindow->new( -title => "Testing" ); $mw->Button( -text => "Open", -command => \&open ) ->pack( -anchor => 'center', -side => "left" ); $mw->Button( -text => "Save", -command => \&save ) ->pack( -anchor => 'center', -side => "left" ); our $nb = $mw->NoteBook( -background => 'white', -inactivebackground = +> 'grey', ) ->pack( -expand => 1, -fill => 'both' ); my $maintab = "Main Window"; my $frame = $nb->add( $maintab, -label => $maintab ); my $txt = $frame->Text( -width => 240, -height => 50 )->pack(); MainLoop; sub file_open { my @types = ( [ "Log files", [qw/.log/] ], [ "Text files", [qw/.txt/] ], [ "All files", '*' ], ); my $aref = $mw->getOpenFile( -filetypes => \@types, -initialdir => '.', -multiple => 1 ); return( $aref ); } ## end sub file_open sub open { my $file_array = &file_open; print "\n"; print join( "\n", @$file_array ); print "\n"; for my $tab ( @$file_array ) { my $frame = $nb->add( $tab, -label => $tab ); $txt = $frame->Text( -width => 240, -height => 50 )->pack(); open FR, "<$tab" or die "Cant open file:$!\n"; my $content = join "", <FR>; $txt->insert( 'end', "$content" ); close( FR ); } } ## end sub open sub save { my $page = $nb->raised(); my $content = $txt->get( "1.0", "end" ); print "\nsaving content= $content\n"; warn "I REFUSE TO WRITE TO page($page) "; #~ open FW, ">$page" or die "Cant Write to file:$!\n"; #~ print FW $content; #~ close( FW ); } ## end sub save

I run the program, open two three files, and two three new tabs are added, I hit save on each tab and the correct filename is selected/warned, not just the latest ...

i tried but cant figure out where is the mistake or what am i missing.

What I said, subs shouldn't use global variables, they should pass arguments, its Coping with Scoping also known as the spirit of strict also known as the life cycle of variables or memory management


In reply to Re^3: Perl Tk Multiple Notebook Editing and Save (life cycle of variables) by Anonymous Monk
in thread Perl Tk Multiple Notebook Editing and Save by akamboj84

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.