Posted on 2006-01-30 20:10:55-08 by lawnboy
Need help assigning ->name a variable
I'm building a simple search function. Follows is a (stripped down) functional script:
use Win32::GUI; use File::Find::Rule; my $main = Win32::GUI::Window->new( -name => 'Main', -text => 'Test', -width => 225, -height => 100, ); $main->Center(); my $Pattern = $main->AddTextfield( -left => 100, -top => 10, -prompt => " List Files Named:", -height => 20, -width => 100, -text => "*.*", ); my $GoButton = $main->AddButton( -name => "GoButt", -size => [75,25], -text => "Start Search", -pos => [70,35], ); $main->Show(); Win32::GUI::Dialog(); sub GoButt_Click { my $pt = $Pattern->Text; my $found_files = find( name => "$pt", maxdepth => 1, exec => \&show_it, in => ("c:\\"), ); } sub show_it { print "@_[2]\n"; } sub Main_Terminate { return -1; } sub Exit { return -1; }
The function works very well, but I'd like to make it case-insensitive. I've tried everything I can think of to convert
$Pattern->Text
to a regex so I can use /i but I keep ending up with a reference instead of the referent. At least, that's what appears to be happening. I've also spent time trying to build
$found_files->name
as a literal string but I'm just not getting it. Obviously, I'm a newbie to Perl. I can't help but think I'm not seeing the forest for the trees; this is too common a feature to cause me this much trouble. Could someone please buy me a clue with an explanation of technique or even an example? TIA, LawnBoy
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.