[18950] in Perl-Users-Digest
Perl-Users Digest, Issue: 1145 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 16 14:05:41 2001
Date: Sat, 16 Jun 2001 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <992714709-v10-i1145@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 16 Jun 2001 Volume: 10 Number: 1145
Today's topics:
Re: A good place to find perl script examples (specific nobull@mail.com
Re: Access Sybase from PERL on NT (isterin)
Re: Access Sybase from PERL on NT (isterin)
Re: Ack! Newbie still suffering from C-brain! <mnemotronic@mind\no-spam/spring.com>
Re: can't handle strings with \ ??? <gnarinn@hotmail.com>
Re: can't handle strings with \ ??? nobull@mail.com
GREAT DISCOVERY!!! <janawills@icqmail.com>
Re: having trouble with system <none@this.net>
Re: How to make GetOpt::Long do what I want <gnarinn@hotmail.com>
howto: recursive implicit method access via 'tie'? <jbehren@gwdg.de>
Re: howto: recursive implicit method access via 'tie'? nobull@mail.com
Re: HTML input box variables? <alan@headru.sh>
Re: Looking for good tutorial/book on Perl programming. (zero the hero)
Re: Marble lossage in "or" vs. "||" <mnemotronic@mind\no-spam/spring.com>
Re: Marble lossage in "or" vs. "||" <bart.lateur@skynet.be>
missing spaces <g-preston1@ti.com>
Re: missing spaces <mbudash@sonic.net>
Re: missing spaces (E.Chang)
Re: missing spaces <pne-news-20010616@newton.digitalspace.net>
Re: missing spacse nobull@mail.com
more than one execution for wait? <vrman@sl2sys.co.kr>
Net::IRC connection problems: possible fix (smk)
Re: period (Barry Allwood)
Re: quick array question (E.Chang)
require-function fails on some servers <charles@betman.demon.nl>
Re: require-function fails on some servers <tony_curtis32@yahoo.com>
Re: require-function fails on some servers <tony_curtis32@yahoo.com>
Server Side Includes on IIS <mwinter@goldenapple.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jun 2001 16:19:12 +0100
From: nobull@mail.com
Subject: Re: A good place to find perl script examples (specifically: sockets)
Message-Id: <u93d90pi4v.fsf@wcl-l.bham.ac.uk>
"Jimmy Campbell" <jcampbell@mediaone.net> writes:
> I want to write a perl script that implements a protocol which requires me
> to connect to a socket, send it a string and then accept the output. Where
> is a good place to find perl scripts that I can view that do similar tasks?
> If any of you have any good suggestions for databases of example scripts I
> can view (kind of like perlarchive.com but not necessarily full apps, just
> chunks of code as tutorials) please let me know. I'm a newbie at perl and
> would love to learn.
I suggest you take a look at the source of Net::Cmd.
This is a base class used to implement the modules for internet
protocols like SNMP, FTP and so on.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 16 Jun 2001 08:24:22 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Access Sybase from PERL on NT
Message-Id: <db67a7f3.0106160724.36e9b72d@posting.google.com>
David Busby <dbusby3@slb.com> wrote in message news:<3B2A6B46.230A1369@slb.com>...
> Does anyone know how to access sybase from PERL running on NT with IIS.
Yes. Are you trying to access from a non wintel platform, or are both
the Perl script and the server on the wintel platform?
> I have tried several times but keep getting the error that for some
> reason PERL can't load the sybperl::dblib or sybperl::ctlib dll files
> from dynaloader.pm. If anyone has any suggestions please let me know.
Did you install DBI/DBD::Sybase successfully? If yes let's see a snip
of your code.
Ilya
>
> Thanks in advance.
>
> Please send email to dbusby@houston.geoquest.slb.com
------------------------------
Date: 16 Jun 2001 08:25:41 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Access Sybase from PERL on NT
Message-Id: <db67a7f3.0106160725.6f7db691@posting.google.com>
You might also want to join the DBI users list. Just send mail to
dbi-user-help@perl.org. You would usually want to ask all db/DBI
related questions there.
Ilya
David Busby <dbusby3@slb.com> wrote in message news:<3B2A6B46.230A1369@slb.com>...
> Does anyone know how to access sybase from PERL running on NT with IIS.
> I have tried several times but keep getting the error that for some
> reason PERL can't load the sybperl::dblib or sybperl::ctlib dll files
> from dynaloader.pm. If anyone has any suggestions please let me know.
>
> Thanks in advance.
>
> Please send email to dbusby@houston.geoquest.slb.com
------------------------------
Date: Sat, 16 Jun 2001 09:48:26 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Re: Ack! Newbie still suffering from C-brain!
Message-Id: <3B2B7FCA.AE443259@mindspring.com>
"David H. Adler" wrote:
[snip]
>
> On a more practical note, you might want to read Effective Perl
> Programming by Joseph Hall (w/Randal Schwartz, but who cares about *him*
> ;-). Very good book for learning to write idiomatic Perl.
>
I agree. It's actually the reason I started looking at my code with a more
critical eye.
>
> dha
>
> --
> David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
> Honk if you love Perl! (or strawberries!) - Larry Wall
Remove the obvious anti-spam to reply.
------------------------------
Date: Sat, 16 Jun 2001 14:59:27 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: can't handle strings with \ ???
Message-Id: <992703567.00379675906151533.gnarinn@hotmail.com>
In article <9gdq23$5og$1@news.netmar.com>, <brunck@silverplatter.com> wrote:
>
>I've got a problem where I have a double quoted string being passed to a
>function, and the data in it is unfortunately delimited by a '\'. I can't
>split
>it up on that or use s/// on it because it's double-quoted, so when there's
>this sort of data:
>
>.. (hardback)\0-85649-756-9
>
>apparently the \0 gets interpreted first before s/// tries its thing, so I'm
>never able to
>translate the backslashes into anything else such as '\\'.
>
>Is there any way to get this string changed to a single-quoted string? Or
>some way to translate these \ into something else while the string is still
>double-quoted?
>
I think you are not understanding what the quotes do.
it does not matter if a string passed to a function was double-quoted
or single-quoted. a string is a string.
the quotes are just string 'constructors'.
so if you have this line in your code:
somefunc("(hardback)\0-85649-756-9");
but wanted to have a backslash and a zero in the argument, change it to
somefunc('(hardback)\0-85649-756-9');
or
somefunc("(hardback)\\0-85649-756-9");
maybe showing us actual code might help us finding your real problem.
gnari
------------------------------
Date: 16 Jun 2001 16:16:09 +0100
From: nobull@mail.com
Subject: Re: can't handle strings with \ ???
Message-Id: <u966dwpi9y.fsf@wcl-l.bham.ac.uk>
brunck@silverplatter.com writes:
> I've got a problem where I have a double quoted string being passed to a
> function,
The adjective "double quoted" (meaning subject to interpoation and
escape handing) is something that applies to strings in
Perl souce code, it does not apply to any entity that exists at
runtime and certaintly not to the string that is passed to a function.
The following are completely equivalent:
foo("bar\$ $baz");
foo('bar$ '. $baz);
> and the data in it is unfortunately delimited by a '\'. I can't
> split it up on that or use s/// on it because it's double-quoted,
No, sorry, that is jibberish.
> so when there's this sort of data:
>
> .. (hardback)\0-85649-756-9
>
> apparently the \0 gets interpreted first before s/// tries its
> thing,
There is no s/// in the above example.
> so I'm never able to
> translate the backslashes into anything else such as '\\'.
If these backslashes are in strings the program source code then
simply type '\\' when you mean '\'. If these backslashes are not in
strings in the program source then you are simply talking yourself into
believing there is a problem where there is none.
> Is there any way to get this string changed to a single-quoted
> string?
In a text editot move the cursor to the " character, delete it and
type a ' character. Repeat for the other end on the
string. (Alternatively if you are feeling pervese insert the letter q
in front of the opening double qoute).
> Or some way to translate these \ into something else while the string is still
> double-quoted?
As I have pointed out "while the string is double quoted" means "in
the source code of my script". Once again I'd suggest a text editor.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 16 Jun 2001 23:13:38 +0800
From: UNO <janawills@icqmail.com>
Subject: GREAT DISCOVERY!!!
Message-Id: <3B2B77A2.54CC5580@icqmail.com>
--------------F9830785182CCFCC6B46AFB9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Have a look at www.drho.com is a live casino with its REAL dealers over
video and REAL live games - no more playing against the random number
generators or the computer.
And from 6 July to 8 July, www.drho.com also offers the internet's first
world BlackJack tournament and US$10,000 is waiting you to be won. It's
fun to play and easy to win!!!
So enjoy your visit to www.drho.com!!!
--------------F9830785182CCFCC6B46AFB9
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Have a look at <font color="#3333FF">www.drho.com</font> is a live casino
with its REAL dealers over video and REAL live games - no more playing
against the random number generators or the computer.
<p>And from <font color="#FF0000">6 July to 8 July</font>, <font color="#3333FF">www.drho.com</font>
also offers the internet's first world BlackJack tournament and <font color="#FF0000">US$10,000</font>
is waiting you to be won. It's fun to play and easy to win!!!
<p>So enjoy your visit to <font color="#3333FF">www.drho.com</font>!!!
<br> </html>
--------------F9830785182CCFCC6B46AFB9--
------------------------------
Date: Sat, 16 Jun 2001 09:20:28 -0400
From: "Eldorado" <none@this.net>
Subject: Re: having trouble with system
Message-Id: <9gfmgm$dj4o$1@newssvr06-en0.news.prodigy.com>
"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87ofrpm7o2.fsf@limey.hpcc.uh.edu...
>
> You managed to snip the important part of the context in
> your reply. Note the "at this point", which was just
> after assigning to $choice at
>
> my $choice = getUserSelection;
>
> (or whatever it was). Try the additional debugging lines
> there, not in the literal assignment part.
>
> FYI: why did I suggest what I did? Well, obviously you
> noted that a literal assignment to $choice worked fine.
> So therefore the value in $choice in the real code is
> causing the problem. So locate the places where $choice
> is assigned to. There's only one, therefore we need to
> see what's in $choice after the assignment and that'll be
> the source of the error.
Tony
Not trying to be difficult, but I think you missed something in my original
post. It is not the value in $choice that is causing the problem. It
contains the expected value and retrieves the expected entry from %options.
The literal assignment was to $action, not $choice. And as I've explained
the content of $action, whether assigned via a literal or via a split of the
value in $options{$choice}, appears to be identical.
So in a nutshell, my question is: Why does system($action) fails when
$action has been populated via the split, but succeeds when $action is
populated with a literal, when the value of $action appears to be identical
in both cases?
That is the part that I'm not understanding, why the behavior is different
with what appear to be identical values. I can print $action in both cases
and the value appears to be the same, and likewise length($action) is the
same in both cases. I've even used one scalar to hold the split and another
to hold the literal, and then compared them with eq and they are the same.
So, what is different about $action in the two cases that would cause
system() to work with one but not the other?
Still confused, but trying :-)
grim
------------------------------
Date: Sat, 16 Jun 2001 14:48:55 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: How to make GetOpt::Long do what I want
Message-Id: <992702935.718604436144233.gnarinn@hotmail.com>
In article <a99dddab.0106151206.612f87d2@posting.google.com>,
Paul Johnson <pauljohn@ukans.edu> wrote:
>my %parameters =();
>GetOptions ("define=f@" => \%parameters) || die "Invalid arguments \n";
>
>However, all I get is a ton of errors if I try to use that with:
>$ perl newRunRB.pl --define numPPL=[100,101] --define vision=[1,2]
>
I think you should re-read the docs again
perldoc GetOpt::Long
there is no way to get GetOptions to take your commandline example
to create numeric arrays. but
GetOptions ("define=s%",\%def) || die "Invalid arguments \n";
will create the the hash
%def=(numPPL=>'[100,101]',vision=>'[1,2]');
(not array references, but strings, so more work needs to be done
or
GetOptions (\%parameters,"numPPL=f@","vision=f@");
with command line
perl newRunRB.pl --numPPL=100 --numPPL=101 --vision=1 --vision=2
will populate %parameters as you (probably) want:
%parameters=(numPPL=>[100,101],vision=>[1,2]);
but it is not the commandline syntax you want
gnari
------------------------------
Date: 16 Jun 2001 17:50:02 +0200
From: Joerg Behrens <jbehren@gwdg.de>
Subject: howto: recursive implicit method access via 'tie'?
Message-Id: <qg1yokl905.fsf@umpp07.gwdg.de>
If i use the 'tie' function to bind a class to a scalar
then it seems that recursive implicit method-calls are not
possible. From the example code (see below) i get
from main: v is tied to test=SCALAR(0x80fe8ec)
from fun: v is not tied, value is <old value>
value of v is <fun.out>
I would have expected to get
from main: v is tied to test=SCALAR(0x80fe8ec)
from fun: v is tied to test=SCALAR(0x80fe8ec)
value of v is <fun.out>
This behaviour looks more like a design-decision than like a bug but
i find recursive implicit method calls useful. Is there a way to get
this functionality with a trick in the tied class?
Thanks,
Jörg
Example code:
#----------------------------------------------------
#!/usr/bin/perl
package test;
sub TIESCALAR {
my $self = shift;
my $val = shift || "";
return bless \$val, $self;
}
sub FETCH {
my $ref=shift;
my $val=$$ref;
$val=&$val() if ref($val) eq "CODE";
return $val;
}
sub STORE {
my $self = shift;
$$self=$shift;
}
package main;
sub check_v {
if (tied($v)) {
print("$_[0]: v is tied to ",tied($v),"\n");
} else {
print("$_[0]: v is not tied, value is $v\n");
}
}
sub fun {
check_v('from fun');
return "<fun.out>";
}
$v="<old value>";
tie $v, 'test',\&fun;
check_v('from main');
print "value of v is $v\n";
#----------------------------------------------------
------------------------------
Date: 16 Jun 2001 17:24:27 +0100
From: nobull@mail.com
Subject: Re: howto: recursive implicit method access via 'tie'?
Message-Id: <u9snh0o0jo.fsf@wcl-l.bham.ac.uk>
Joerg Behrens <jbehren@gwdg.de> writes:
> This behaviour looks more like a design-decision than like a bug...
Actually to me it looks like a bug, to be specific it looks like bugs
20010411.004 and 20010329.009.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 16 Jun 2001 15:06:26 +0100
From: "alan@" <alan@headru.sh>
Subject: Re: HTML input box variables?
Message-Id: <9gfp2f$4ua$1@news8.svr.pol.co.uk>
Alan J. Flavell <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.30.0106161342360.12672-100000@lxplus003.cern.ch...
The point was not to demonstrate the perfect solution , nor was it intended
to be completely acceptable to the "experts". The idea was that this works
as it is and by copying and pasting into a .cgi and testing, then the
problem the original poster described, can be shown to disappear. The guy is
obviously not an expert, and I don't pretend to be either, but every little
helps to move forward.
We are all learning all the time, just because you may be more advanced is
no reason to baffle people with science, when all they need is a helping
hand to get moving.
I don't write text books.
Regards
Alan
------------------------------
Date: 16 Jun 2001 10:04:17 -0700
From: christopher_brien@hotmail.com (zero the hero)
Subject: Re: Looking for good tutorial/book on Perl programming.
Message-Id: <3bcda11.0106160904.12b1367e@posting.google.com>
"Wyzelli" <wyzelli@yahoo.com> wrote
>--
>($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down,
pass it
>around');
>$d='$_$a$s$b$w';$e='$_$a$s$b';sub
d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
>sub
>e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
>$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";
Shouldn't that be
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down,
pass it around');$d='$_$a$s$b$w';$e='$_$a$s$b';sub
d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);$c.="$f\n$g\n$t\n";$_--;$s=e($_);$i=d($d);$c.="$i\n\n";}print"$c*hic*";
------------------------------
Date: Sat, 16 Jun 2001 09:43:18 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Re: Marble lossage in "or" vs. "||"
Message-Id: <3B2B7E95.EF2B21D0@mindspring.com>
Bart Lateur wrote:
> pt wrote:
>
> >sub or_3()
> >{
> > # this doesn't work!
> > return 0 or 0 or (1 && 1 && 1) ;
> >}
>
> because it gets interpreted as
>
> (return 0) or 0 or (1 && 1 && 1);
>
> So it never gets to the remainder of the statement.
>
> Remember, the precedence of "or" is extremely low. Lower than most
> expressions commonly looked at as statements, anyway.
>
I had assumed (incorrectly) that the "return" would be a "special
case", and be the lowest precedence. It would wait for the bride &
groom to depart, the guests to leave, the band to pack up, and the
cleaning crew to start before it grabbed the leftovers. Guess that just
ain't so.
Remove the obvious anti-spam to reply.
------------------------------
Date: Sat, 16 Jun 2001 17:51:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Marble lossage in "or" vs. "||"
Message-Id: <677nitgfr945rc3e73r0qal709anpult3c@4ax.com>
pt <mnemotronic@mind\no-spam/spring.com> wrote:
> I had assumed (incorrectly) that the "return" would be a "special
>case", and be the lowest precedence. It would wait for the bride &
>groom to depart, the guests to leave, the band to pack up, and the
>cleaning crew to start before it grabbed the leftovers. Guess that just
>ain't so.
Me too, actually. But I knew what to suspect when things behaved
strangely.
--
Bart.
------------------------------
Date: Sat, 16 Jun 2001 11:26:57 -0500
From: Jerry Preston <g-preston1@ti.com>
Subject: missing spaces
Message-Id: <3B2B88D1.990BB1E0@ti.com>
Hi,
I need some help. When I read a text file and display it on a web site all the spacing is missing.
Why? How do I print the text with all the spacing with out a complete re spacing of each line?
open( FP, "$fn/$file" ) || die "cannot open view_file file $fn/$file $!\n";
while( <FP> ) {
print "$_<br>";
}
close FP;
Thanks for Your HELP!
Jerry
------------------------------
Date: Sat, 16 Jun 2001 09:56:27 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: missing spaces
Message-Id: <mbudash-8055FA.09562716062001@news.pacbell.net>
In article <3B2B88D1.990BB1E0@ti.com>, Jerry Preston
<g-preston1@ti.com> wrote:
> Hi,
>
> I need some help. When I read a text file and display it on a web site
> all the spacing is missing.
> Why? How do I print the text with all the spacing with out a complete re
> spacing of each line?
>
> open( FP, "$fn/$file" ) || die "cannot open view_file file $fn/$file
> $!\n";
> while( <FP> ) {
> print "$_<br>";
> }
> close FP;
>
> Thanks for Your HELP!
>
> Jerry
web browsers compress repeating whitespace into a single space unless
instructed not to do so. try wrapping your code with '<pre>' tags like
so:
print "<pre>\n";
open(FP, "$fn/$file") || die "can't open view_file file $fn/$file $!\n";
while( <FP> ) {
print "$_<br>";
}
close FP;
print "</pre>\n";
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sat, 16 Jun 2001 17:06:07 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: missing spaces
Message-Id: <Xns90C285CF41433echangnetstormnet@207.106.92.86>
Jerry Preston <g-preston1@ti.com> wrote in
<3B2B88D1.990BB1E0@ti.com>:
> Hi,
>
> I need some help. When I read a text file and display it on a web
> site all the spacing is missing. Why? How do I print the text with
> all the spacing with out a complete re spacing of each line?
>
> open( FP, "$fn/$file" ) || die "cannot open view_file file
> $fn/$file $!\n"; while( <FP> ) {
> print "$_<br>";
> }
> close FP;
This is not related to Perl or even to CGI. The normal display of HTML
reduces all spaces and tabs in the source code to a single space. If
you want to reproduce the text formatting verbatim, you need to use the
appropriate HTML formatting. The tags you should look up are <PRE> and
<TT> (or <CODE>). If all of the content is plain text, you can send a
content type header of text/plain instead of text/html.
--
EBC
------------------------------
Date: Sat, 16 Jun 2001 19:21:17 +0200
From: Philip Newton <pne-news-20010616@newton.digitalspace.net>
Subject: Re: missing spaces
Message-Id: <9a5nit008hk5a8abrpk4n3b2tk2ttpt1ds@4ax.com>
On Sat, 16 Jun 2001 11:26:57 -0500, Jerry Preston <g-preston1@ti.com>
wrote:
> Why? How do I print the text with all the spacing with out a complete re
> spacing of each line?
Tell the client that you're sending out text/plain and not text/html, if
what you are sending *is* plain text and not HTML.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 16 Jun 2001 17:56:17 +0100
From: nobull@mail.com
Subject: Re: missing spacse
Message-Id: <u9puc4nz2m.fsf@wcl-l.bham.ac.uk>
Jerry Preston <g-preston1@ti.com> writes:
> Newsgroups: comp.lang.perl.misc
> I need some help.
But not help related to Perl! Your problem is purely related to HTML.
> When I read a text file and display it on a web site all the spacing is missing.
I take it that you are displaying it as HTML. Any amount of
whitespace in HTML is equivalent to a single space (except within
<PRE></PRE>).
> How do I print the text with all the spacing with out a complete re
> spacing of each line?
Enclose it in <PRE></PRE>.
This also instructs the browser to use a monspaced font - which is
kinda important if you are tring to use spaces to make your text line
up.
> open( FP, "$fn/$file" ) || die "cannot open view_file file $fn/$file $!\n";
> while( <FP> ) {
> print "$_<br>";
> }
Inside <PRE> you won't need the <BR>.
You may also want to consider using escapeHTML() in case the file
contains any '<' or '&'.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sun, 17 Jun 2001 02:17:29 +0900
From: "Lee Seung K." <vrman@sl2sys.co.kr>
Subject: more than one execution for wait?
Message-Id: <9gg470$h4v$1@imsinews.kornet.net>
I'm really new to perl and shell programming.
My question may seem a little stupid but please bear with me :)
This is what I want to do. I have 500 queue directory for sendmail,
If I start queueing, sendmail starts up 500 sendmail childs to process the
queue.
That's far too much. The systems gonna complain that there's too much file
open.
It's vital that we have 500 queue directories as each directory has a limit
of number of
files it can contain(It really gets slow after certain number)
So I want sendmail to open 5 sendmail queue directories at a time, then
when it's done open next 5 sendmail queue directories and send out mail.
The problem with the code below is that it only sends the first line of
execute.
So only q1,q6,q11,q16.... directories get emptied and other queues don't get
sent.
exec("$commandexec2");
exec("$commandexec3");
exec("$commandexec4");
exec("$commandexec5");
lines get ignored.
I basically want to open 5 process as a set at a time...
which will wait for the each other to be done.
I'm new to this process stuff. It's hard ... but fun.
Any help would be greatly appreciated.
Thanks.
Regards,
Seung
============================================================================
======
while ($m < 501)
{
if (!defined($kidpid = fork())) {
die "cannot fork: $!";
}
if ($kidpid == 0) {
$commandexec1 =
"sendmail -OQueueDirectory=/var/spool/vqueue/q$m -q";
$commandexec2 =
"sendmail -OQueueDirectory=/var/spool/vqueue/q".($m+1)." -q";
$commandexec3 =
"sendmail -OQueueDirectory=/var/spool/vqueue/q".($m+2)." -q";
$commandexec4 =
"sendmail -OQueueDirectory=/var/spool/vqueue/q".($m+3)." -q";
$commandexec5 =
"sendmail -OQueueDirectory=/var/spool/vqueue/q".($m+4)." -q";
print "\n$commandexec1\n";
print "$commandexec2\n";
print "$commandexec3\n";
print "$commandexec4\n";
print "$commandexec5\n";
exec("$commandexec1");
exec("$commandexec2");
exec("$commandexec3");
exec("$commandexec4");
exec("$commandexec5");
# if the exec fails, fall through to the next statement
die "can't exec echo: $!";
} else {
print "I'm the parent process waiting\n";
wait;
print "I'm the parent process finished waiting\n";
}
undef $kidpid;
$m= $m+5;
}
------------------------------
Date: 16 Jun 2001 09:19:35 -0700
From: smk@fyi.net (smk)
Subject: Net::IRC connection problems: possible fix
Message-Id: <befb49b6.0106160819.201cabdf@posting.google.com>
I havent seen this anywhere else so I figured I would post it here.
When I first downloaded Net::IRC right away I got this error:
Connection to the server....
Can't connect to irc.nexlinks.net:6667! at
/usr/lib/perl5/site_perl/5.6.0/Net/IRC.pm line 192
Cannot Connect to the server at /home/xxx/testbot.pl line 7.
The guys at perlmonks.com helped me out right away. These guys are
great.
This is what you need to do:
Find the Connect.pm in your @INC:
On line 253 on Connection.pm you will see a chunk of code that looks
something like this:
# This bind() stuff is so that people with virtual hosts can select
# the hostname they want to connect with. For this, I dumped the
# astonishingly gimpy IO::Socket. Talk about letting the interface
# get in the way of the functionality...
#if ($self->hostname) {
# unless (bind( $sock, sockaddr_in( 0, inet_aton($self->hostname) )
)) {
# carp "Can't bind to ", $self->hostname, ": $!";
# $self->error(1);
# return;
# }
# }
Just simply comment the whole if statment out like I did and it should
work.
Again the guys at perlmonks saved me alot of time and searching.
Thanks guys!
smkNOSPAM@fyi.net
http://www.fyi.net/~smk
------------------------------
Date: 16 Jun 2001 17:27:48 GMT
From: barryallwood@aol.com (Barry Allwood)
Subject: Re: period
Message-Id: <20010616132748.19607.00001918@ng-fk1.aol.com>
Well, the period just seperates variables and file endings because It may cause
an error like because they are all together like this
print "thisfile$variable.bpe";
#This is wrong you end up calling a variable called $variable.bpe which does
not exist
Wheras :-
print "thisfile$variable".".bpe";
# Works fine
This line basically opens the file for later on where the programmer could do
this
print(<LOCATION>, "Data");
which would print to the file that had been opened
Hope that helped!
Barry
------------------------------
Date: Sat, 16 Jun 2001 14:16:26 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: quick array question
Message-Id: <Xns90C2690A2E3CFechangnetstormnet@207.106.92.86>
Abe Timmerman <abe@ztreet.demon.nl> wrote in
<96fmitsfml6lbkc7jibuusgt0i4qp1fdhp@4ax.com>:
>On Fri, 15 Jun 2001 16:21:12 GMT, echang@netstorm.net (E.Chang)
>wrote:
>> foreach (@rows) {
>> $fields = $tildes if (my $tildes = tr/~/~/) > $fields;
>> }
>> print $fields+1;
>
>Global symbol "$tildes" requires explicit package name at try.pl
>line 7.
>
>The if-statement modifier can't 'create' a lexical for the statement
>itself. You'll have to declare it before the statement + modifier.
>
> foreach (@rows) {
> my $tildes;
> $fields = $tildes if ($tildes = tr/~/~/) > $fields;
> }
Thanks for pointing that out. I didn't realize the difference with the
modifier form of if. As must be obvious, I didn't use the "my" in
testing the fragment, but added it to the code I posted, thinking the
scope would be similar to the standard if construction.
--
EBC
------------------------------
Date: Sat, 16 Jun 2001 19:24:47 +0200
From: "Charles Betman" <charles@betman.demon.nl>
Subject: require-function fails on some servers
Message-Id: <992712166.3135.0.pluto.d4ee0b73@news.demon.nl>
Hi there,
I've got (on some servers, all Windows-servers so far) a problem with the
execution of the require-function. The following, very simple code,
- - - - -
#!/usr/bin/perl
require "cgi-lib.pl";
print "Hello world!<br>";
exit;
- - - - -
results in
- - - - - - -
Can't locate cgi-lib.pl in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib
.) at E:\domains\stmaarten
- - - - -
I'm quite sure the required file cgi-lib.pl is situated in the same
directory as the cgi-script I'm executing. And the same script works fine on
several other (UNIX-, Linus- and windows-)servers.
On the servers where the require-function fails I tried the following:
- - - - -
opendir(DIR, ".");
@list = readdir(DIR);
closedir DIR;
- - - - -
I was suprised to find that @list contained the files of the
parent-directory of cgi-bin, and not the files of the cgi-bin itself as is
the case on the servers where all works fine.
Does anyone know what the problem is, and more important, how to get rid of
it?
Met vriendelijke groet,
Charles
http://www.betman.nl/
------------------------------
Date: 16 Jun 2001 12:30:35 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: require-function fails on some servers
Message-Id: <87snh0z610.fsf@limey.hpcc.uh.edu>
>> On Sat, 16 Jun 2001 19:24:47 +0200,
>> "Charles Betman" <charles@betman.demon.nl> said:
> Hi there, I've got (on some servers, all Windows-servers
> so far) a problem with the execution of the
> require-function. The following, very simple code,
> - - - - - #!/usr/bin/perl require "cgi-lib.pl"; print
> "Hello world!<br>"; exit; - - - - -
> results in
> - - - - - - - Can't locate cgi-lib.pl in @INC (@INC
> contains: C:/Perl/lib C:/Perl/site/lib .) at
> E:\domains\stmaarten - - - - -
> I'm quite sure the required file cgi-lib.pl is situated
> in the same directory as the cgi-script I'm
> executing. And the same script works fine on several
It's probably in the same directory as the program is
located, but in this case not in the same directory as it
is executing. Relative paths are a bad assumption in CGI
environments.
This doesn't have anything to do with perl, it's a
webserver/CGI issue. comp.infosystems.www.authoring.cgi
is probably a better group to ask in (fup set) and also
take a look at
http://www.boutell.com/openfaq/cgi/8.html
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: 16 Jun 2001 12:36:31 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: require-function fails on some servers
Message-Id: <87ofroz5r4.fsf@limey.hpcc.uh.edu>
[ aaack, hit send too quickly ]
>> On Sat, 16 Jun 2001 19:24:47 +0200,
>> "Charles Betman" <charles@betman.demon.nl> said:
> #!/usr/bin/perl
-w and use strict;
> require "cgi-lib.pl";
cgi-lib ? You should update your code to use CGI.pm.
It's a standard part of perl releases and thus relieves
you of this problem and fixes other potential holes in one
fell swoop.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Sat, 16 Jun 2001 13:09:13 -0400
From: "Michal T. Winter" <mwinter@goldenapple.com>
Subject: Server Side Includes on IIS
Message-Id: <3B2B92B8.E74BB5D7@goldenapple.com>
Does anyone know if you can include a "PL" as a SSI on an IIS server and
how to do it. It does not support it out of the box.
Warren Winter
------------------------------
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.
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 1145
***************************************