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
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
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
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
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
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
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
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
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
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
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
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
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|#))
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
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
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
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
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
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
--
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
[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
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
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
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
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 =
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;
> >
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
> 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
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
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
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;
>
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
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
[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,
[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
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
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
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
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
"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->
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
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
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
[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
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
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
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
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
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
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
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 =
"">
> "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
52 matches
Mail list logo