- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Perl question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2004 06:19 PM
тАО05-06-2004 06:19 PM
%all=("\$a"=>$buta,"\$b"=>$butb);
for $temp(keys %all) {
if ($all{$temp} eq 1) {
$temp->destroy;
last;
}
}
How can I achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2004 06:37 PM
тАО05-06-2004 06:37 PM
Re: Perl question
#!/usr/bin/perl -w
use strict;
my $a = "test";
my $b = "test2";
my $adata = 'one';
my $bdata = 'two';
my %hash = (
$a => $adata,
$b => $bdata
);
for my $key (keys %hash) {
printf( "Got here with %s and %s\n", $key, $hash{$key} );
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2004 06:46 PM
тАО05-06-2004 06:46 PM
Re: Perl question
My problem is kinda more complex.
$a specifies a button.
$a = $mw -> Checkbutton ('-indicator'=>off, '-activebackground'=>green, '-border'=>15, '-text'=>green, -command=>\&action, '-variable'=>\$buta)-> place ( -x=>10, -y=>10, -height=>40, -width=>40);
I wish to destroy this button if someone clicks on it.Of course it's simple if there's only one button.
But I wish to destroy a specific button if someone clicks on it....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2004 06:54 PM
тАО05-06-2004 06:54 PM
Re: Perl question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2004 07:01 PM
тАО05-06-2004 07:01 PM
Re: Perl question
Because this way I'll have to define different function for each button.
I'll do that if there's no choice, but I wish to make the program as smaller as possible.
Ego issues :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2004 07:44 AM
тАО05-07-2004 07:44 AM
Re: Perl question
eval "$temp->destroy";
Also, the "if ($all{$temp} eq 1)" looks a
bit fishy; perhaps it should be
"if ($app{$temp})".
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2004 09:12 PM
тАО05-07-2004 09:12 PM
SolutionYou won't need a seperate function for each button. define the command as
[ \&action,$a ] for the first button
[ \&action,$b ] for the second button and so on.
In you action function, destroy $_[0]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2004 12:11 PM
тАО05-08-2004 12:11 PM
Re: Perl question
I've not done much OO in perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2004 12:45 AM
тАО05-09-2004 12:45 AM
Re: Perl question
Thanks for the eval tip.
Regarding your second advise:
Also, the "if ($all{$temp} eq 1)" looks a
bit fishy; perhaps it should be
"if ($app{$temp})".
I specifically do
"if ($all{$temp} eq 1)"
because there's also
"if ($all{$temp} eq 2)"
so:
"if ($app{$temp})" won't be good enough
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-09-2004 12:53 AM
тАО05-09-2004 12:53 AM
Re: Perl question
I probably miss something...