Hi Perl Monks,
I have a perl script which makes use of Tk
main.pl use Tk; . . . . sub s1 { require p1.pl; require p2.pl; require p3.pl; require p4.pl; . . . .} 1; . . .
p1.pl,p2.pl,p3.pl,p4.pl contain subroutines which are called within subroutine s1.

As a further level of nesting,in p3.pl
p3.pl . . . sub s2 { require p5.pl; require p6.pl; require p7.pl; require p8.pl; . . . } 1; . . .
p5.pl,p6.pl,p7.pl,p8.pl contain subroutines which are called within subroutine s2.

I had written all the code in parts, i.e. all the lower level subs first and then combined
the entire code using require statements.

The code was working fine this way.When I put all the subroutines in main.pl itself and removed
the require statements, I got a lot of Tk errors:

Tk::Error: Can't call method "insert" without a package or object reference at C:\monisha\project\Appliw\s.pl line
124, <EDINP> line 1.
\&main::replace1
(menu invoke)

Tk::Error: Tk::Label=HASH(0x23b8818) is not a Tk object at D:/Perl/site/lib/Tk.pm line 91, <EDINP> line 1.
Tk callback for tkwait
(command bound to event)

Tk::Error: Can't call method "get" without a package or object reference at C:\monisha\project\Appliw\s.pl line 46,
<EDINP> line 1.
\&main::tged

Line 124 is this:

$t->insert('sel.first',"$chosen1");

Line 46:

@chars=$t->get('sel.first','sel.last');

What is the problem here?
Please help.Thanx
:)

In reply to Tk question by perl_seeker

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.