Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
Rob Richardson wrote: > Greetings! Hi Rob. > I have the following class in a .pm file: > > use warnings; > use strict; > package ScheduleDay; > > use Train; > > sub new > { > my $self = {}; # $self is a reference to an anonymous, empty (for now) hash > bless $self; > return $self; N

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
This is a repost, to correctly start a new thread. Apologies to all for the duplication. /R Rob Richardson wrote: > Greetings! Hi Rob. > I have the following class in a .pm file: > > use warnings; > use strict; > package ScheduleDay; > > use Train; > > sub new > { > my $self = {}; # $self

Re: How can I check the size of a file

2003-03-20 Thread Rob Dixon
Giarrocco, Camillo wrote: > Hi, > > Can anybody tell me how can I check the size of a file? > > I know the "if (-s "file") function but never used and don't know the > right syntax of it. Well it's just that really. But you can do more than just test it for being non-zero with 'if'. my $size

Re: How can I check the size of a file

2003-03-20 Thread Rob Dixon
Hello Camillo It seems you're not too well versed with Perl? Giarrocco, Camillo wrote: > Rob, > > Thank You for your replay. > > Let's say I want check if a file is not less then 1 bytes > I would do then: > > $size = "1"; This will work, but "1" is a string, whereas you really mean

RE: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread wiggins
On Wed, 19 Mar 2003 20:02:20 -0800 (PST), Rob Richardson <[EMAIL PROTECTED]> wrote: > Greetings! > > I have the following class in a .pm file: > > use warnings; > use strict; > package ScheduleDay; > > use Train; > > sub new > { > my $sel

RE: Class using a class: "new" confusion and strange print behavi or

2003-03-20 Thread Bob Showalter
Rob Richardson wrote: > Greetings! > > I have the following class in a .pm file: > > use warnings; > use strict; > package ScheduleDay; > > use Train; > > sub new > { > my $self = {}; # $self is a reference to an anonymous, empty (for > now) hash > bless $self; > return $self

RE: Class using a class: "new" confusion and strange print behavi or

2003-03-20 Thread Rob Richardson
Greetings! Thanks to all of you for your thoughts. I like Rob's idea of ORing $_[0] with 'The Little Engine That Could'. I'll try that. I'm pretty darn sure that Train.pm has a line that says "package Train;", but I'll double-check. A bit of background: This program will eventually be used

Unix ls -lrt | tail -1 in Perl

2003-03-20 Thread NYIMI Jose (BMB)
Hello, How can I do this unix command in Perl ? : ls -lrt | tail -1 Actually, i would like to get the most recent file from a given directory. Thanks in advance for your input. José. DISCLAIMER "This e-mail and any attachment thereto may contain information which is confidential

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
Rob Dixon wrote: > > When I run perl -c on this, I get the following messages: > > Subroutine new redefined at Train.pm line 106. > > It's telling you that you have two definitions of ScheduleDay::new. > Presumably Train.pm has no 'package Train;' statement? Wiggins' post got me to think a little

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread wiggins
On Thu, 20 Mar 2003 14:06:56 -, "Rob Dixon" <[EMAIL PROTECTED]> wrote: > Rob Dixon wrote: > > > When I run perl -c on this, I get the following messages: > > > Subroutine new redefined at Train.pm line 106. > > > > It's telling you that you hav

Re: Unix ls -lrt | tail -1 in Perl

2003-03-20 Thread Sudarshan Raghavan
On Thu, 20 Mar 2003, NYIMI Jose (BMB) wrote: > Hello, > > How can I do this unix command in Perl ? : ls -lrt | tail -1 > Actually, i would like to get the most recent file from a given directory. my $latest = (sort {-M $b <=> -M $a} <$dir/*>)[-1]; or my $latest; while (<$dir/*>) { $lates

next if........ a cleaner way?

2003-03-20 Thread chad kellerman
Hello everyone, I want to clean this bit of code up. It looks really messy. I am in a mental block. Any suggestions? @userInfo = split /\s+/, $buffer; #insert home users & quota in the db foreach $userInfo ( @userInfo ) { ( $name, $quota ) = split /\|/, $user

RE: next if........ a cleaner way?

2003-03-20 Thread Hanson, Rob
This should work... next if $name =~ /Block|nobody|User|www|backup|ftp|httpd|root|netop|sysop|users|bill/; next if $name =~ /^(?:\d|#)/; next if $quota !~ /\d+/; next if $quota <= 8; You should also be able to combine the two (just make sure you test my syntax)... next if $name =~ /(?:^(?:\d|#))

RE: Unix ls -lrt | tail -1 in Perl

2003-03-20 Thread Hanson, Rob
If you use the first version that Sudarshan posted, you might want to use this instead. It uses map, and is a lot faster. my $latest = (sort {$b->{mtime} <=> $a->{mtime}} map {{mtime => -M $_, file => $_}} <$dir/*>)[-1]; print $latest->{file}, "\n"; Benchmark results w

Multi-OS script

2003-03-20 Thread beau
Hi folks, I am trying to write a simple 'status' script that will run as a simple server on each machine on a diverse network (there are >400 machines of all types, OSs and flavors); when queried the script will resopond (proving that machine is up) with machine name, ipaddr, disk usage, and so on

Re: why objects?

2003-03-20 Thread Paul Johnson
On Thu, Mar 06, 2003 at 10:25:57AM -0800, Paul wrote: > I'm sold -- I write most code as object modules now. > > My coworkers aren't interested in dealing > with the learning curve for objects, and don't care to hear about it. I think you have bigger problems than t

Re: next if........ a cleaner way?

2003-03-20 Thread Rob Dixon
Hi Chad. Chad Kellerman wrote: > Hello everyone, > > I want to clean this bit of code up. It looks really messy. I > am in a mental block. Any suggestions? > > @userInfo = split /\s+/, $buffer; Use a single space here to split on. @userInfo = split ' ', $buffer; It's a special case

%HASHES/Associative Arrays To receive input

2003-03-20 Thread Horace Franklin Jr.
Clear DayHello, I would like to use %HASHES/Associative arrays to accept input from a form generated within a perl script. The normal input of a html form is print " \n"; Is the syntax when using Hashes: my %hashes; print ""\n; Also what is the syntax is you want to input checkboxes with the sa

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread R. Joseph Newton
Rob Dixon wrote: > > When I run perl -c on this, I get the following messages: > > Subroutine new redefined at Train.pm line 106. This can be easily corrected: my $motto = "Where no one has gone before!"; ..and still avoid having that pointless damn number at the end of the module. Joseph --

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread R. Joseph Newton
Rob Richardson wrote: > Greetings! > > I have the following class in a .pm file: > > use warnings; > use strict; > package ScheduleDay; > > use Train; > > sub new > { > my $self = {}; # $self is a reference to an anonymous, empty (for > now) hash > bless $self; > return $s

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > > I was hoping someone would correct me, if you have? ;-) After reading Bob's e-mail > I paid closer attention to the error and thought in terms of compile time rather > than runtime... But I am a bit confused about the order of compiling, does the whole > file get c

Filling out forms on the web.

2003-03-20 Thread Larry Wissink
Hi, I'm a Perl newbie in way over my head, but I love a challenge. My company needs to download transaction data from a partner's website on a regular basis. The data can be retrieved through a form, (entering date ranges, selecting merchants, etc.), but one must log in to the site first and mus

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Richardson
Joseph, Thanks for your comments. Let's see if I can snip this and still come up with intelligible contexts. --- "R. Joseph Newton" <[EMAIL PROTECTED]> wrote: > Rob Richardson wrote: > > > Greetings! > > > > I have the following class in a .pm file: > > > > use warnings; > > use strict; > > pac

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Richardson
Joseph, That's an interesting thought! I'll check tonight. Rob --- "R. Joseph Newton" <[EMAIL PROTECTED]> wrote: > Just a hunch, since the material in question is out of reach, but > could this be a circular reference? It happens a lot when assembling > C headers. If Train.pm by any chance

caller() problems

2003-03-20 Thread Hanson, Rob
I'm using caller() to get the name of the calling package and method, but sometimes the info isn't there. My code looks something like this... # Begin code example ## package main; use ModuleX 'logit'; logit("a message"); package ModuleX; sub logit { my @caller =

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
Hi Joseph. R. Joseph Newton wrote: > Rob Richardson wrote: > > > Greetings! > > > > I have the following class in a .pm file: > > > > use warnings; > > use strict; > > package ScheduleDay; > > > > use Train; > > [snip] 'new' method > > > > sub AddTrain > > { > > my $self = shift; > >

Re: Filling out forms on the web.

2003-03-20 Thread Pete Emerson
Randal Schwartz just wrote an excellent article titled "Screen Scraping for Fun and Profit" in Linux Magazine. His code is available at http://www.linuxmagazine.com/downloads/2003-04/perl, although I recommend reading the article (April 2003 edition), because he walks the code line by line and give

RE: Filling out forms on the web.

2003-03-20 Thread Dan Muey
> Randal Schwartz just wrote an excellent article titled > "Screen Scraping for Fun and Profit" in Linux Magazine. His > code is available at > http://www.linuxmagazine.com/downloads/2003-> 04/perl, although > I recommend reading the article (April > 2003 edition), because he walks the code l

Re: next if........ a cleaner way?

2003-03-20 Thread R. Joseph Newton
chad kellerman wrote: > Hello everyone, > > I want to clean this bit of code up. It looks really messy. I am in a > mental block. Any suggestions? > > @userInfo = split /\s+/, $buffer; > > #insert home users & quota in the db > foreach $userInfo ( @userInfo ) { > > ( $nam

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
R. Joseph Newton wrote: > Rob Dixon wrote: > > > > When I run perl -c on this, I get the following messages: > > > Subroutine new redefined at Train.pm line 106. > > This can be easily corrected: > my $motto = "Where no one has gone before!"; > ..and still avoid having that pointless damn number at

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread R. Joseph Newton
Rob Dixon wrote: [snip] > Yes, but it's > > $schedule_day_object->AddTrain($train_name); > > which does that for you. > > > If that is the case, then your parameter catch would be neater and > > more understandable as: > > my ($self, $trainName) = @_; > > > > or: > > my $self = shift; >

Re: caller() problems

2003-03-20 Thread david
Rob Hanson wrote: > I am guessing the problem is (as stated in the perldoc) that "the > optimizer might have optimized call frames away before "caller" had a > chance to get > the information.". Furthermore it states that ""caller(N)" might not > return > information about the call frame you exp

RE: Class using a class: "new" confusion and strange print behavi or

2003-03-20 Thread Bob Showalter
R. Joseph Newton wrote: > ... > Does any call to a class method then have the reference to the object, > or the object itself, as the first parameter. An "object" is a reference that has been blessed into a class. In a method call, the reference is passed as the first element in @_. So, if $obj i

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > On Thu, 20 Mar 2003 14:06:56 -, "Rob Dixon" > <[EMAIL PROTECTED]> wrote: > > > > > Wiggins' post got me to think a little more carefully, and it is > > clear > > that Train.pm is doing the redefining at its line 106,

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > > I was hoping someone would correct me, if you have? ;-) Although I could make a correction! [EMAIL PROTECTED] wrote: > > Rob's suggestion that you lack a package statement for Train could be > it, it could also be that Train exports 'new', which is placing it in > the

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
R. Joseph Newton wrote: > > Just a hunch, since the material in question is out of reach, but > could this be a circular reference? It happens a lot when assembling > C headers. If Train.pm by any chance has a "use ScheduleDay;" > statement, then that would porobably cause some havoc. In general

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
R. Joseph Newton wrote: > > Thanks. Let me make sure I have this clear, then. Does any call to > a class method then have the reference to the object, or the object > itself, as the first parameter. Almost. Any method called through an object will have that object (a blessed reference) as its fi

Re: Filling out forms on the web.

2003-03-20 Thread Rob Dixon
Hi Larry. I saw the 'Larry W' and, just for a moment, thought we had the man himself here! Larry Wissink wrote: > Hi, > I'm a Perl newbie in way over my head, but I love a challenge. > My company needs to download transaction data from a partner's > website on a regular basis. The data can be re

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread R. Joseph Newton
Rob Dixon wrote: > ... > Yes, but it's > > $schedule_day_object->AddTrain($train_name); > > which does that for you. > > ... > It's a tradition that methods start with: > > my $self = shift; > my ( $trainName, $p1, $p2, $p3, @prest ) = @_; > > to separate the implicit parameter from t

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread R. Joseph Newton
"R. Joseph Newton" wrote: > > But... > > I can do this: > > #!/usr/bin/perl -w > > use strict; > > use Person; > > my $person = Person::new("Newton", "R. Joseph"); > $person->set_address("666 NoSpam way", "Eugene", "OR", "97402", > "USA"); > $person->{'Surname'} = "Johnson"; #this > $person->

Trapping whitespaces between fields in an array

2003-03-20 Thread Gufranul Haque
Hello all, I need to process a record Key1 3.00 4.005.00 I need to trap spaces between nonwhitespace characters as array elements i.e for the above record the resulting array should be (' ',' ','') The staement that I am using my @spaces = map /(\s+)/, $_; is able to trap only t

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Paul Johnson
On Thu, Mar 20, 2003 at 03:46:16PM -0800, R. Joseph Newton wrote: > "R. Joseph Newton" wrote: [ Perl allows you to manipulate an object other than via its interface ] > > Without anything preventing me. I am not at all sure that this is a > > good thing. Is there any way to construct a class so

RE: Trapping whitespaces between fields in an array

2003-03-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Gufranul Haque wrote: > Hello all, > > I need to process a record > > Key1 3.00 4.005.00 > > I need to trap spaces between nonwhitespace characters as array > elements i.e for the above record the resulting array should be > (' ',' ','') > > The staement that I am using > > my @spa

Re: Multi-OS script

2003-03-20 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote: I can encapsulate the uses in a string eval, but then it seems I must put all use of that (thoese) modules into the same string eval, which gets syntatically sticky quickly. Can someone point me to a simple, elegant, perlish solution? Maybe switching to 'require' instead of

Filling out forms on the web. (completed).

2003-03-20 Thread Larry Wissink
Hi, Thanks to everyone for their responses. I am very impressed by how quickly people responded. I'm subscribed to the digest format, so I didn't realize that my complete script didn't get posted until now. (I think it was a paste error on my part.) So, for completeness, in case anyone wanted t

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
Hi Joseph. Well, it's 01:00 here and I really should go to bed, but I'll take a stab at this before I go. R. Joseph Newton wrote: > > > > Well, you goaded me into it. I finally decided to pull the spoon > > off my tongue and try Perl OOP. I must say, it is pretty painless. > > I can get used to

Re: Class using a class: "new" confusion and strange print behavior

2003-03-20 Thread Rob Dixon
R. Joseph Newton wrote: > > Got it! The changes shown below seem to provide the protection I > want. I guess the object hash can be left as a programmer > scratchpad, while the payload remains protected as a private variable No, this is a step backwards I'm afraid! > > package Person; > > > > u

Re: Trapping whitespaces between fields in an array

2003-03-20 Thread Rob Dixon
Gufranul Haque wrote: > Hello all, > > I need to process a record > > Key1 3.00 4.005.00 > > I need to trap spaces between nonwhitespace characters as array > elements i.e for the above record > the resulting array should be > (' ',' ','') > > The staement that I am using > > my @spaces

My own #@$%%# fault (was: "new" confusion)

2003-03-20 Thread Rob Richardson
Greetings! As always happens, it turns out that this whole conundrum was my own fault. There were not one but two pieces of glaring idiocy. First, it turned out that the mysterious Trains.pm file did indeed have two separate methods named new(). Second, I followed up on the suggestion a couple

how to upload image in perl

2003-03-20 Thread Dave
Hai , I have a problem uploading images with perl. I have HTML code within perl. When i just link the image useing the link tag It doesnt work. I tried giving the path ../search.gif. Is there any other way to upload the image. Thanks in advance, - With Y

Fw: Hash/Associtative Array

2003-03-20 Thread Horace Franklin Jr.
I am writing a CGI Script like the guestbook.cgi script.   I want following actions to occur: a. Menu item calls my script (cgi). b. Script displays a menu with four items on it. c. Menu items calls form (sub routine) i.e., sub entry_form {  my $q    = shift;  my $url = "">  

Re: Filling out forms on the web.

2003-03-20 Thread Randal L. Schwartz
> "Pete" == Pete Emerson <[EMAIL PROTECTED]> writes: Pete> Randal Schwartz just wrote an excellent article titled "Screen Scraping Pete> for Fun and Profit" in Linux Magazine. His code is available at Pete> http://www.linuxmagazine.com/downloads/2003-04/perl, although I recommend Pete> reading