Hi,
thanks for the reply.I am a bit confused.In the first section of code I have a text widget defined like this:
my $f = $mw->Frame->pack(-side => 'top', -fill => 'x');
my $t = $mw->Scrolled("Text",-font=>"{arial} 12 {bold}")->pack(-side =
+> 'bottom', -fill => 'both', -expand => 1);
Then I have a number of subroutines where $t is used again.
These subroutines are bound to buttons which
are defined in the frame above with stmts like:
$f->Button(-text => "Display", -command =>\&tged)->pack(-side => 'righ
+t');
sub tged {
@chars=$t->get('sel.first','sel.last');
#print "\nSelected word:";
#print @chars;
}
1;
In the sub &tged, the get stmt should read characters
within the text widget defined initially using $t.If I use
"my $t" within this sub and localise it, we wont be referring to the first $t defined outside the sub.Is that
right?
These subs also use $t again and need to refer to the
text widget define initially using:
my $t = $mw->Scrolled("Text",-font=>"{arial} 12 {bold}")->pack(-side =
+> 'bottom', -fill => 'both', -expand => 1);
sub replace1{
.
.
$t->insert('sel.first',"$chosen1");
.
.
}
1;
sub replace2{
.
.
$t->insert('sel.first',"$chosen2");
.
.
}
1;
sub replace3{
.
.
$t->insert('sel.first',"$chosen3");
.
.
}
1;
sub addit{
.
.
@addword=$t->get('sel.first','sel.last');
.
.
}
1;
I'm not sure where we should use "my", and where we should not.Turning on use strict gives no message about $t.
The sub &tged works on the first button click, and does not
work therafter.The other subs are not working at all.
Please help.
Thanx :)
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.