[24153] in Perl-Users-Digest
Perl-Users Digest, Issue: 6347 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 31 18:05:54 2004
Date: Wed, 31 Mar 2004 15:05:10 -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 Wed, 31 Mar 2004 Volume: 10 Number: 6347
Today's topics:
Re: [NEWBIE] newline question <remorse@partners.org>
Re: [NEWBIE] newline question <jan.biel@tu-clausthal.de>
Re: [NEWBIE] newline question <jan.biel@tu-clausthal.de>
Re: [NEWBIE] newline question <dwall@fastmail.fm>
Re: [NEWBIE] newline question <noreply@gunnar.cc>
Re: [NEWBIE] newline question <noreply@gunnar.cc>
Re: [NEWBIE] newline question (Randal L. Schwartz)
Re: [NEWBIE] newline question <tadmc@augustmail.com>
Re: Bless, inheritance and swig (Xiaodong Huang)
CGI script does not print values selected??? <bdu@iastate.edu>
Re: CGI script does not print values selected??? <ittyspam@yahoo.com>
Re: CGI script does not print values selected??? <bdu@iastate.edu>
Re: Filehandles Referenced with a Variable <emschwar@pobox.com>
Inline C on Windows - what am i doing wrong? <nospamplease@no.com>
Re: Inline C on Windows - what am i doing wrong? <nospamplease@no.com>
Re: Inline C on Windows - what am i doing wrong? <postmaster@castleamber.com>
Re: Lost data on socket - Can we start over politely? <jgibson@mail.arc.nasa.gov>
Re: Modify elements of an array <bmb@ginger.libs.uga.edu>
Re: Modify elements of an array <krahnj@acm.org>
Module install help? <pat@nuclearrabbit.com>
Re: Module install help? <spamtrap@dot-app.org>
Re: multiple lines / success or failure?! <jtc@shell.dimensional.com>
PHP-to-Perl function reference? <none@none.com>
Re: PHP-to-Perl function reference? <postmaster@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 31 Mar 2004 14:19:25 -0500
From: Richard Morse <remorse@partners.org>
Subject: Re: [NEWBIE] newline question
Message-Id: <remorse-8B6F3C.14192531032004@plato.harvard.edu>
In article <c4f1j1$2hkaud$1@ID-184292.news.uni-berlin.de>,
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Richard Morse wrote:
> >
> > @lines = ( 'a\n', 'b\n', 'c\n' );
>
> No, that wouldn't populate @lines with the same thing. This would:
>
> @lines = ( "a\n", "b\n", "c\n" );
Right. I knew that.
/me starts flipping through documentation
My bad,
Ricky
--
Pukku
------------------------------
Date: Wed, 31 Mar 2004 21:27:54 +0200
From: "Jan Biel" <jan.biel@tu-clausthal.de>
Subject: Re: [NEWBIE] newline question
Message-Id: <c4f6ur$12oh$1@ariadne.rz.tu-clausthal.de>
Richard Morse wrote:
> Try this:
[...]
Thanks a lot.
I really appreciate the comments.
Always glad to learn decent style along with learning the basics of a
language.
Thanks,
Janbiel
------------------------------
Date: Wed, 31 Mar 2004 21:33:39 +0200
From: "Jan Biel" <jan.biel@tu-clausthal.de>
Subject: Re: [NEWBIE] newline question
Message-Id: <c4f6ur$12oh$2@ariadne.rz.tu-clausthal.de>
Gunnar Hjalmarsson wrote:
> my $filein = 'a.txt';
> my $fileout = 'b.txt';
> ----^^
> Declare variables with my()
Is that a style hint or is it crucial to the script?
I'm always eager to learn coding good style, I was just wondering which it
is ;)
>> grep(s/\n//g,@lines);
>
> That works, but it's clearer written as:
>
> @lines = map { tr/\n//d; $_ } @lines;
I guess I'll need to read some tutorials to get a better hang of the
language. Trial and error won't cut it with perl I guess. I wasted too many
hours trying to find out why my code doesn't work. RTFM would have helped I
guess.
Thanks a lot for your input. I appreciate it.
Janbiel
------------------------------
Date: Wed, 31 Mar 2004 20:05:33 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: [NEWBIE] newline question
Message-Id: <Xns94BD9987892A0dkwwashere@216.168.3.30>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Brian McCauley wrote:
>> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>>
>>>>grep(s/\n//g,@lines);
>>>
>>>That works, but it's clearer written as:
>>>
>>> @lines = map { tr/\n//d; $_ } @lines;
>>
>> That works, but it's not clearer.
>
> Well, I could argue, but I won't. Let's just agree that I should
> better have used 'for'. :)
Since the OP was just stripping newlines from lines read from a file,
why not use this:
chomp( my @lines = <INFO> );
Did I miss something somewhere? Why use map() when chomp() is made for
this purpose?
------------------------------
Date: Wed, 31 Mar 2004 23:26:08 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [NEWBIE] newline question
Message-Id: <c4fd6b$2i9163$1@ID-184292.news.uni-berlin.de>
Jan Biel wrote:
> Gunnar Hjalmarsson wrote:
>>
>> my $filein = 'a.txt';
>> my $fileout = 'b.txt';
>> ----^^
>> Declare variables with my()
>
> Is that a style hint or is it crucial to the script?
Running the script with strictures enabled:
use strict;
is a very important style hint. Doing so requires that all variables
are declared, and normally you declare the variables lexically using my().
> I guess I'll need to read some tutorials to get a better hang of
> the language. Trial and error won't cut it with perl I guess. I
> wasted too many hours trying to find out why my code doesn't work.
> RTFM would have helped I guess.
Good thoughts. :)
> Thanks a lot for your input. I appreciate it.
You are welcome.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 31 Mar 2004 23:29:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [NEWBIE] newline question
Message-Id: <c4fdc1$2gad64$1@ID-184292.news.uni-berlin.de>
David K. Wall wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> Brian McCauley wrote:
>>> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>>>>
>>>>> grep(s/\n//g,@lines);
>>>>
>>>> That works, but it's clearer written as:
>>>>
>>>> @lines = map { tr/\n//d; $_ } @lines;
>>>
>>> That works, but it's not clearer.
>>
>> Well, I could argue, but I won't. Let's just agree that I should
>> better have used 'for'. :)
>
> Since the OP was just stripping newlines from lines read from a file,
> why not use this:
>
> chomp( my @lines = <INFO> );
>
> Did I miss something somewhere? Why use map() when chomp() is made for
> this purpose?
No, I think it was I who missed something (twice). (And Brian once.)
Thanks.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 31 Mar 2004 13:52:28 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: [NEWBIE] newline question
Message-Id: <86d66sptur.fsf@blue.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
>>>>> "Gunnar" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
Gunnar> That works, but it's clearer written as:
Gunnar> @lines = map { tr/\n//d; $_ } @lines;
I don't consider that clearer. The loop first modifies @lines (via
the side effect of having changed $_ in the map block), then gathers
all those results together to create a new list, then assigns the
entire new list over the top of the identically updated list.
Weird. Definitely not clearer, and more dangerous too. Consider
the obvious cut-and-paste mangling:
@newlines = map { tr/\n//d; $_ } @lines;
Your copy of @lines and @newlines are identical, even though you might
expect @lines to remain unaffected!
Definitely bad. Definitely don't do this. Not without the required
BIG HONKIN COMMENT to the right describing how wasteful you are.
print "Just another Perl hacker,"; # yeah, the guy who invented this phrase
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
------------------------------
Date: Wed, 31 Mar 2004 16:17:42 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [NEWBIE] newline question
Message-Id: <slrnc6mgs6.1l6.tadmc@magna.augustmail.com>
Jan Biel <jan.biel@tu-clausthal.de> wrote:
> Gunnar Hjalmarsson wrote:
>
>> my $filein = 'a.txt';
>> my $fileout = 'b.txt';
>> ----^^
>> Declare variables with my()
>
> Is that a style hint or is it crucial to the script?
It is a style hint (a really strong one).
It _may_ be crucial to _a_ script, but I don't think it is
crucial to the code quoted above. (dodged a bullet)
It may be crucial to having folks here decide between looking
at the code and moving on to the next post. :-)
> I'm always eager to learn coding good style, I was just wondering which it
> is ;)
Controlling the scope of variables is a general CS type topic, much
of it is the same regardless of the programming language being used.
Learn about scoping in Perl:
"Coping with Scoping":
http://perl.plover.com/FAQs/Namespaces.html
Without my(), it is a Global Variable, and everybody knows that the
indiscriminate use of Global Variables is bad design.
I like to encourage these preliminary "rules" regarding variable scope:
For a Perl Beginner:
Always prefer lexical (my) over package (our) variables,
except for the built-in variables.
For a Perl Intermediate:
Always prefer lexical (my) over package (our) variables,
except when your program is so big as to require breaking
it up into several files.
For Everyone Else:
Always prefer lexical (my) over package (our) variables,
except when you can't. (you'll know when you can't by this point)
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Mar 2004 11:47:53 -0800
From: xhuang@yahoo.com (Xiaodong Huang)
Subject: Re: Bless, inheritance and swig
Message-Id: <d20a1c88.0403311147.a9f962e@posting.google.com>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote in message news:<Pine.A41.4.58.0403302118580.14252@ginger.libs.uga.edu>...
> On Tue, 30 Mar 2004, Xiaodong Huang wrote:
>
> > I searched but could not find answer for this question on Internet or
> > in Newsgroups.
> >
> > I have a class CObject in C++ which is wrapped by SWIG:
> >
> > class CObject {
> > public:
> > CObject();
> > get();
> > }
> >
> > I want to write a perl object that inherits from
> > CObject. So I wrote something like this (I used similar code
> > before in non-SWIG case):
> >
> > Package MyPerlObject;
> --^
> s/P/p/;
>
>
> >
> > use Exporter;
>
> FWIW, you probably don't need Exporter.
>
>
> > use CObject;
> >
> > our @ISA = qw(CObject Exporter);
> >
> > sub new {
> > my $class = shift ;
> > $class = ref($class) || $class ;
> > my $self = CObject->new();
> > bless $self, $class;
> > return $self;
> > }
> >
> > ...
> >
> > MyPerlObject does not have a method get(). When client of MyPerlObject
> > called MyPerlObject::get() at run-time, I got
> > "No matching function for overloaded CObject_get()".
> >
> > So I tried to pinpoint where the problem was and found that it seemed
> > to have something to do with bless.
> >
> > I modified the above new() subroutine by adding two lines:
> >
> > sub new {
> > my $class = shift ;
> > $class = ref($class) || $class ;
> > my $self = CObject->new();
> > $self->get(); # works
> > bless $self, $class;
> > $self->get(); # does not work
> > return $self;
> > }
> >
> > The line before "bless" statement works but the line after it gives me
> > the "No matching function .." error as before.
> >
> > Could someone point to me what I did wrong or suggest a way to work around
> > the problem?
> >
> > Thanks.
> >
> > xh
> >
>
> package CObject;
>
> sub get { print "CObject::get ran\n" }
> sub new { bless {}, $_[0] }
>
> package MyPerlObject;
>
> our @ISA = qw(CObject);
>
> sub new {
> my $class = shift ;
> $class = ref($class) || $class ;
> my $self = CObject->new();
> $self->get(); # works
> bless $self, $class;
> $self->get(); # does not work (does now)
> return $self;
> }
>
> my $o = MyPerlObject->new();
>
> __END__
> CObject::get ran
> CObject::get ran
>
>
> Hope that helps,
>
> Brad
Brad,
If CObject is a plain perl class, it's get() method can be located by
its derived class. The problem arises when CObject
is a C++ class wrapped by SWIG interface. Hence the message "No matching
function for overloaded CObject_get()".
still searching for solution..
Thanks.
xh
------------------------------
Date: Wed, 31 Mar 2004 13:57:18 -0600
From: Bing Du <bdu@iastate.edu>
Subject: CGI script does not print values selected???
Message-Id: <c4f7r3$1a6$1@news.iastate.edu>
Greetings,
No matter what year(s) I select from the list on the web, the selected
years are not printed out as they are supposed to be. Would anybody
tell me what's wrong? Appreciate any help!
test.cgi:
================================
#!/usr/bin/perl
use CGI;
print "content-type: text/html\n\n";
$program = "test.cgi";
my $q = new CGI;
if ($q->param('select_year'))
{
@years = $q->param('years');
print "Class Schedules for years (",join(',',@years),")<br>";
exit;
}
print <<_HTML;
<form method=post action=$program>
<select name=years[] size=5 multiple>
<option>2003
<option>2004
</select>
<input type=submit name=select_year value=GO>
</form>
_HTML
=====================================
Bing
------------------------------
Date: Wed, 31 Mar 2004 15:17:23 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: CGI script does not print values selected???
Message-Id: <20040331151630.K19862@dishwasher.cs.rpi.edu>
On Wed, 31 Mar 2004, Bing Du wrote:
> Greetings,
>
> No matter what year(s) I select from the list on the web, the selected
> years are not printed out as they are supposed to be. Would anybody
> tell me what's wrong? Appreciate any help!
>
> test.cgi:
>
> ================================
> #!/usr/bin/perl
>
> use CGI;
>
> print "content-type: text/html\n\n";
>
> $program = "test.cgi";
> my $q = new CGI;
>
>
> if ($q->param('select_year'))
> {
> @years = $q->param('years');
> print "Class Schedules for years (",join(',',@years),")<br>";
> exit;
> }
>
> print <<_HTML;
>
> <form method=post action=$program>
>
> <select name=years[] size=5 multiple>
Perl != PHP.
<select name="years" size="5" multiple>
Try that. The rest of the script should then work.
Paul Lalli
> <option>2003
> <option>2004
> </select>
> <input type=submit name=select_year value=GO>
>
> </form>
>
> _HTML
> =====================================
>
> Bing
>
>
------------------------------
Date: Wed, 31 Mar 2004 14:39:49 -0600
From: Bing Du <bdu@iastate.edu>
Subject: Re: CGI script does not print values selected???
Message-Id: <c4faaq$h8h$1@news.iastate.edu>
Ah, good to know. I used the exactly same syntax (i.e.name=years[]) in
another Perl script and it works there. But the difference is that Perl
script is called by a PHP wrapper which was written by another person.
This one stands alone. Thanks for the heads-up.
Bing
Paul Lalli wrote:
> On Wed, 31 Mar 2004, Bing Du wrote:
>
>
>>Greetings,
>>
>>No matter what year(s) I select from the list on the web, the selected
>>years are not printed out as they are supposed to be. Would anybody
>>tell me what's wrong? Appreciate any help!
>>
>>test.cgi:
>>
>>================================
>>#!/usr/bin/perl
>>
>>use CGI;
>>
>>print "content-type: text/html\n\n";
>>
>>$program = "test.cgi";
>>my $q = new CGI;
>>
>>
>> if ($q->param('select_year'))
>> {
>> @years = $q->param('years');
>> print "Class Schedules for years (",join(',',@years),")<br>";
>> exit;
>> }
>>
>>print <<_HTML;
>>
>><form method=post action=$program>
>>
>><select name=years[] size=5 multiple>
>
>
>
> Perl != PHP.
>
> <select name="years" size="5" multiple>
>
> Try that. The rest of the script should then work.
>
> Paul Lalli
>
>
>
>><option>2003
>><option>2004
>></select>
>><input type=submit name=select_year value=GO>
>>
>></form>
>>
>>_HTML
>>=====================================
>>
>>Bing
>>
>>
------------------------------
Date: Wed, 31 Mar 2004 15:07:22 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <etoisgkoelh.fsf@fc.hp.com>
Mike Flannigan <mikeflan@earthlink.net> writes:
> There is something about this statement from Myron that
> I don't understand:
> "When you extract $fh from the hash and use it in a position requiring a
> filehandle perl goes to the type glob which holds
> $fh (*fh) and fetches the filehandle for you."
>
> I guess that "extract $fh from the hash" is happening behind
> the scenes, and I shouldn't really expect to see it directly
> in my code below.
Nope. By "extract $fh from the hash" he means
my $fh = $handles{$state}
You had the handle in the hash, now you have extracted it into $fh.
Comprende?
> Right or wrong, I have a lot to learn.
So do we all.
> foreach (@states) {
> my $fh; # Start with a scalar variable whose value is undef
> open $fh, '>', "$_.txt" or die "Cannot open $_.txt: $!";
You can unify these two lines if you like:
open my $fh, '>', "$_.txt" or die "Can't open $_.txt: $!";
> $handles{$_} = $fh; # open() magically makes $fh into a filehandle!
> }
Bingo!
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 31 Mar 2004 22:27:13 +0100
From: "SketchySteve" <nospamplease@no.com>
Subject: Inline C on Windows - what am i doing wrong?
Message-Id: <KyGac.471$Tq5.405@newsfe3-win.server.ntli.net>
Hi there,
I have a fairly simple C function which I need to itegrate into a perl
script. I have decided to use Inline for this task.
First I needed nmake for Visual Studio 6.0 C++. I found this file here
http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
installed it and set a path variable so it could be found.
After installing Inline and nmake I am still unable to run simple hello
world c progs or any other type either. I always get this message.
Had problems bootstrapping Inline module 'hello_pl_b1a6'
Can't locate loadable object for module hello_pl_b1a6 in @INC (@INC
contains: C:\_Inline\lib C:/Perl/lib C:/Perl/site/li
b .) at C:/Perl/site/lib/Inline.pm line 500
at C:\hello.pl line 0
INIT failed--call queue aborted.
This is a very urgent problem and help would be appreciated greatly. Am
really wracking my brain to work out what might be going wrong. Could it be
that my version of Perl was not compiled with nmake (i'm using 5.8 with
windows XP)?
Here is the program giving the error message
use Inline C;
greet('Ingy');
greet(42);
__END__
__C__
void greet(char* name) {
printf("Hello %s!\n", name);
}
This is from the inline cook book and all other program fail aswell (in the
same way).
Thanks in advance for your help
Steve
------------------------------
Date: Wed, 31 Mar 2004 23:13:16 +0100
From: "SketchySteve" <nospamplease@no.com>
Subject: Re: Inline C on Windows - what am i doing wrong?
Message-Id: <VdHac.948$Tb2.407@newsfe5-gui.server.ntli.net>
I installed nmake incorrectly and solved the problem but the error message
I'm now getting is as follows.
Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils/xsubpp -typemap
C:\Perl\lib\ExtUtils\typemap hello_pl_b1a688f821f707 19.xs >
hello_pl_b1a688f821f70719.xsc && C:\Perl\bin\perl.exe -MExtUtils::Command -e
mv hello_pl_b1a688f821f70719.xsc he llo_pl_b1a688f821f70719.c
cl -c -IC:/ -nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STR
ICT -DHAVE_DES_FCRYPT -DNO_HASH_SE
ED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1 -DVERSION=\"0.
00\" -DXS_VERSION=\"0.00\" "-IC:\Perl\lib\CORE" hello_pl_b1a688f821f70719.c
'cl' is not recognized as an internal or external command, operable program
or batch file. NMAKE : fatal error
U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1' Stop.
A problem was encountered while attempting to compile and install your
Inline C code. The command that failed was:
nmake > out.make 2>&1
The build directory was: C:\_Inline\build\hello_pl_b1a688f821f70719
To debug the problem, cd to the build directory, and inspect the output
files.
------------------------------
Date: Wed, 31 Mar 2004 16:44:03 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Inline C on Windows - what am i doing wrong?
Message-Id: <406b4a07$0$24342$58c7af7e@news.kabelfoon.nl>
SketchySteve wrote:
> 'cl' is not recognized as an internal or external command, operable program
> or batch file. NMAKE : fatal error
it means cl can not be found. What happens when you type cl in cmd.exe?
Probably same warning? Do you have cl on your system, and if so, is the
directory in your path?
--
John personal page: http://johnbokma.com/
Freelance Perl / Java developer available - http://castleamber.com/
------------------------------
Date: Wed, 31 Mar 2004 11:54:38 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Lost data on socket - Can we start over politely?
Message-Id: <310320041154384966%jgibson@mail.arc.nasa.gov>
In article <4069ecf6$1_1@news.iglou.com>, Vorxion
<vorxion@knockingshopofthemind.com> wrote:
> In article <4069a132.0@juno.wiesbaden.netsurf.de>, Thomas Kratz wrote:
> >[ code snipped ]
> >
[comments snipped]
> >++++ server ++++
> >
> >use strict;
> >use warnings;
> >
> >use IO::File;
> >use IO::Select;
> >use IO::Socket;
> >
> >my $max_buf = 10240;
> >
> >my $sel = IO::Select->new();
> >
> >my $srv = IO::Socket::INET->new(
> > Proto => 'tcp',
> > LocalPort => 4016,
> > Listen => SOMAXCONN,
> > ReuseAddr => 1,
> >);
> >
> >$sel->add($srv);
> >
> >die "couldn't create socket" unless $srv;
> >
> >my $log = IO::File->new('server.log', '>') or die $!;
> >$log->autoflush(1);
> >
> >while ( 1 ) {
> >
> > foreach my $sock ( $sel->can_read(0.05) ) {
> >
> > if ( $sock == $srv ) {
> >
> > my $new = $srv->accept();
> > $new->autoflush(1);
> > print $log "new connection from ", $new->peerhost,
> > ':', $new->peerport, "\n";
> > $sel->add($new);
> >
> > next;
> > }
> >
> > my $buf = '';
> > my $clsel = IO::Select->new($sock);
>
[snip]
>
> That, and one thing is curious--the docs for foreach() say that adding and
> removing elements from something from a list used for the loop is a Bad
> Thing[tm]. You're modifying $sel any time there's a connect or disconnect.
> Doesn't that throw the foreach() loop out of sync? Not at all a criticism,
> it's just that I've had fresh experience with foreach() and changed lists
> and elements thereof, and that part of the docs is fresh in my mind. I'm
> curious why this causes no difficulties in your example.
>
IO::Select->can_read(TIMEOUT) returns a list of handles ready to read.
The list will be in the form of a copy stored in memory for the
duration of the foreach loop. Modifying the IO::Select object $sel by
calling $sel->add() does not modify that list. $sel-> can_read() is not
called again for each iteration of the loop.
------------------------------
Date: Wed, 31 Mar 2004 14:20:43 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Modify elements of an array
Message-Id: <Pine.A41.4.58.0403311413400.13714@ginger.libs.uga.edu>
On Wed, 31 Mar 2004, fenisol3 wrote:
> All,
>
> I am a perl beginner and am trying to remove all the commas before the first
> word and after the last word in an array. Any hints? Thanks a lot.
>
> -Fenisol3
You asked a similar question in another thread where you also included
"commas" as pertinent in a discussion about "arrays". You haven't
clarified what your data really looks like.
But here's a hint based on my ESP. I think your data looks like this:
,,hey,,you,,,,,what's,,,up,,,
If it does, that's NOT an array. So please don't mention commas and
arrays any more. :-)
Please DO show some data if you're really serious about getting an answer.
Regards,
Brad
------------------------------
Date: Wed, 31 Mar 2004 22:42:18 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Modify elements of an array
Message-Id: <406B48D5.8914BD5B@acm.org>
fenisol3 wrote:
>
> I am a perl beginner and am trying to remove all the commas before the first
> word and after the last word in an array. Any hints? Thanks a lot.
$array[ 0 ] =~ s/^,+//;
$array[ -1 ] =~ s/,+$//;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 31 Mar 2004 19:41:17 GMT
From: Pat Garner <pat@nuclearrabbit.com>
Subject: Module install help?
Message-Id: <x9Fac.2879$Fo4.32772@typhoon.sonic.net>
I'm trying to install Bugzilla and when attempting to install the perl
modules necessary I keep getting this:
Writing Makefile for DBI
-- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
Only not just with the DBI module. By the way, I'm using cpan (perl
-MCPAN) to install the modules. Any help is greatly appreciated!
------------------------------
Date: Wed, 31 Mar 2004 17:21:36 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Module install help?
Message-Id: <4u6dnTMDbdjA2fbdRVn-jw@adelphia.com>
Pat Garner wrote:
... not nearly enough, and in the wrong place. (Followups have been set to
c.l.p.modules.)
> Writing Makefile for DBI
> -- NOT OK
We need to see the specific error message to have any chance at helping.
> Only not just with the DBI module. By the way, I'm using cpan (perl
> -MCPAN) to install the modules.
What modules? Onto what version of Perl, on what platform?
> Any help is greatly appreciated!
Likewise. We're not psychic... help us help you! ;-)
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 31 Mar 2004 14:38:33 -0700
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: multiple lines / success or failure?!
Message-Id: <slrnc6meip.eqd.jtc@shell.dimensional.com>
In article <slrnc6m3p2.1fg.tadmc@magna.augustmail.com>, Tad McClellan wrote:
> Geoff Cox <geoffacox@dontspamblueyonder.co.uk> wrote:
>> On 31 Mar 2004 17:50:30 +0100, Brian McCauley <nobull@mail.com> wrote:
>>>Geoff Cox <geoffacox@dontspamblueyonder.co.uk> writes:
>>>>
>>>> I am getting a "can't find EOHTML string terminator anywhere before
>>>> EOF" message using above. Is there a typo?
>>>
>>>Have you eleminiated the most likely cause that is explained when you
>>>look that message up in the reference manual (perldiag)?
>>
>> Making me work for the answer!!
>
>
> Making you do your own work.
>
> We are not a read-the-docs-to-me service.
>
> We hope that posters would be respectful enough of other's time
> to try the obvious things themselves before involving thousands
> of other people around the world.
>
> Knowing about perldiag.pod can help your troubleshooting
> forevermore, well beyond the problem that happened to
> bring you here today.
>
>
>> Problem solved -
>
>
> It is amazing how often reading the docs applicable to your
> problem will do that for you!
>
> Work smart. Try to find help in the best resource available first,
> look elsewhere only after that does not help.
>
> The best resource available for Perl is the standard documentation
> that comes with perl.
Also, when all other resources have been exhausted, a well-worded google
search can often lead to a solution. (This applies to many technologies,
of course, not just perl.)
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: Wed, 31 Mar 2004 21:19:28 +0100
From: Garry Heaton <none@none.com>
Subject: PHP-to-Perl function reference?
Message-Id: <sHFac.26291$h44.3498647@stones.force9.net>
Does anyone know if a reference exists for Perl equivalents of PHP
functions? With so much PHP/MySQL code available in books and only one book
on Perl/MySQL (Dubois), I'd like to set about using some of the existing PHP
code in Perl.
Garry Heaton
------------------------------
Date: Wed, 31 Mar 2004 14:25:10 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: PHP-to-Perl function reference?
Message-Id: <406b296c$0$24350$58c7af7e@news.kabelfoon.nl>
Garry Heaton wrote:
> Does anyone know if a reference exists for Perl equivalents of PHP
> functions? With so much PHP/MySQL code available in books and only one book
> on Perl/MySQL (Dubois), I'd like to set about using some of the existing PHP
> code in Perl.
Yup, there is such a site:
http://www.cs.wcupa.edu/~rkline/perl2php/
Google, did again, the trick: PHP Perl functions
http://www.google.com/search?q=PHP+Perl+functions
(But I have been on that site before, so I knew it was out there, somewhere)
--
John personal page: http://johnbokma.com/
Freelance Perl / Java developer available - http://castleamber.com/
------------------------------
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 6347
***************************************