Hello, Here is the code:
1 #! /usr/bin/perl 2 3 use Tk; 4 use Tk::NoteBook; 5 6 $num_adapters = 0; 7 $adapt_tabs = 0; 8 $inter = 0; 9 $inter2 = 0; 10 $count2; 11 $adapt_tabs = 0; 12 $num1; 13 @interface[$num1]; 14 $s1=0; 15 $page_num = 0; 16 17 # Create MainWindow 18 19 $win_main = MainWindow->new(-background => 'black'); 20 $win_main->title ("IP Configuration"); 21 $win_main->geometry("350x150+0+0"); 22 23 #Add Notebook Widget to the main window 24 $nb = $win_main->NoteBook(); 25 26 #Run ipconfig command and put results into the @list array 27 @list = `ipconfig /all`; 28 29 #Walk through the information in the @list array and 30 #make a page for host information 31 foreach (@list) { 32 33 if (/Host/) { 34 ($label,$value) = split /:/; 35 $title = "Host: " . $value; 36 $host_tab = $nb->add("Host", -label => $title); 37 } 38 # Count the number of adapters, parse the name and add the name to +the 39 # @interface array 40 41 if (/Ethernet adapter/) { 42 43 $int_name = $_; 44 $int_name =~ s/Ethernet adapter//; 45 $int_name =~ tr/://d; 46 chop $int_name; chop $int_name; 47 @interface[$num1] = $int_name; 48 $num1++; 49 $num_adapters++; 50 } 51 } 52 53 # Create a page for each interface 54 55 foreach (@interface) { 56 $page_name = $_; 57 #$lname = "a" . $s1; 58 $int[$s1] = $nb->add($s1, -label => $page_name); 59 $s1++ 60 } 61 62 #Print page names 63 64 @pn = $nb->pages; 65 foreach (@pn) { 66 print $_ . "\n"; 67 } 68 69 # Process the information onto the pages 70 71 foreach (@list) { 72 73 ($lab1,$val1) = split /:/; 74 $lab_len = length $lab1; 75 $val_len = length $val1; 76 $output = $label . ": " . $value; 77 78 79 if (/Ethernet adapter/) { 80 $nb->$page_num->Label(-textvariable => $output)->pack(); 81 $page_num++; 82 } 83 else { 84 $nb->$page_num->Label(-textvariable => $output)->pack(); 85 } 86 } 87 88 $win_main->pack(-side => 'left', -anchor => 'nw'); 89 90 91 MainLoop;
The problem I am having is lines 80 and 84. When I run the script I get the following error:
Failed to AUTOLOAD 'Tk::NoteBook::0' at ipc1.pl line 84
So my question is how do I address a "page" in the NoteBook and add things like Labels or text?

In reply to How do I put Widgets/Information onto TK::NoteBook pages by Anonymous Monk

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.