It would be easier for us to help you if you gave us more of a clue as to what happened. Specifically, which of the lines in your excerpt was line 116 in the original file? Where and what was the "previous declaration" of $buffer you mentioned?
The line
buffer = $text->get_buffer;
needs a "$" in front of buffer; this could be causing your problem. As to whether is really should be
my $buffer = $text->get_buffer;
I can only guess.
Also, if you posted all of the connect sub, it is using $buffer as a global. This works (if $buffer is really a global), but passing it as a parameter is more flexible and less prone to attracting errors when making changes to the surrounding code. Like this:
sub connect {
my $buffer = shift;
$buffer->set_text( "testing the text box and it must be working");
}
and you can call it as
... connect($buffer) ...
Perl has no problem with using lexical variables of the same name to hold the same value in different subs (or different blocks -- enclosed by curly braces), but some people do find it easier to follow the code if each sub uses a different variable name that is unique throughout the program.
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.