[23945] in Perl-Users-Digest
Perl-Users Digest, Issue: 6146 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 17 11:05:50 2004
Date: Tue, 17 Feb 2004 08:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 17 Feb 2004 Volume: 10 Number: 6146
Today's topics:
Re: [MIME] How to attach eMails? <tore@aursand.no>
Re: [MIME] How to attach eMails? <Guru03@despammed.com>
Re: [MIME] How to attach eMails? <jwillmore@remove.adelphia.net>
Re: do not reload anonymous@coolgroups.com
Re: generate a list of file extensions? <me@privacy.net>
Re: generate a list of file extensions? <paul.cooper@Nobasspam.ac.uk>
how to start thread in thread <pawo2000@wp.pl>
Re: how to start thread in thread <usenet@morrow.me.uk>
OOP: Inheriting identically named methods <tore@aursand.no>
Re: OOP: Inheriting identically named methods <usenet@morrow.me.uk>
Re: OOP: Inheriting identically named methods <tore@aursand.no>
Re: OOP: Inheriting identically named methods <usenet@morrow.me.uk>
Re: OPEN( , Get , or slurping problem (Anno Siegel)
Re: OPEN( , Get , or slurping problem <noreply@gunnar.cc>
Re: OPEN( , Get , or slurping problem <usenet@morrow.me.uk>
Perl Graph? (newbie) <bumble@what.the.heck>
Re: Perl Graph? (newbie) <usenet@morrow.me.uk>
Re: Perl Graph? (newbie) <bumble@what.the.heck>
Re: Perl Graph? (newbie) <jwillmore@remove.adelphia.net>
Re: Perl Graph? (newbie) <beable+unsenet@beable.com.invalid>
Re: Perl memory allocation <bernard.el-haginDODGE_THIS@lido-tech.net>
Threadsafe writing to files (Yash)
Re: Threadsafe writing to files <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 17 Feb 2004 13:41:56 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: [MIME] How to attach eMails?
Message-Id: <pan.2004.02.17.12.11.44.112189@aursand.no>
On Tue, 17 Feb 2004 10:52:34 +0000, Guru03 wrote:
>> But have you tried reading the same email message in other email
>> clients than Outlook? I don't trust Outlook when it comes to "does it
>> work when sending an email like this?" stuff. :)
> I verified that Outlook 2000 SP1 has a bug, not viewing correctly the
> email attachments. 2000 (NOT SP1) and 2000 SP3 works.
So it wasn't a Perl (or -related) problem at all? Maybe you should verify
that _your_ application works against other application that _works_ next
time? :)
--
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." -- Sir John Lubbock
------------------------------
Date: Tue, 17 Feb 2004 13:56:25 +0000 (UTC)
From: Guru03 <Guru03@despammed.com>
Subject: Re: [MIME] How to attach eMails?
Message-Id: <Xns9492980F195B9Guru03despammedcom@193.43.96.1>
Tore Aursand <tore@aursand.no> wrote in news:pan.2004.02.17.12.11.44.112189
@aursand.no:
> So it wasn't a Perl (or -related) problem at all?
yes, I discovered that bug just now ;)
------------------------------
Date: Tue, 17 Feb 2004 10:15:08 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: [MIME] How to attach eMails?
Message-Id: <pan.2004.02.17.15.15.06.515094@remove.adelphia.net>
On Tue, 17 Feb 2004 08:42:54 +0000, Guru03 wrote:
> jwillmore@myrealbox.com (James Willmore) wrote in
> news:d61170e5.0402161640.276df4f7@posting.google.com:
>
>>> Ok, but I must return a MIME::Entity object...
>>
>> No, you don't - that's the beauty of using MIME::Lite - no sendmail
>> required :-)
>>
>
> I'm writing a subroutine that MUST return a MIME::entity object, NOT
> MIME::Lite... and it's integrated into an MTA (Postfix, qmail)...
Have you *read* the documentation for MIME::Lite?
http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm
I understand what you're trying to do - send an email with MIME
attachment(s), correct?
Then you *can* use MIME::Lite if this is the case. MIME::Lite uses
Net::SMTP to send email via an MTA - *without* using a command line
application to do it.
I find it easier to send email with MIME attachments using MIME::Lite, but
to each his own.
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Command, n.: Statement presented by a human and accepted by a
<computer in such a manner as to make the human feel as if he is
in control.
------------------------------
Date: Tue, 17 Feb 2004 16:04:27 GMT
From: anonymous@coolgroups.com
Subject: Re: do not reload
Message-Id: <15b0563b78248a465363ad830f2a3230@news.scbiz.com>
Ok, maybe I wasn't clear about the issue since nobody
answered the question. Basically, I want the browser to
use a CACHED copy of a page if the person goes back to it.
Specifically, if you go to http://www.coolgroups.com, view
a message, and then click BACK, I don't want it to reload
the message listing from the server.
------------------------------
Date: Tue, 17 Feb 2004 06:31:09 -0800
From: "davido@codethought.nospamforme.com" <me@privacy.net>
Subject: Re: generate a list of file extensions?
Message-Id: <sb9430d2krjjr9jc69aoll0dcr9jh24175@4ax.com>
On 11 Feb 2004 14:44:26 GMT, Michele Dondi <bik.mido@tiscalinet.it>
wrote:
>Sorry to say this, but it may be that Perl is not strictly necessary
>for this task, and neither convenient.
Actually, yes it is. This code must run in Win32, Linux and Tru64.
The suggestion you made, while excellent, leaves Win32 in the cold.
------------------------------
Date: Tue, 17 Feb 2004 15:44:09 +0000
From: Paul Cooper <paul.cooper@Nobasspam.ac.uk>
Subject: Re: generate a list of file extensions?
Message-Id: <fkd430psmg3n6pltiekea0qrq2q01jr73h@4ax.com>
On Tue, 17 Feb 2004 06:31:09 -0800,
"davido@codethought.nospamforme.com" <me@privacy.net> wrote:
>On 11 Feb 2004 14:44:26 GMT, Michele Dondi <bik.mido@tiscalinet.it>
>wrote:
>
>>Sorry to say this, but it may be that Perl is not strictly necessary
>>for this task, and neither convenient.
>
>Actually, yes it is. This code must run in Win32, Linux and Tru64.
>The suggestion you made, while excellent, leaves Win32 in the cold.
>
Not so. The excellent Cygwin software provides most of the Unix
utilities in a Win32 environment.
Paul
------------------------------
Date: Tue, 17 Feb 2004 13:10:51 +0100
From: "pawo" <pawo2000@wp.pl>
Subject: how to start thread in thread
Message-Id: <c0t0gm$bsc$1@nemesis.news.tpi.pl>
Hello everyone,
I'm a perl beginner. I created a piece of code which starts a first thread.
Thie first thread
in turn creates a second thread (It's only testing but I will need such
feature soon). Unfortunately the creation of the second
thread hangs the first one (please, see the test example attached below). Is
there anybody who knows what's going on ?.
I decided to create fully OO software and I wouldn't like to go back into a
fork-based solution (It would be a really painful operation).
Env: Active State Perl 5.8.3/w2k (unfortunately I had no time to test it
under Red Hat 8).
Anyway i'm just wondering whether it's my fault or it's a kind of limitation
built-in into perl release (as i said I'm just a perl beginner).
Here is my test application (I know there are no joins but it's only
for testing purposes)
--------------- test.pl -----------------------
#!/usr/bin/perl -w
use strict;
use Config;
$Config{useithreads} or die "recompile Perl with threads to run this
program.";
use ThrdTest;
#new object
my $object = ThrdTest->new;
#does sth
$object->start;
#wait for a carriage return from stdin
my $svalue = <>;
print "\nFINISHED\n";
------------ ThrdTest.pm ------------
package ThrdTest;
use strict;
use threads;
use threads qw(yield);
my $thread1;
my $thread2;
my $thread3;
sub new {
my $class = shift;
my $self = {};
bless $self , $class;
return $self;
}
sub start {
my $self = shift;
$thread1 = threads->new(\&aaa, $self, "1");
$thread2 = threads->new(\&ddd, $self,"@");
}
sub aaa {
my $self = shift;
my $val = shift;
while(1) {
print $val;
yield;
}
}
sub ddd{
my $self = shift;
my $val = shift;
$thread3 = threads->new(\&aaa, $self, $val); #the script execution stalls
right here.
}
return 1;
--------------------------------
Thank you in advance.
--
pawo
[spadam b za duzo gadam]
------------------------------
Date: Tue, 17 Feb 2004 12:37:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: how to start thread in thread
Message-Id: <c0t1v5$t0d$1@wisteria.csv.warwick.ac.uk>
"pawo" <pawo2000@wp.pl> wrote:
> I'm a perl beginner. I created a piece of code which starts a first thread.
> Thie first thread
> in turn creates a second thread (It's only testing but I will need such
> feature soon). Unfortunately the creation of the second
> thread hangs the first one (please, see the test example attached below). Is
> there anybody who knows what's going on ?.
> I decided to create fully OO software and I wouldn't like to go back into a
> fork-based solution (It would be a really painful operation).
You do realise that OO and threads are not the same thing at all?
> --------------- test.pl -----------------------
> #!/usr/bin/perl -w
'use warnings' is better than -w
> use strict;
>
> use Config;
> $Config{useithreads} or die "recompile Perl with threads to run this
> program.";
>
> use ThrdTest;
> #new object
> my $object = ThrdTest->new;
> #does sth
> $object->start;
> #wait for a carriage return from stdin
> my $svalue = <>;
> print "\nFINISHED\n";
>
> ------------ ThrdTest.pm ------------
> package ThrdTest;
> use strict;
You need 'use warnings' here as well (it is lexically scoped).
>
> use threads;
> use threads qw(yield);
>
> my $thread1;
> my $thread2;
> my $thread3;
>
> sub new {
> my $class = shift;
> my $self = {};
> bless $self , $class;
> return $self;
What's wrong with
return bless {}, shift;
?
> }
>
> sub start {
> my $self = shift;
> $thread1 = threads->new(\&aaa, $self, "1");
> $thread2 = threads->new(\&ddd, $self,"@");
> }
>
> sub aaa {
> my $self = shift;
> my $val = shift;
> while(1) {
> print $val;
> yield;
You do know that 'yield' guarantees *absolutely* *nothing*, don't you?
It's just a hint: it may well be completely ignored.
> }
> }
>
> sub ddd{
> my $self = shift;
> my $val = shift;
> $thread3 = threads->new(\&aaa, $self, $val); #the script execution stalls
> right here.
What do you mean by 'stalls'? Do you carry on getting 1s? What happens
if you press return? What happens if you add a 'print' line just before
this? What happens if you add a 'print' line just after this?
> }
>
> return 1;
FWIW, on my system (linux 2.4.20, glibc 2.3.2, perl 5.8.2) I get large
numbers of both 1s and @s, until I press return when it prints
FINISHED
A thread exited while 3 threads were running, <> line 1.
as expected. I suspect you have a synchronisation problem: likely, for
some reason the first thread is sitting in the <> doing nowt: does Win32
suffer from the 'one thread blocking blocks all threads' problem?
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Tue, 17 Feb 2004 13:06:46 +0100
From: Tore Aursand <tore@aursand.no>
Subject: OOP: Inheriting identically named methods
Message-Id: <pan.2004.02.17.12.05.46.658959@aursand.no>
Hmm. Don't know if I got the subject totally right. Just take a look at
the example instead.
I'm having problems with simple OOP inheritance. Seems like I've been
away from the OOP business too long. I've read through perlboot, perltoot
and perltooc.
Here's some sample code:
package Person;
use strict;
use warnings;
sub new {
my $class = shift;
my $self = {
'firstname' => '',
'lastname' => '',
'age' => 0,
};
bless( $self, $class );
$self->_init( @_ );
return $self;
}
sub _init {
my $self = shift;
my %ARGS = @_;
$self->{'firstname'} = $ARGS{'firstname'} || '';
$self->{'lastname'} = $ARGS{'lastname'} || '';
$self->{'age'} = $ARGS{'age'} || 0;
}
1;
package Employee;
use strict;
use warnings;
use Person;
our @ISA = qw( Person );
sub new {
my $class = shift;
my $self = $class->SUPER::new( @_ );
$self->{'salary'} = 0;
bless( $self, $class );
$self->_init( @_ );
return $self;
}
sub _init {
my $self = shift;
my %ARGS = @_;
$self->{'salary'} = $ARGS{'salary'} || 0;
}
1;
This code may very well work as intended, but when I create a new instance
of the Employee class, only Employee::_init() is run (and it is run twice);
#!/usr/bin/perl
#
use strict;
use warnings;
use Employee;
my $Employee = Employee->new();
I really thought this would spawn into this:
Employee::new()
Person::new()
Person::_init()
Employee::_init()
But it doesn't. Instead it is executed in this manner:
Employee::new()
Person::new()
Employee::_init()
Employee::_init()
Anyone care to explain what's going on and what I need to do in order to
make this work as I want it to?
Thanks!
--
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." -- Sir John Lubbock
------------------------------
Date: Tue, 17 Feb 2004 12:20:16 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: OOP: Inheriting identically named methods
Message-Id: <c0t0u0$sbn$1@wisteria.csv.warwick.ac.uk>
Tore Aursand <tore@aursand.no> wrote:
> Hmm. Don't know if I got the subject totally right. Just take a look at
> the example instead.
>
> I'm having problems with simple OOP inheritance. Seems like I've been
> away from the OOP business too long. I've read through perlboot, perltoot
> and perltooc.
>
> Here's some sample code:
>
> package Person;
> use strict;
> use warnings;
>
> sub new {
> my $class = shift;
>
> my $self = {
> 'firstname' => '',
> 'lastname' => '',
> 'age' => 0,
You don't need to do this as you init them all in _init. You can just
say
my $self = bless {}, $class;
> };
> bless( $self, $class );
>
> $self->_init( @_ );
If $self is actually an Employee object, this will call Employee::_init.
> return $self;
> }
>
> sub _init {
> my $self = shift;
> my %ARGS = @_;
>
> $self->{'firstname'} = $ARGS{'firstname'} || '';
> $self->{'lastname'} = $ARGS{'lastname'} || '';
> $self->{'age'} = $ARGS{'age'} || 0;
None of the hash keys need quoting.
> }
>
> 1;
>
> package Employee;
> use strict;
> use warnings;
>
> use Person;
> our @ISA = qw( Person );
Better than these two lines is
use base qw/Person/;
as it happens at compile time.
> sub new {
> my $class = shift;
>
> my $self = $class->SUPER::new( @_ );
> $self->{'salary'} = 0;
This, again, is done by _init.
> bless( $self, $class );
>
> $self->_init( @_ );
These have already been done by Person::new (that's why you used two-arg
bless, remember :).
> return $self;
> }
>
> sub _init {
> my $self = shift;
> my %ARGS = @_;
Here you want to call $self->SUPER::_init(@_), so that Person::_init
gets called. You probably also want to make the _init methods remove the
keys they know and return the rest:
$self->{salary} = (delete $ARGS{salary}) || 0;
return %ARGS;
and then in subclasses you can say
my %ARGS = $self->SUPER::_init(@_);
to let the superclass handle the keys it knows and return you the rest.
> $self->{'salary'} = $ARGS{'salary'} || 0;
> }
>
> 1;
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: Tue, 17 Feb 2004 15:03:06 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: OOP: Inheriting identically named methods
Message-Id: <pan.2004.02.17.13.09.39.144593@aursand.no>
On Tue, 17 Feb 2004 12:20:16 +0000, Ben Morrow wrote:
>> package Person;
>> use strict;
>> use warnings;
>>
>> sub new {
>> my $class = shift;
>>
>> my $self = {
>> 'firstname' => '',
>> 'lastname' => '',
>> 'age' => 0,
> You don't need to do this as you init them all in _init. You can just
> say
> my $self = bless {}, $class;
I see that as pretty irrelevant to my problem, and I _want_ to do it this
way. That way I can handle all the initialisation of the object inside a
special method, while the structure of the class in another.
Why? Well. Consider this _init() method;
sub _init {
my $self = shift;
my %ARGS = @_;
foreach ( keys %ARGS ) {
if ( exists $self->{$_} ) {
$self->{$_} = $ARGS{$_};
}
else {
warn "'$_' isn't a member of this class\n";
}
}
}
Easier to read the code, IMO; new() takes care of the class definition,
while _init() initialises it.
>> $self->{'firstname'} = $ARGS{'firstname'} || '';
>> $self->{'lastname'} = $ARGS{'lastname'} || ''; $self->{'age'}
> None of the hash keys need quoting.
I know, but that's not a problem. I helps me from going cross-eyed; my
editor highlights those strings so nice. :)
>> package Employee;
>> use strict;
>> use warnings;
>>
>> use Person;
>> our @ISA = qw( Person );
> Better than these two lines is
> use base qw/Person/;
> as it happens at compile time.
Nice to know. What is the difference between these two methods? Are they
practically identical? Should one never need to use @ISA? (No, I haven't
read the 'perldoc base' yet, but I will do after writing this post). :)
>> bless( $self, $class );
>>
>> $self->_init( @_ );
> These have already been done by Person::new (that's why you used two-arg
> bless, remember :).
Aha. So I should never bless() an inherited class?
Just to sum up. Does this look better (forget about where I initialise
the data and how I quote, please)?
package Person;
use strict;
use warnings;
sub new {
my $class = shift;
my $self = {
'firstname' => '',
'lastname' => '',
'age' => 0,
};
bless( $self, $class );
$self->_init( @_ );
return $self;
}
sub _init {
my $self = shift;
}
1;
package Employee;
use strict;
use warnings;
use Person;
our @ISA = qw( Person );
sub new {
my $class = shift;
my $self = $class->SUPER::new( @_ );
$self->{'salary'} = 0;
return $self;
}
sub _init {
my $self = shift;
$self->SUPER::_init( @_ );
}
1;
I'm still using the @ISA, but this will - of course - be changed whenever
I find it suitable, as it didn't seem to do any difference in my example
above. :)
--
Tore Aursand <tore@aursand.no>
"Omit needless words. Vigorous writing is concise. A sentence should
contain no unnecessary words, a paragraph no unnecessary sentences,
for the same reason that a drawing should have no unnecessary lines
and a machine no unnecessary parts." -- William Strunk Jr.
------------------------------
Date: Tue, 17 Feb 2004 15:00:09 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: OOP: Inheriting identically named methods
Message-Id: <c0ta9p$5dj$1@wisteria.csv.warwick.ac.uk>
Tore Aursand <tore@aursand.no> wrote:
> On Tue, 17 Feb 2004 12:20:16 +0000, Ben Morrow wrote:
> > You don't need to do this as you init them all in _init. You can just
> > say
> > my $self = bless {}, $class;
>
> I see that as pretty irrelevant to my problem, and I _want_ to do it this
> way. That way I can handle all the initialisation of the object inside a
> special method, while the structure of the class in another.
>
> Why? Well. Consider this _init() method;
>
> sub _init {
> my $self = shift;
> my %ARGS = @_;
>
> foreach ( keys %ARGS ) {
> if ( exists $self->{$_} ) {
> $self->{$_} = $ARGS{$_};
> }
> else {
> warn "'$_' isn't a member of this class\n";
> }
> }
> }
>
> Easier to read the code, IMO; new() takes care of the class definition,
> while _init() initialises it.
Fair enough, though see below for a potential problem.
> >> use Person;
> >> our @ISA = qw( Person );
>
> > Better than these two lines is
> > use base qw/Person/;
> > as it happens at compile time.
>
> Nice to know. What is the difference between these two methods? Are they
> practically identical? Should one never need to use @ISA? (No, I haven't
> read the 'perldoc base' yet, but I will do after writing this post). :)
use base qw/Person/; is nearly the same as
BEGIN {
require Person;
push @ISA, qw/Person/;
}
except that it also handles the 'use fields' pragma if you use that.
Having the inheritance set up at compile time can be important.
> >> bless( $self, $class );
> >>
> >> $self->_init( @_ );
>
> > These have already been done by Person::new (that's why you used two-arg
> > bless, remember :).
>
> Aha. So I should never bless() an inherited class?
Not under normal circumstances.
> Just to sum up. Does this look better (forget about where I initialise
> the data and how I quote, please)?
<snip>
That will work, yes; however, if I may remember for one moment the
question of initialising the data :), Employee::_init will be called
*before* Person::new returns, so an _init structured as you mentioned
above will fail when called on an Employee object (the 'salary' key
won't have been added to the hash yet). If you wish to keep the
'construction' and 'initialisation' phases separate, you could split new
into two methods:
package Person;
use Hash::Util qw/lock_keys/;
sub new {
my $class = shift;
my $self = $class->_construct;
# make sure we don't change the structure by mistake: this is
# sort-of like 'use strict' for hashes
lock_keys %$self;
$self->_init(@_);
return $self;
}
sub _construct {
my $class = shift;
return bless {
'firstname' => '',
...
}, $class;
}
sub _init {
my $self = shift;
...
}
package Employee;
use base qw/Person/;
# no need for a new method: Person's will do for all subclasses
sub _construct {
my $class = shift;
my $self = $class->SUPER::_construct;
$self->{'salary'} = 0;
return $self;
}
sub _init {
my $self = shift;
@_ = $self->SUPER::_init(@_); # or whatever
...
}
This ensures that all the _construct methods are called before any of
the _init are.
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * ben@morrow.me.uk
------------------------------
Date: 17 Feb 2004 11:46:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <c0suv5$284$1@mamenchi.zrz.TU-Berlin.DE>
Ben Morrow <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
[...]
> my $content = get $site;
> my @content = split /\n/, $content;
>
> Some people would object to my using both $content and @content here...
> that is a matter of style you may wish to consider.
I wouldn't object at all. When the same content is represented in different
forms, using the same name for both is intuitive and describes the situation.
I do it all the time.
Anno
------------------------------
Date: Tue, 17 Feb 2004 13:08:46 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <c0t0s7$1b6clr$1@ID-184292.news.uni-berlin.de>
Michele Dondi wrote:
> On Mon, 16 Feb 2004 21:59:48 +0100, Gunnar Hjalmarsson
> <noreply@gunnar.cc> wrote:
>>
>> use LWP::Simple;
>> my $site = get 'http://www.webbuyeruk.co.uk/links.htm';
>> while ( $site =~ /(.*)/g ) {
>> if ($1 =~ /PATTERN/) {
>> print "Found\n";
>> last;
>> }
>> }
>
> [...]
>
>>> open(MYFILE, "<($site[0])") || die "Can't open $site[0] : $!\n";;
>>
>> You can't open a URL! Please learn the difference between a path
>> and a URL.
>
> But then, if he *really* wants to open() the downloaded HTML, he
> could do that "in memory":
>
> # untested
> open my $file, '<', \$site or die $!;
> do_something while <$file>;
Well, I tested, and it just made my script hang.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Feb 2004 12:40:41 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <c0t249$t0d$2@wisteria.csv.warwick.ac.uk>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Michele Dondi wrote:
> > But then, if he *really* wants to open() the downloaded HTML, he
> > could do that "in memory":
> >
> > # untested
> > open my $file, '<', \$site or die $!;
> > do_something while <$file>;
>
> Well, I tested, and it just made my script hang.
Yesss... $site has no newlines in. Michele meant something more like
my $html = get $site;
open my $FILE, '<', \$html or die $!;
do_summat while <$FILE>;
Ben
--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: ben@morrow.me.uk
------------------------------
Date: Tue, 17 Feb 2004 13:51:14 -0000
From: "Bumble" <bumble@what.the.heck>
Subject: Perl Graph? (newbie)
Message-Id: <c0t67t$rn5$1@news8.svr.pol.co.uk>
Hi, I'm looking to construct a graph using Perl, to be displayed on a HTML
page, is this possible? Is there a module? I've been looking at some but a
little confused? Any examples about?
--
Bumble
http://bumble.rumble.at
------------------------------
Date: Tue, 17 Feb 2004 13:54:16 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl Graph? (newbie)
Message-Id: <c0t6e8$2p6$1@wisteria.csv.warwick.ac.uk>
"Bumble" <bumble@what.the.heck> wrote:
> Hi, I'm looking to construct a graph using Perl, to be displayed on a HTML
> page, is this possible? Is there a module? I've been looking at some but a
> little confused? Any examples about?
Try GD::Graph from CPAN.
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
/Alcestis/) [ flame, and falls out of sight. ] ben@morrow.me.uk
------------------------------
Date: Tue, 17 Feb 2004 14:04:23 -0000
From: "Bumble" <bumble@what.the.heck>
Subject: Re: Perl Graph? (newbie)
Message-Id: <c0t70i$ggn$1@news6.svr.pol.co.uk>
Ben Morrow wrote:
> "Bumble" <bumble@what.the.heck> wrote:
>> Hi, I'm looking to construct a graph using Perl, to be displayed on
>> a HTML page, is this possible? Is there a module? I've been looking
>> at some but a little confused? Any examples about?
>
> Try GD::Graph from CPAN.
>
> Ben
Ta... Now a silly question, how do I actually use that module or those
modules? Do I need to install it somewhere (on my PC and the server it'll be
run from)? And if so where?
--
Bumble
http://bumble.rumble.at
------------------------------
Date: Tue, 17 Feb 2004 10:36:19 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Perl Graph? (newbie)
Message-Id: <pan.2004.02.17.15.36.17.927802@remove.adelphia.net>
On Tue, 17 Feb 2004 14:04:23 +0000, Bumble wrote:
> Ben Morrow wrote:
>> "Bumble" <bumble@what.the.heck> wrote:
>>> Hi, I'm looking to construct a graph using Perl, to be displayed on
>>> a HTML page, is this possible? Is there a module? I've been looking
>>> at some but a little confused? Any examples about?
>> Try GD::Graph from CPAN.
> Ta... Now a silly question, how do I actually use that module or those
> modules? Do I need to install it somewhere (on my PC and the server it'll be
> run from)? And if so where?
perldoc CPAN
perldoc perlmodinstall
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
If someone had told me I would be Pope one day, I would have
<studied harder. -- Pope John Paul I
------------------------------
Date: Tue, 17 Feb 2004 15:48:10 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: Perl Graph? (newbie)
Message-Id: <eer7wtvhdr.fsf@dingo.beable.com>
"Bumble" <bumble@what.the.heck> writes:
> Ben Morrow wrote:
> > "Bumble" <bumble@what.the.heck> wrote:
> >> Hi, I'm looking to construct a graph using Perl, to be displayed on
> >> a HTML page, is this possible? Is there a module? I've been looking
> >> at some but a little confused? Any examples about?
> >
> > Try GD::Graph from CPAN.
> >
> > Ben
>
> Ta... Now a silly question, how do I actually use that module or those
> modules? Do I need to install it somewhere (on my PC and the server it'll be
> run from)? And if so where?
You need to install the module:
http://www.cpan.org/modules/INSTALL.html
Then, you can read the documentation for the module, which will have
examples in it. You can read the documentation for GD::Graph by
running this command:
perldoc GD::Graph
--
Once the genie is out of Pandora's box, you'll never get the cat back
into the stable.
http://beable.com/
------------------------------
Date: Tue, 17 Feb 2004 12:02:39 +0100
From: Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Perl memory allocation
Message-Id: <slrnc33t04.10c.bernard.el-haginDODGE_THIS@gdndev25.lido-tech>
On 2004-02-17, Maximus <anio@webgroup-bg.com> wrote:
>>
>> My variable is a global, so it will never go out of scope, but I've tried
>> "$var = undef;" without any success.
>
>
>
> $var = undef; ??? What is this?
>
> undef $var; That is!!! :)))
Same thing.
--
Cheers,
Bernard
------------------------------
Date: 17 Feb 2004 06:27:07 -0800
From: yashgt@yahoo.com (Yash)
Subject: Threadsafe writing to files
Message-Id: <5a373b1d.0402170627.68f210a7@posting.google.com>
Our perl program has to write lines to a large number of files. To
make use of a multiprocessor architecture, we use threads.
Some of the files will be written to by more than one threads. Which
function should I use so that lines do not get split by different
threads writing to the same file?
Is it WRITE or PRINT that I should be using? Basically I am looking
for a thread-safe function to write to files.
We use Perl 5.8 on Windows 2000.
Thanks
------------------------------
Date: Tue, 17 Feb 2004 15:04:17 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Threadsafe writing to files
Message-Id: <c0tahh$5dj$2@wisteria.csv.warwick.ac.uk>
yashgt@yahoo.com (Yash) wrote:
> Our perl program has to write lines to a large number of files. To
> make use of a multiprocessor architecture, we use threads.
> Some of the files will be written to by more than one threads. Which
> function should I use so that lines do not get split by different
> threads writing to the same file?
> Is it WRITE or PRINT that I should be using? Basically I am looking
> for a thread-safe function to write to files.
write does not do the same thing as print at all. None of the Perl
output functions are 'thread-safe' in the way you want: you will need to
use a mutex to sychronise your outputs, and either use syswrite or set
$| to 1 so Perl flushes every write right out.
Ben
--
Razors pain you / Rivers are damp
Acids stain you / And drugs cause cramp. [Dorothy Parker]
Guns aren't lawful / Nooses give
Gas smells awful / You might as well live. ben@morrow.me.uk
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6146
***************************************