I would see codes written like this:
$submit->bind('<1>' => sub { Submit($p1, $p2, $p3, $p4, $p5); } );
The above codes I understand, knowing how many parameters and how to intercept the params in a subroutine.
However I dont understand this code:
$yscroll=$mw->Scrollbar()->pack(-fill=>'y', -side=>'right',);
$yscroll->configure( -command => [ \&ScrollAll, $yscroll, [$p1, $p2, $
+p3, $p4, $p5]]);
sub ScrollAll {
my ($sb, $wigs, @args) = @_;
foreach my $w (@$wigs) {
$w->yview(@args);
}
}
Can anyone explain how the params are passed when it is constructed in this manner:
-command => [ \&ScrollAll, $yscroll, [$p1, $p2, $p3, $p4, $p5]]
In the above sub's code
my ($sb, $wigs, @args) = @_;
What is assigned to $sb?
What is assigned to $wigs?
Is there any other way of passing params when used with
-command?
And can that like be written like:
-command => sub {
subname ($p1, $p2, $p3, $p4, $p5);
}
thanks
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.