Win32::FileOp::OpenDialog with Tk
Problem: If I open an Win32::FileOp::OpenDialog from within a Tk window the OpenDialog leaves footprints all over my Tk Main window when it is moved over the main Tk window. I have tried binding the main Tk window with Events that would update its view such as , , to see if will get repainted. It does not. I have tried configuring the OpenDialog with a 0 as a handle, a DeskTopHandle, and the Tk Main window handle. These do not help. It seems that I am not configuring the OpenDialog with the correct handle. Anybody have any ideas or experience with this problem. Thanks Jim James C. Hooker Marconi - TAC ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: input redirection question
Attache is my test code: while () { print "$_"; } I call it via C:>prac.pl < testone.txt The testone.txt file has three lines of text in it. The program runs and emits a single newline, but no text. It is as if it cannot recognize the input information. This is why I was wondering if there is some kind of Windows configuration I should be doing. Bernard -Original Message- From: Kevin Horvatin [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 12:07 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: input redirection question You shouldn't have to do anything at all --- if you post a simple program that you believe should work you will get more help. -Kevin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Eisengrein Sent: Friday, April 04, 2003 2:01 PM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: input redirection question Does it truly need to be redirected, or can you just use @ARGV ? -Original Message- From: Bernard Golden [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 1:17 PM To: [EMAIL PROTECTED] Subject: input redirection question I want to enable my program to read from STDIN via input redirection, e.g.: myprogram < getstuff When I try it on my machine the program does not see the input. Is there something I should be configuring my machine with to enable it to see redirected input? Many thanks. Bernard Golden ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What is wrong here (finding zero sized file )...
Carl Jolley wrote: > On Thu, 3 Apr 2003, Daniel Gross wrote: > > > Hello, > > > > I am trying to find all files that have zero size, but it doesn't work > > -- why? > > > > > > my @tmpArray = glob("$dirName/*.tif"); > > my @zeroFiles = getZeroSizeTiffs(@tmpArray); > > > > sub getZeroSizeTiffs { > > my (@tiffFiles) = @_; > > > > my @zeroFiles = grep { -z $_ } @tiffFiles; > > > > return @zeroFiles; > > } > > > > My guess is that the $dirName is giving you problems. Since you glob'ed > with a directory name, my guess is that the list returned by the glob > was just filenames, without the directory prepended. Try this for your > grep and see if it works: > > my @zeroFiles = grep { -z "$dirName/$_" } @tiffFiles; > > [EMAIL PROTECTED] > All opinions are my own and not necessarily those of my employer > I think Daniel's doing it right. My guess is his pathnames have spaces in them. I first noticed this weirdness on Windoze and I thought it was just normal stuff, but I just verified it on Linux too. Try this test on for size: [NB. This script removes the directory: "a directory with spaces" if it exists ;-] == #!/usr/bin/perl -w use strict; use File::Path 'rmtree'; use FileHandle; use File::Glob qw(); my $tstdir = 'a directory with spaces'; -d $tstdir and File::Path::rmtree( $tstdir ); mkdir( $tstdir ) or die( "mkdir: $tstdir: $!" ); foreach ( qw( a b c d e f ) ) { new FileHandle( ">$tstdir/$_.tif" ) or die( "create: '$tstdir/$_.tif': $!" ); } foreach ( glob( qq($tstdir/*.tif) ) ) { print "glob: got: $_\n"; } print "Glob(", $File::Glob::GLOB_ERROR, "): $!\n" if ( $File::Glob::GLOB_ERROR ); foreach ( CORE::glob( qq($tstdir/*.tif) ) ) { print "CORE::glob: got: $_\n"; } print "Glob(", $File::Glob::GLOB_ERROR, "): $!\n" if ( $File::Glob::GLOB_ERROR ); foreach ( File::Glob::glob( qq($tstdir/*.tif) ) ) { print "File::Glob:glob: got: $_\n"; } print "Glob(", $File::Glob::GLOB_ERROR, "): $!\n" if ( $File::Glob::GLOB_ERROR ); == I get the same output on WindowsNT(ASPerl5.6.0-623) and RHLinux7.1(Perl5.6.0): glob: got: a glob: got: directory glob: got: with CORE::glob: got: a CORE::glob: got: directory CORE::glob: got: with File::Glob:glob: got: a directory with spaces/a.tif File::Glob:glob: got: a directory with spaces/b.tif File::Glob:glob: got: a directory with spaces/c.tif File::Glob:glob: got: a directory with spaces/d.tif File::Glob:glob: got: a directory with spaces/e.tif File::Glob:glob: got: a directory with spaces/f.tif == FWIW, perl crashes on both Linux and Windoze if I call CORE::glob when I do: use File::Glob qw(:glob); in the above program. On Linux I get a SEGV, and on Windoze the disk just spins... rgr ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: input redirection question
You shouldn't have to do anything at all --- if you post a simple program that you believe should work you will get more help. -Kevin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Eisengrein Sent: Friday, April 04, 2003 2:01 PM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: input redirection question Does it truly need to be redirected, or can you just use @ARGV ? -Original Message- From: Bernard Golden [mailto:[EMAIL PROTECTED] Sent: Friday, April 04, 2003 1:17 PM To: [EMAIL PROTECTED] Subject: input redirection question I want to enable my program to read from STDIN via input redirection, e.g.: myprogram < getstuff When I try it on my machine the program does not see the input. Is there something I should be configuring my machine with to enable it to see redirected input? Many thanks. Bernard Golden ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: input redirection question
Does it truly need to be redirected, or can you just use @ARGV ? -Original Message-From: Bernard Golden [mailto:[EMAIL PROTECTED]Sent: Friday, April 04, 2003 1:17 PMTo: [EMAIL PROTECTED]Subject: input redirection question I want to enable my program to read from STDIN via input redirection, e.g.: myprogram < getstuff When I try it on my machine the program does not see the input. Is there something I should be configuring my machine with to enable it to see redirected input? Many thanks. Bernard Golden
RE: Perl OO Question: subclass using parent object's methods, not overridden methods?
Thanks James, Tobias, Roger, and Randy, for your advice. In summary, creation of a "Formatter" object that acts upon a Table object seems to be the Right Thing to do. I will create an abstract base class "My::Table::Formatter" that is to be subclassed by My::Table::Formatter::HTML and other "plugins", and these plugins will implement an interface with a single format() method that acts on a My::Table. And since all the plugins implement the same interface, I can hide this additional complexity from the My::Table module user by creating a loader like James proposed. Does what I want it to do in proper OO fashion! Thanks again all. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Sent: Friday, April 04, 2003 11:37 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: Perl OO Question: subclass using parent object's > methods, not ove rridden methods? > > > > -Original Message- > > From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] > > Sent: Friday, April 04, 2003 11:28 AM > > To: Tillman, James; Thomas, Mark - BLS CTR; > > [EMAIL PROTECTED] > > Subject: RE: Perl OO Question: subclass using parent > object's methods, > > not ove rridden methods? > > > > > > > I think, perhaps, a little better description of > > > what you're > > > trying to accomplish with all this OOP might help others give > > > you better > > > advice. Maybe a high-level description of what's desired and > > > what made you try OO in the first place? > > > > OK, let me back up a little and give you some background. > > > > [...] > > > > > Seemed straightforward at first, but the problem I'm running > > into is that > > the html() method refers to a few "private methods" > > ($self->_encode($str)) > > that are My::Table object methods. When I move this into > > Table::Formatter::HTML, the $self still refers to My::Table > > unless I first > > bless($self) into Table::Formatter::HTML. > > > > Does this help? > > Yes. But it basically confirms what I thought you were > trying to do. The solution that offered to you previously > should work just fine for this. The "plugins" you are > talking about would be your "My::Table::HTML" module and the > ASCII and PDF ones. The suggestion from someone else on this > list to use a common base class for these was a very good > one. I've done just this kind of thing before and it works > beautifully. > > Instead of having the My::Table object contain the encoding > logic for the strings, you MUST move that code into your > formatter objects, since ASCII, HTML, and PDF all have > different requirements. They must take responsibility for > their own encoding. So your code would look like this in the > $formatter->format($table_object) method call: > > $self->_encode($str); > > But $self will refer to the My::Table::HTML object this time, > not My::Table. Of course, the $str variable will have to be > populated by pulling the data out of the My::Table object. > > Essentially, My::Table becomes a container object for the > data, and the formatter objects encapsulate the knowledge of > how to create various document types with the data by > traversing the My::Table data structure. Adding the quirky > loading mechanism that I provided just gives you a > convenience mechanism for choosing which plugin to use. You > could just as easy do this in your code: > >my $formatter = new My::Table::PDF(); >$formatter->format($table_object); > > Is this making any sense yet? :-) > > jpt > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
input redirection question
I want to enable my program to read from STDIN via input redirection, e.g.: myprogram < getstuff When I try it on my machine the program does not see the input. Is there something I should be configuring my machine with to enable it to see redirected input? Many thanks. Bernard Golden
Re: What is wrong here (finding zero sized file )...
On Thu, 3 Apr 2003, Daniel Gross wrote: > Hello, > > I am trying to find all files that have zero size, but it doesn't work > -- why? > > > my @tmpArray = glob("$dirName/*.tif"); > my @zeroFiles = getZeroSizeTiffs(@tmpArray); > > sub getZeroSizeTiffs { > my (@tiffFiles) = @_; > > my @zeroFiles = grep { -z $_ } @tiffFiles; > > return @zeroFiles; > } > My guess is that the $dirName is giving you problems. Since you glob'ed with a directory name, my guess is that the list returned by the glob was just filenames, without the directory prepended. Try this for your grep and see if it works: my @zeroFiles = grep { -z "$dirName/$_" } @tiffFiles; [EMAIL PROTECTED] All opinions are my own and not necessarily those of my employer ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Perl OO Question: subclass using parent object's methods, not ove rridden methods?
> -Original Message- > From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] > Sent: Friday, April 04, 2003 11:28 AM > To: Tillman, James; Thomas, Mark - BLS CTR; > [EMAIL PROTECTED] > Subject: RE: Perl OO Question: subclass using parent object's methods, > not ove rridden methods? > > > > I think, perhaps, a little better description of > > what you're > > trying to accomplish with all this OOP might help others give > > you better > > advice. Maybe a high-level description of what's desired and > > what made you try OO in the first place? > > OK, let me back up a little and give you some background. > [...] > > Seemed straightforward at first, but the problem I'm running > into is that > the html() method refers to a few "private methods" > ($self->_encode($str)) > that are My::Table object methods. When I move this into > Table::Formatter::HTML, the $self still refers to My::Table > unless I first > bless($self) into Table::Formatter::HTML. > > Does this help? Yes. But it basically confirms what I thought you were trying to do. The solution that offered to you previously should work just fine for this. The "plugins" you are talking about would be your "My::Table::HTML" module and the ASCII and PDF ones. The suggestion from someone else on this list to use a common base class for these was a very good one. I've done just this kind of thing before and it works beautifully. Instead of having the My::Table object contain the encoding logic for the strings, you MUST move that code into your formatter objects, since ASCII, HTML, and PDF all have different requirements. They must take responsibility for their own encoding. So your code would look like this in the $formatter->format($table_object) method call: $self->_encode($str); But $self will refer to the My::Table::HTML object this time, not My::Table. Of course, the $str variable will have to be populated by pulling the data out of the My::Table object. Essentially, My::Table becomes a container object for the data, and the formatter objects encapsulate the knowledge of how to create various document types with the data by traversing the My::Table data structure. Adding the quirky loading mechanism that I provided just gives you a convenience mechanism for choosing which plugin to use. You could just as easy do this in your code: my $formatter = new My::Table::PDF(); $formatter->format($table_object); Is this making any sense yet? :-) jpt ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Perl OO Question: subclass using parent object's methods, not ove rridden methods?
> I think, perhaps, a little better description of > what you're > trying to accomplish with all this OOP might help others give > you better > advice. Maybe a high-level description of what's desired and > what made you try OO in the first place? OK, let me back up a little and give you some background. I have a Table class, with Header and Row subclasses. These are true object classes. You can create a Header object and add it to a Table object. You can add a Header object to another Header object, which allows you to create a header "tree". Ditto for Row objects. These relationships are critical for creating section 508 compliant HTML tables. In the Table module, I have a method html(). This is an object method, as you can print $Table->html(); and it outputs a nice xHTML/Section 508-compliant table. This has been working fine for a while now. I want to expand on it now and add other output formats such as text() and pdf(). Even though these are Table object methods, including these in the Table module would be messy. So I'd like to split it up and have these methods in separate files. In fact, I'd like to separate it so completely that the Table object doesn't know/care what output methods it has--it just require()s the requested method at runtime. This has the added advantage that it is modular (think "plugins")--if you only wanted the html() method, you don't have to have the others installed. Seemed straightforward at first, but the problem I'm running into is that the html() method refers to a few "private methods" ($self->_encode($str)) that are My::Table object methods. When I move this into Table::Formatter::HTML, the $self still refers to My::Table unless I first bless($self) into Table::Formatter::HTML. Does this help? -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Perl OO Question: subclass using parent object's methods, not ove rridden methods?
> -Original Message- > From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] > Sent: Friday, April 04, 2003 10:42 AM > To: Tillman, James; Thomas, Mark - BLS CTR; > [EMAIL PROTECTED] > Subject: RE: Perl OO Question: subclass using parent object's methods, > not ove rridden methods? > > > > use My::Table; > > $T = new My::Table; > > # here would be methods to fill the table with data > > $T->title("Test"); > > # output the table > > $T->output('HTML'); > > > > # in package My::Table > > > > sub output { > > my($self, $format_method) = @_; > > # this dynamically loads and instantiates the correct formatter > > object. If you pass in "HTML", you get a > > # My::Table::HTML object, etc. > > require "My/Table/" . $format_method . ".pm"; > > my $formatter = "My::Table::$format_method"->new(); > > #note that the > > formatter class must have a constructor named > >#"new" > > $formatter->dostuff(); > > } > > I am doing something similar (I'm exec()ing a 'use' instead > of require. > Require is probably cleaner). > > But what I _can't_ do is "My::Table::$format_method"->new(); > because the > object I want to dostuff() with is the existing My::Table > object, not a new > object from the sub-package. > I'm not sure what dostuff() is supposed to do, so I might have misinterpreted what its purpose was. I thought it was supposed to print out the table contents as either ASCII or HTML, depending on what the formatter was. If you want My::Table to be the one to "dostuff()", then by all means, replace this line: $formatter->dostuff($self); with this one: $formatter->format($self); And then have My::Table::HTML's format() method look like this: sub format { my ($self, $table) = @_; $table->dostuff(); # Then do what you gotta do to print the thing out } I don't see that OOP will have any problem with what you're trying to do. It's not like people haven't been designging this same kind of abstraction for years. I think, perhaps, a little better description of what you're trying to accomplish with all this OOP might help others give you better advice. Maybe a high-level description of what's desired and what made you try OO in the first place? jpt ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Perl OO Question: subclass using parent object's methods, not ove rridden methods?
> It's necessary because by calling "bless" you are doing what > should have > been done in the missing object constructor I mentioned > above. You are > taking the reference and placing it in a different namespace (the > My::Table::HTML namespace). Once you've done that, calls to > the object will > search the new namespace for methods, and hence your > dostuff() method is discovered. Is there anything wrong with this (other than calling it a subclass :) ? > I think someone else mentioned that you are probably not > really wanting a > subclass. I believe he is correct. Yep, I used misleading terminology. I'm not really looking for a subclass. > It appears that you > could probably be > working on something like this: > > use My::Table; > $T = new My::Table; > # here would be methods to fill the table with data > $T->title("Test"); > # output the table > $T->output('HTML'); > > # in package My::Table > > sub output { > my($self, $format_method) = @_; > # this dynamically loads and instantiates the correct formatter > object. If you pass in "HTML", you get a > # My::Table::HTML object, etc. > require "My/Table/" . $format_method . ".pm"; > my $formatter = "My::Table::$format_method"->new(); > #note that the > formatter class must have a constructor named >#"new" > $formatter->dostuff(); > } I am doing something similar (I'm exec()ing a 'use' instead of require. Require is probably cleaner). But what I _can't_ do is "My::Table::$format_method"->new(); because the object I want to dostuff() with is the existing My::Table object, not a new object from the sub-package. > I really recommend you read the perltoot man page for more info on > subclassing. It may help clear things up. OO in Perl is > great and powerful > stuff, but it's not as structured (i.e., _regimented_) as > most other OO > languages, so it's easy to misunderstand what needs to be > done. Believe me, I've reviewed and re-reviewed perltoot, but it just doesn't cover what I'm trying to do. > In this > case, however, it appears to be a case of the wrong tool for > the job. A > subclass is not necessarily what you want. I'm in agreement here. I just don't know if there's a "proper" OO way to do what I'm trying to do. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Another defining variables question.
Hello World! I'm using Tk for a GUI, and I have a menu item that opens an instructions window. If I already have the instructions window opened somewhere, I want to bring it to the foreground, rather than opening another window. To this end, I can only see this way of doing it. First, near the beginning of the script, define an empty $instructions variable. Then at the start of my instructions routine, have the following... sub instructions { if (Exists($instructions)) { $instructions -> deiconify; $instructions -> raise; return; } else { $instructions = $main_window -> Toplevel (); } ... Is there a way of doing this without defining a global variable? I tried... sub instructions { if (defined ($instructions)) { $instructions -> deiconify; $instructions -> raise; return;} else { my $instructions etc... but, I got an error, "Variable "$instructions" is not imported..." Thanks. R. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: HTML forms to a file
Lawrence F. Durfee wrote: Cameron wrote: In the old days (literally, last year), installing a web server on Window$ WAS a big deal. But not anymore. ... download the latest >> Apache 2.0 server binary (2.0.44?) for Window$, ... Cameron, I am using a very capable Pentium based PC running Win2k (a very incapable OS... enough said) and so your suggestion of installing a server is something I could do. I looked at the site you suggested but after a quick review, I found that there is a major problem with ZoneAlarm, something I use and like, and I therefore decided not to install that server. Could you please elaborate? I'm sure there are plenty of people running web servers and Zone Alarm together, and I can't figure out what your problem might be. If you run a web server, you have to leave some port (usually 80) open, but I'm also sure you can set Zone Alarm to ignore that port. You can also set up your server so that it will only run as localhost, so no one else can get into it. I am only about a third of the way through Lincoln Stein's book "Network Programming with Perl" when I realized that I can write a simple server, in Perl, that will suit my purposes. Great! But, what does this do that Apache doesn't in terms of your Zone Alarm problem? You've still got port 80 open, don't you? Note: If you can do everything you want this way and don't have to install Apache or some other web server, that's fine. I installed Apache on my personal machines (localhost access only) mainly because I wanted to simulate exactly anything I do on the department server I run. Randal Schwartz also wrote a perl-based web server that he discussed in a Web Techniques column, which you might want to take a look at, if only because it's AWTDI. http://www.stonehenge.com/merlyn/WebTechniques/col56.html Cameron -- Cameron Dorey Associate Professor of Chemistry University of Central Arkansas Phone: 501-450-5938 [EMAIL PROTECTED] If you have received this communication, please contact the local HAZMAT team and delete the material from your computer. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: counting files with a certain extension
opendir(DIR, "path_to_/logon/input/") or die "\nCannot open Dir to read.\nError: $!"; my @contents = readdir DIR; closedir(DIR); my @log_files = grep (/\.log$/) @contents; foreach (@log_files) { rename("path_to_/login/inputs/$_", "path_to_/logon_logs/$_"); print "Moved: path_to_/login/inputs/$_\nTo: path_to_/logon_logs/$_\n\n"; ## # Note: please read the doc's on rename. This is just a sample on one way of doing something. # I'd suggest taking a look at file::copy if rename won't work well for your situation. ## } you can make this into a subroutine really easy, so you can use the code for all kinds of things where you need to move file types...btw, usually your OS also has a tool for this. sub MoveFiles { my ($srsDir, $fileType, $dstDir, $bShowMovement) = @_; opendir(DIR, $stsDir) or die "\nCannot open $srsDir to read.\nError: $!"; my @contents = readdir DIR; closedir(DIR); my @log_files = grep (/$fileType$/) @contents; foreach (@log_files) { rename("$srsDir/$_", "$dstDir/$_"); print "Moved: $srsDir/$_\nTo: $dstDir/$_\n\n" if($bShowMovement); ## # Note: please read the doc's on rename. This is just a sample on one way of doing something. # I'd suggest taking a look at file::copy if rename won't work well for your situation. ## } } Then you can call it: MoveFiles("/path/to/folder/", ".html", "/path/to/put/files/", 0); #Don't show movement print statements. MoveFiles("/path/to/folder/", ".html", "/path/to/put/files/", 1); #Show movement print statements. hth, JY - Original Message - From: "rverven007" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, April 03, 2003 4:42 PM Subject: counting files with a certain extension > I have the following directory structure > > /logon/ > /logon/input > /logon/logs > > in the directory input I got a lot of file and directories. > I need to count the amount of files and directories in the directory > /logon/input/ and move all files with the extension .log to the /logon/logs/ > directory > > Can anyone assist me in setting up this perl script? > > many thanks, Ron > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Perl OO Question: subclass using parent object's methods, not overridden methods?
Yes! In fact I have done just that, although I didn't call it Formatter. I like the name Formatter better, thanks for the idea. Currently it's just an empty namespace, as I don't have any common code (yet) to put in the base class. I do call it on the fly by exec()ing 'use $formatter_name'. But my problem is that the formatter needs to call methods that act on the object, yet I want these methods to remain in the particular Formatter module that has been called, not in the My::Table object which I'd like to keep abstract. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; > -Original Message- > From: Randy W. Sims [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 03, 2003 7:05 PM > To: Thomas, Mark - BLS CTR > Cc: 'Tobias Hoellrich'; [EMAIL PROTECTED] > Subject: Re: Perl OO Question: subclass using parent object's > methods, not overridden methods? > > > On 4/3/2003 4:15 PM, Thomas, Mark - BLS CTR wrote: > >>Huh? Question is: how do you create your > >>"My::Table::HTML/ASCII" objects? > >>What does the constructor look like? > > > > > > I don't. The My::Table::HTML and My::Table::ASCII modules > don't have a > > constructor. I am using the subclasses to perform operations on the > > parent > > (My::Table) object. > > > > My reason for separating them was to separate the model (My::Table) > > from the views. This allows for the creation of a new output (like > > My::Table::PDF) without having to change My::Table. Also, > I'm treating > > those output modules like "plugins" where you only need to > install the > > ones you care about. So this design may be unconventional, but it > > seems to have advantages for me. > > > > So my question boils down to this: Can I override methods > that act on > > the superclass' object, without having to instantiate a new object? > > > > Maybe my re-blessing "workaround" is really the only way to do it. > > It sounds like your design calls for a "uses" relationship. Store a > reference to the correct formatter in your My::Table instance > or create > one on the fly as needed that refers to the correct > formatter. You may > want to rearrange the formatters to have a base class if there is any > common code between the formatters. > > My::Table::Formatter > My::Table::Formatter::HTML > My::Table::Formatter::Text > etc. > > Randy. > > -- > A little learning is a dang'rous thing; > Drink deep, or taste not the Pierian spring; > There shallow draughts intoxicate the brain; > And drinking largely sobers us again. > - Alexander Pope > > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Perl OO Question: subclass using parent object's methods, not overridden methods?
> At 04:15 PM 4/3/2003 -0500, Thomas, Mark - BLS CTR wrote: > >So my question boils down to this: Can I override methods > that act on > >the superclass' object, without having to instantiate a new object? > > And my question in response: Didn't my attached code accomplish that? Your code instantiated a My::Table::HTML object. This is normal OO, and in fact I do something similar with My::Table::Header and My::Table::Row subclasses (that is, I instantiate their objects and add them to the table). I omitted them from my original description for simplicity. But I'm treating these "output classes" differently. A My::Table object will already be built. I don't want My::Table to know about My::Table::HTML or any other output method until the method is called on a My::Table object. In other words, I want them to act like My::Table object methods, but I want to separate them into (optional) modules. Perhaps I shouldn't have called them "subclasses" as they do not represent a different object. Is this making sense? Perhaps there's a better way to do it. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: HTML forms to a file
Cameron wrote: >Date: Wed, 02 Apr 2003 14:56:38 -0600 >From: Cameron Dorey <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Re: HTML forms to a file > >Lawrence F. Durfee wrote: >> Cameron Dorey wrote: >> >>>Just have your form ACTION be a small perl script which writes your >>>input to a file. In order to do this, you have to know how to set up >>>your web server for CGI (outside the scope of this mailing list) and >>>some simple Perl (not PERL). >> >> Cameron, >> >> Thanks for the response and I did spend some time looking at the >> sites you suggested. However, I could be wrong, but installing a web >> server seems like a big deal and it also seems like a huge overkill just >> to get some data out of an HTML form (I expect most of my forms to be >> somewhat small). > >In the old days (literally, last year), installing a web server on >Window$ WAS a big deal. But not anymore. Assuming you have a capable >computer (at least 200 MHz Pentium or equiv., 64 MB RAM - 128 is better, >WinNT, Win2K, WinXP - you could even go with Win98 if your situation is >simple and secure, i.e., an intranet with little chance of more than one >person entering data simultaneously), the procedure is this: (1) bop on >over to www.apache.org and download the latest Apache 2.0 server binary >(2.0.44?) for Window$, (B) double-click on the downloaded file, (III) >follow the directions from the Installation Wizard, which mostly consist >of you telling where you want to put your web server files. The most >time-consuming part is the download. > >If you haven't installed Perl, I would advise getting the latest 5.6 >build (5.6.633?), since there seem to be too many things still missing >from the 5.8 build (from reading this mailing list) to make it really >easy to use if you decide to get fancy and install a bunch of modules. > >> >> I looked at CGI (as you suggested), ASP and Windows script hosting, >> but it is not clear to me how to make any of them work. > >Lincoln Stein's CGI.pm module which comes with core Perl makes using the >CGI interface an absolute breeze. There are even a bunch of examples for >doing useful stuff and the documentation is truly voluminous. I haven't >done any ASP or WSH stuff, never had the need for it. > >> Just for the >> fun of it, I also tried replacing 'mailto:' with 'file:', but I >> couldn't make that work either. > >Nope, it won't. You need a web server. > >One thing about PC's nowadays, they are SO cheap and SO fast and SO >capable (IMHO, due to M$ bloatware pushing the hardware, thank you , >Bill), that it is pretty much impossible to find one manufactured within >the last 3 years which will NOT run a webserver and 20 other >applications without breaking a sweat. > >Cameron > > >Emails cannot be guaranteed to be secure or free of errors, viruses, >bacteria, fungi, prions, or the heartbreak of psoriasis. The sender >does not accept any liability or responsibility for any interception, >corruption, destruction, loss, late arrival or incompleteness of or >tampering or interference with this email or for its incorrect delivery >or non-delivery for whatsoever reason or its effect on any electronic, >magnetic, mechanical, biological, or metaphysical device of the recipient. > > >-- >Cameron Dorey >Associate Professor of Chemistry >University of Central Arkansas >Phone: 501-450-5938 >[EMAIL PROTECTED] Cameron, I am using a very capable Pentium based PC running Win2k (a very incapable OS... enough said) and so your suggestion of installing a server is something I could do. I looked at the site you suggested but after a quick review, I found that there is a major problem with ZoneAlarm, something I use and like, and I therefore decided not to install that server. I am only about a third of the way through Lincoln Stein's book "Network Programming with Perl" when I realized that I can write a simple server, in Perl, that will suit my purposes. Within thirty minutes, I had the web server up and running. I will now focus on the issue of implementing the `POST` feature into the server code. I believe Mr. Stein should be praised for his fine work on books and contributions of Perl modules. I would highly recommend the book and the use of any Perl module he develops. I have been using Perl for about four (4) years now and it is nothing less than fantastic. The language is very elegant and allows one to develop code quickly. A premier feature, I believe, is the fact that one can find modules (*.pm) on almost any subject (networking, algorithms, etc.) from a variety of different sources. Furthermore, the ease with which modules are installed and used (POD documentation and so on) is phenomenal. I applaud the efforts of ActiveState to provide the basic Perl package, the web site for the module repository and this very forum. I hope they are able to continue this effort as I think it will continue to significantly advance the state of the art. T
RE: preventing IE windows from being grabbed by popups
Click on IE's Tools->Internet Options menu option, which will bring up a dialog box. in the "Advanced" tab, you will find a "Reuse windows for launching shortcuts" option. (This used to be called "Browse in a new process", so depending on your IE version, it may vary). Check this box, and IE will open a new window for each popup and won't try to reuse old windows. Hope this helps! jpt -Original Message-From: Thomas Drugeon [mailto:[EMAIL PROTECTED]Sent: Friday, April 04, 2003 5:11 AMTo: [EMAIL PROTECTED]Subject: OLE: preventing IE windows from being grabbed by popups Hello, I am controlling an IE windows with OLE, but surfing on the web in the same time cause this windows to be grabbed on every popup window. Is their a solution to prevent my IE windows from being kidnapped like this? Thanks, Thomas
RE: Perl OO Question: subclass using parent object's methods, not ove rridden methods?
> -Original Message- > From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 03, 2003 3:01 PM > To: [EMAIL PROTECTED] > Subject: Perl OO Question: subclass using parent object's methods, not > ove rridden methods? > > > I have a module, let's call it My::Table, which represents a > data table. In > order to simplify maintenance, I have separated output functions into > subclasses called My::Table::HTML and My::Table::ASCII. > > One would use the module like this: > > use My::Table; > $T = new My::Table; > # here would be methods to fill the table with data > $T->title("Test"); > # output the table > $T->output('HTML'); > > Fairly standard stuff, except for the last line. The output() > method exec's > the appropriate subclasses' output method. So in the above > output method, > the method My::Table::HTML::output receives a My::Table > object. So far, so > good. I have the following in My::Table::HTML: Actually, not "so far so good." This is why things aren't working properly for you. My::Table::HTML::output should be receiving a My::Table::HTML object, not a My::Table object. It's a subclass of My::Table. So when you call one of its methods, it should receive an object that is, at the same time, an instance of both of those classes (through inheritance, of course). > # this is an excerpt from My::Table::HTML > use My::Table; > @ISA=qw('My::Table'); > > sub output { > my $self = shift; > $self->dostuff(); > } > > sub dostuff { > my $obj = shift; > #... > } > > Here's the problem: the dostuff() method only works if I > define the method > in the parent, My::Table. It is not seen at all in My::Table::HTML. I > thought that this was considered an "overridden method" and > perl would look > for it in the subclass. "Overridden" methods only apply to objects, and this PM file you just posted is not an example of an object class. If it were, it would have a constructor that looked like this: sub new { my($class, %attribs) = @_; my $self = {}; return bless => $self; } But you have no constructor, so whatever object you're dealing with is NOT a My::Table::HTML object, and thus doesn't have that method you are talking about. > I have a workaround. In the subclass I modified the output method as > follows: > sub output { > my $self = shift; > bless $self;#why is this necessary? > $self->dostuff(); > } > > But I don't know why it is necessary. It's necessary because by calling "bless" you are doing what should have been done in the missing object constructor I mentioned above. You are taking the reference and placing it in a different namespace (the My::Table::HTML namespace). Once you've done that, calls to the object will search the new namespace for methods, and hence your dostuff() method is discovered. I think someone else mentioned that you are probably not really wanting a subclass. I believe he is correct. It appears that you could probably be working on something like this: use My::Table; $T = new My::Table; # here would be methods to fill the table with data $T->title("Test"); # output the table $T->output('HTML'); # in package My::Table sub output { my($self, $format_method) = @_; # this dynamically loads and instantiates the correct formatter object. If you pass in "HTML", you get a # My::Table::HTML object, etc. require "My/Table/" . $format_method . ".pm"; my $formatter = "My::Table::$format_method"->new(); #note that the formatter class must have a constructor named #"new" $formatter->dostuff(); } If you really want subclasses, you'll have to instantiate the specific subclass you want _instead of_ the My::Table object each time. The above code provides a workaround that lets you decide which formatter to use at runtime, instead at development time. I hope I didn't make this too confusing! I really recommend you read the perltoot man page for more info on subclassing. It may help clear things up. OO in Perl is great and powerful stuff, but it's not as structured (i.e., _regimented_) as most other OO languages, so it's easy to misunderstand what needs to be done. In this case, however, it appears to be a case of the wrong tool for the job. A subclass is not necessarily what you want. jpt ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Bitmap on a Button, Bitmap not displaying
At 06:31 2003-04-04 -0500, Stuart Arnold wrote: It prints out that the $img and $bname are all ok,eg they exist and that $img has a value. I'm using ActiveState PERL 560. The window displays and shows a blank button. The bitmap is 20x20 and I've put the width/height to be 100,100 to see if thats the problem. This is a trycky one that bit me too at first. The variable that holds the bitmap must not go out of scope during the lifetime of the button (which probably is the lifetme of the program). This should ideally be handled automatically by Win32::GUI, but isn't. One simple way of doing that is to: - my @bitmap; sub winCreate { #... $img = new Win32::GUI::Bitmap( $bname ) push(@bitmap, $img); #... } - For each bitmap you use. /J -- --- -- -- -- -- - - - Johan LindströmSourcerer @ Boss Casinos [EMAIL PROTECTED] Latest bookmark: "Open Source in Government" http://use.perl.org/comments.pl?sid=12076&cid=18699 dmoz (1 of 5): /Business/Industries/Publishing/Publishers/ 14 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Removing all \n in a text file.
If all you need to do is seperate the array with spaces, you could use the following code snippet: $" = ' '; print FILE "@array"; The $" variable is the list seperator special variable. This may be faster than doing the join. Troy - Original Message - From: "Daniel Gross" <[EMAIL PROTECTED]> To: "'Scot Robnett'" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, April 02, 2003 13:58 Subject: RE: Removing all \n in a text file. > Perl is amazing ... Reminds me of lisp where 4-5 of heavily recursive > lines do it all ... Just, thank G-d, its not heavily recursive :-) > > > Thanks > > Daniel > > > -Original Message- > From: Scot Robnett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 02, 2003 1:46 PM > To: Daniel Gross > Cc: [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > chomp(@ary); > print FILE join (' ', @ary); > > Scot R. > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Daniel Gross > Sent: Wednesday, April 02, 2003 12:45 PM > To: 'Scot Robnett' > Cc: [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > Hi Scott, > > Actually, it turns out that sometimes I need to chomp a \n but also add > a space instead (to not concatenate the strings at the end of one line > with the one in the beginning of the next line. > > Which, I guess rules out the short version :-) > > Thanks > > Daniel > > > -Original Message- > From: Scot Robnett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 02, 2003 1:30 PM > To: Carl Jolley > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > See, I told you somebody would follow with a shorter and cleaner > example. > :-) > > Scot R. > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Carl Jolley > Sent: Wednesday, April 02, 2003 12:17 PM > To: Scot Robnett > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > On Mon, 31 Mar 2003, Scot Robnett wrote: > > > That seems like a lot of work when you could just do something like > > what's shown below. And I'm sure someone is going to follow with > > something > shorter > > and cleaner than this one, but it's a start. I did test it and it > > worked. > > > > > > #!C:\Perl\bin\perl.exe -w > > > > use strict; > > my $file = 'C:\path\to\file.txt'; > > my @ary = (); > > > > open(FILE, "<$file"); > > @ary = ; > > close(FILE); > > > > open(FILE, ">$file"); > > for(@ary) { > > chomp; > > print FILE $_; > > } > > close(FILE); > > > > print "Newlines removed. \n"; > > > > > > > > # > > This was the file before: > > # > > line1 > > line2 > > line3 > > line4 > > line5 > > line6 > > line7 > > line8 > > line9 > > line10 > > > > > > # > > This was the file after: > > # > > line1line2line3line4line5line6line7line8line9line10 > > No need to use a loop to chomp and print each line, instead: > > chomp(@ary); > print FILE @ary; > > [EMAIL PROTECTED] > All opinions are my own and not necessarily those of my employer > > > ___ > Perl-Win32-Users mailing list [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > -Original Message- > From: Scot Robnett [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 02, 2003 1:30 PM > To: Carl Jolley > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > See, I told you somebody would follow with a shorter and cleaner > example. > :-) > > Scot R. > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Carl Jolley > Sent: Wednesday, April 02, 2003 12:17 PM > To: Scot Robnett > Cc: Daniel Gross; [EMAIL PROTECTED] > Subject: RE: Removing all \n in a text file. > > > On Mon, 31 Mar 2003, Scot Robnett wrote: > > > That seems like a lot of work when you could just do something like > > what's shown below. And I'm sure someone is going to follow with > > something > shorter > > and cleaner than this one, but it's a start. I did test it and it > > worked. > > > > > > #!C:\Perl\bin\perl.exe -w > > > > use strict; > > my $file = 'C:\path\to\file.txt'; > > my @ary = (); > > > > open(FILE, "<$file"); > > @ary = ; > > close(FILE); > > > > open(FILE, ">$file"); > > for(@ary) { > > chomp; > > print FILE $_; > > } > > close(FILE); > > > > print "Newlines removed. \n"; > > > > > > > > # > > This was the file before: > > # > > line1 > > line2 > > line3 > > line4 > > line5 > > line6 > > line7 > > line8 > > line9 > > line10 > > > > > > # > > This was the file after: > > # > > line1line2line3line4line5line6line7line8line9line10 > > No need to use a loop to chomp and print each line, instead: > >
Bitmap on a Button, Bitmap not displaying
Title: Message I've been trying to use Win32::GUI:Bitmap() and to no success. Here's the code sniplet: ...mainwindow built before this... my ($img, $btn, $bname); $bname = "listbox.bmp"; print "bitmap is $bname\n"; if( -e $bname ) { $img = new Win32::GUI::Bitmap( $bname ) || die "Error: $bname $!\n"; } else { warn "Bitmap file $bname does not exist, skipping it!\n";return 0; } $btn = $winTool->AddButton( -text => "BTN", -name => "button", -bitmap => $img, -top => 25, -left => 25, -width => 25, -height => 25, ); $btn->SetImage( $img ); It prints out that the $img and $bname are all ok,eg they exist and that $img has a value. I'm using ActiveState PERL 560. The window displays and shows a blank button. The bitmap is 20x20 and I've put the width/height to be 100,100 to see if thats the problem. thanks, -Stuart My opinions are my own and only stated at the top of large water towers...
OLE: preventing IE windows from being grabbed by popups
Hello, I am controlling an IE windows with OLE, but surfing on the web in the same time cause this windows to be grabbed on every popup window. Is their a solution to prevent my IE windows from being kidnapped like this? Thanks, Thomas