[18348] in Perl-Users-Digest
Perl-Users Digest, Issue: 516 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 17 18:10:38 2001
Date: Sat, 17 Mar 2001 15:10:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984870617-v10-i516@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 17 Mar 2001 Volume: 10 Number: 516
Today's topics:
Re: linebreaks in a system call (Garry Williams)
Re: linebreaks in a system call (Logan Shaw)
Re: linebreaks in a system call (Abigail)
Re: linebreaks in a system call (Abigail)
Re: linebreaks in a system call (Garry Williams)
Re: linebreaks in a system call (Logan Shaw)
Re: linebreaks in a system call (Garry Williams)
Re: PERL and ASP (Abigail)
Re: perl hacker wanted <joe+usenet@sunstarsys.com>
Re: perl hacker wanted (Tad McClellan)
Re: Print to file nobull@mail.com
Re: Print to file <godzilla@stomp.stomp.tokyo>
Re: Print to file <ben.sugars@home.com>
Re: Simple Email @ Parsing Solution? nobull@mail.com
Re: Simple Email @ Parsing Solution? (Abigail)
Re: Sol 2.8, Perl 5.6.0 - Bug with getpwent? (Abigail)
Re: Sol 2.8, Perl 5.6.0 - Bug with getpwent? (Garry Williams)
Specify variable in a literal list <pigpen@easynews.com>
Re: Specify variable in a literal list <joe+usenet@sunstarsys.com>
Re: Specify variable in a literal list (Tad McClellan)
Starting a non-terminating program from within a CGI sc <edinburghguy21@yahoo.com>
Re: Starting a non-terminating program from within a CG (Logan Shaw)
Re: Subroutine in separate files (Abigail)
Re: Subroutine in separate files (Martien Verbruggen)
Re: Username/password from an HTML form (Abigail)
Re: using variable content as constant name (Abigail)
way to check a pop3 mailbox without using additional mo <paulthomson@hotmail.com>
Re: way to check a pop3 mailbox without using additiona (Logan Shaw)
Re: way to check a pop3 mailbox without using additiona (Garry Williams)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 17 Mar 2001 19:16:46 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: linebreaks in a system call
Message-Id: <yKOs6.72$ez4.3092@eagle.america.net>
On 17 Mar 2001 18:58:38 GMT, Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk> wrote:
>In article <7bOs6.67$ez4.2676@eagle.america.net>,
>Garry Williams <garry@zvolve.com> wrote:
>>On 17 Mar 2001 17:44:17 GMT, Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk>
>>wrote:
>
> That odd.. I tried that... Wait no, I tired
>
>system("ls",
> " -l";
>
> Why does system("ls"," -l"); fail
I presume that "fail" means that the /bin/ls program complains about
its arguments. /bin/ls expects its options to start with `-' not ` '.
When you type `ls -l' on a command line, the shell parses the line
into words so that /bin/ls is eventually called with "ls" as its
*argv[0] and "-l" as its *argv[1]. When you tell perl to call /bin/ls
with the parameters "ls" and " -l", /bin/ls squawks. (It actually
"sees" the " -l" as a file name because it cannot be an option.)
>when
>print("ls"," -l"); work?
By "work", I assume you mean that it produced the string "ls -l" on
the stdout. That's because of the definition of print(). It takes a
list and simply outputs it to the file without anything in between the
elements of the list. (Assuming the default value of $,.)
--
Garry Williams
------------------------------
Date: 17 Mar 2001 13:19:59 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: linebreaks in a system call
Message-Id: <990dcv$3qn$1@boomer.cs.utexas.edu>
In article <990c4u$d16$1@niobium.hgmp.mrc.ac.uk>,
Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk> wrote:
> Why does system("ls"," -l"); fail when
>print("ls"," -l"); work?
For the same reason that typing
ls " -l"
fails at the shell command line. Both call "ls" with " -l" as its
first argument.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: 17 Mar 2001 19:30:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: linebreaks in a system call
Message-Id: <slrn9b7er9.7eb.abigail@tsathoggua.rlyeh.net>
Mr. M.J. Lush (mlush@hgmp.mrc.ac.uk) wrote on MMDCCLV September MCMXCIII
in <URL:news:9907ph$c7c$1@niobium.hgmp.mrc.ac.uk>:
^^ I'm not sure if this is a perl or a UNIX question
^^ but....
^^
^^ I'm writing a program with some very long system calls,
^^ which look ugly and unreadable when wordwrapped by the editor.
^^
^^ How do I split a UNIX system call over two or
^^ more lines?
^^
^^ ie write:-
^^ system("ls -l");
^^
^^ as
^^ system("ls
^^ -l");
That's really a question better asked in comp.os.unix.
You follow whatever rules your shell used, usually a backwhack at the
end of the line.
So:
system 'ls \
-l';
If you use interpolation (double quotes), you need to escape the
backslash lest Perl doesn't eat it:
system "ls \\
-l";
Or you could just do:
system qq{@{["ls",
"-l"]}};
Or:
my $command = <<EOT;
ls
-l
EOT
$command =~ s/\n/ /g;
system $command;
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
Date: 17 Mar 2001 19:32:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: linebreaks in a system call
Message-Id: <slrn9b7eui.7eb.abigail@tsathoggua.rlyeh.net>
Garry Williams (garry@zvolve.com) wrote on MMDCCLV September MCMXCIII in
<URL:news:7bOs6.67$ez4.2676@eagle.america.net>:
?? On 17 Mar 2001 17:44:17 GMT, Mr. M.J. Lush <mlush@hgmp.mrc.ac.uk>
?? wrote:
??
?? > How do I split a UNIX system call over two or
?? >more lines?
?? >
?? >ie write:-
?? >system("ls -l");
?? >
?? >as
?? >system("ls
?? > -l");
??
?? Here's two ways:
??
?? system("ls"
?? . " -l");
??
?? system("ls",
?? "-l");
??
?? The latter is preferred since it avoids using the shell.
I would phrase that as "the latter doesn't use the shell".
You sound as if using the shell is a bad thing. If it's so bad, why do many
people use shells?
Abigail
------------------------------
Date: Sat, 17 Mar 2001 19:49:18 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: linebreaks in a system call
Message-Id: <2dPs6.76$ez4.3092@eagle.america.net>
On 17 Mar 2001 19:32:34 GMT, Abigail <abigail@foad.org> wrote:
>Garry Williams (garry@zvolve.com) wrote on MMDCCLV September MCMXCIII in
><URL:news:7bOs6.67$ez4.2676@eagle.america.net>:
>??
>?? Here's two ways:
>??
>?? system("ls"
>?? . " -l");
>??
>?? system("ls",
>?? "-l");
>??
>?? The latter is preferred since it avoids using the shell.
>
>
>I would phrase that as "the latter doesn't use the shell".
>
>You sound as if using the shell is a bad thing. If it's so bad, why do many
>people use shells?
Didn't intend to malign the shell. I'm one of those people. :-) I
meant it avoids an unnecessary step.
--
Garry Williams
------------------------------
Date: 17 Mar 2001 14:05:15 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: linebreaks in a system call
Message-Id: <990g1r$44p$1@boomer.cs.utexas.edu>
In article <7bOs6.67$ez4.2676@eagle.america.net>,
Garry Williams <garry@zvolve.com> wrote:
> system("ls"
> . " -l");
>
> system("ls",
> "-l");
>
>The latter is preferred since it avoids using the shell.
Hmm... Don't they *both* avoid using the shell?
From "perldoc -f system":
If there is only one scalar argument, the
argument is checked for shell metacharacters, and if
there are any, the entire argument is passed to the
system's command shell for parsing (this is `/bin/sh
-c' on Unix platforms, but varies on other
platforms). If there are no shell metacharacters in
the argument, it is split into words and passed
directly to `execvp', which is more efficient.
At least, I assume "-" isn't considered a metacharacter. It would be
nice if there were some way of knowing besides looking at the source or
trying various characters while tracing the perl process.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Sat, 17 Mar 2001 21:21:43 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: linebreaks in a system call
Message-Id: <HzQs6.91$ez4.3964@eagle.america.net>
On 17 Mar 2001 14:05:15 -0600, Logan Shaw <logan@cs.utexas.edu> wrote:
>In article <7bOs6.67$ez4.2676@eagle.america.net>,
>Garry Williams <garry@zvolve.com> wrote:
>> system("ls"
>> . " -l");
>>
>> system("ls",
>> "-l");
>>
>>The latter is preferred since it avoids using the shell.
>
>Hmm... Don't they *both* avoid using the shell?
Well, er... Yes, now that you point that out. :-)
--
Garry Williams
------------------------------
Date: 17 Mar 2001 19:37:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: PERL and ASP
Message-Id: <slrn9b7f89.7eb.abigail@tsathoggua.rlyeh.net>
rapid_response (rapid_response@memecdesign.com) wrote on MMDCCLIV
September MCMXCIII in <URL:news:BIEFIDFMNNNMGFCLKGEOAEEMCAAA.rapid_response@memecdesign.com>:
:: Hello Perl Guru’s
::
:: I am new to PERL, however, I have searched endlessly for two days to be in
:: the know. My search began when my boss handed me a perl file and asked me
:: to impliment a procedure to unleash its magic on our intranet users. The
:: procedure requires a data file to be uploaded to the webserver and read by
:: the perl file to write an fpga (field programmable gate array)graphical
:: layout onto an html page. The perl file runs appropriately from the command
:: line. My question is, how can I programmatically launch the perl file from
:: an active server page after the asp uploads the data file to the webserver.
:: It seems to me that there ought to be a way to achieve the command line
:: result with two or three lines of script. I have searched to no avail.
:: Your assistance would be greatly appreciated in this regard.
Well, in the same way you call a C program, or an Ada program from ASP.
Your problem is with calling external programs from ASP - the mere fact
the program you want to call happens to be a Perl program doesn't make
it a Perl program.
I'm afraid you wasted two days searching in the wrong corner of the
universe.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: 17 Mar 2001 14:11:28 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: perl hacker wanted
Message-Id: <m3n1aktdlr.fsf@mumonkan.sunstarsys.com>
minorseventhSPAMBLOCK@earthlink.net (Jim Kroger) writes:
> In article <3ab15fc8$1@news.microsoft.com>, "Jürgen Exner" <juex@deja.com>
> wrote:
>
> > Does the charta of any individual comp.* or comp.lang.* group allows job
> > postings?
> > If not, then you don't need to search further.
> >
> > Job posting in USENET are not allowed unless specifically authorized by the
> > group charta. It's as easy as that.
> >
> > jue
>
> Actually, if the charter does not specifically state one way or the other
> about an issue, then there is no policy on the issue for that newsgroup.
> General usenet policy and ettiquete prohibits posting off topic posts, and
> commercial posts. A post in a perl group looking for a perl programmer can
> reasonably be interepreted as being neither. So you should find the
> charter and see if it strictly prohibits job postings. If it doesn't, then
> there's no problem with them.
Nonsense- job postings *are* commercial ("help wanted") ads.
From "How to find the right place to post (FAQ)":
http://www.faqs.org/faqs/finding-groups/general/
[...]
2) Commercial Advertisements
The general rule of thumb is that you need to take the time to learn
where your advertisement is appropriate before you post it. If you
are not sure where your advertisement is appropriate, don't post it.
Another good rule of thumb is that unless the group's charter or FAQ
specifically mentions that some limited types of advertising are
welcome, you should assume that no commercial postings are allowed.
Most Usenet users strongly disapprove of business advertising in
non-business-related groups. In particular, anything that looks like
a pyramid scheme or chain letter will draw floods of critical e-mail
to both you and your machine administrators. Posting about a few
items for sale, _or a job opening_, _in an appropriate newsgroup_
(such as misc.forsale. or misc.jobs.) is OK; posting an ad for your
business to a hundred groups is not.
See also the Usenet Advertising FAQs in news.announce.newusers and
biz.marketplace.discussion...
> If this is true, and somebody has built a bot to remove those postings,
> they are doing so in well-intentioned error.
Fortunately, what you've written simply isn't true. Knitting a tapestry
out of camel hairs isn't discussed in the charter, either. That doesn't
make it OK for someone to post a question about it here, even if the
loom is driven by a Perl script.
--
Joe Schaefer "This isn't right, this isn't even wrong."
-- Wolfgang Pauli
------------------------------
Date: Sat, 17 Mar 2001 14:55:47 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl hacker wanted
Message-Id: <slrn9b7ga3.cpi.tadmc@tadmc26.august.net>
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>Fortunately, what you've written simply isn't true. Knitting a tapestry
>out of camel hairs isn't discussed in the charter, either.
How can I make my Camel's hair grow faster?
>That doesn't
>make it OK for someone to post a question about it here, even if the
>loom is driven by a Perl script.
Oh...
... sorry.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Mar 2001 19:15:10 +0000
From: nobull@mail.com
Subject: Re: Print to file
Message-Id: <u9elvwky0x.fsf@wcl-l.bham.ac.uk>
I've almost given up lizard-baiting but at least one of the errors
(the race condition) in this bit of advice is sufficienly subtle that
a newbie might not notice it.
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> There is a work around to emulate file locking
> on a Win 32 box. Basic principles are displayed
> by this code snippet:
s/principles/errors/
Please ignore Godzilla's broken lockfile code unless you are looking
for specimen code to put in an "explain what's wrong with the
following" exam question. A good student should be able to find half
a dozen errors.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 17 Mar 2001 11:56:03 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Print to file
Message-Id: <3AB3C153.492EDDF@stomp.stomp.tokyo>
"Randal L. Schwartz" wrote:
> Godzilla! wrote:
(snippage not noted by Randal)
> > There is a work around to emulate file locking
> > on a Win 32 box. Basic principles are displayed
> > by this code snippet:
> > while ( -e "filelock.tmp" )
> > { sleep(1); }
> Godzilla!> open(FILELOCK,"> filelock.tmp");
> Basic fragile principles, that is.
These principles displayed are, as stated, quite
basic and, quite sound, well beyond fragile.
They will work fine for all average conditions. My note
of "basic principles" is a cue for a reader to use more
advanced techniques, if needed. This concept of basic
principles is additionally noted by my tossing in a Unix
style change mode snippet, as a courtesy.
Verification of these basic principles can be accomplished
by creating 'filelock.tmp' in a test directory then running
this test snippet:
#!perl
$counter = 0;
while ( -e "filelock.tmp" )
{
print "locked\n"; sleep(1);
$counter++;
if ($counter == 4)
{ last; }
}
I have added a counter to prevent a runaway while loop.
This test script, when run under a dos box or run at
a unix style command prompt, will display an adequate
time delay to virtually eliminate any race condition.
Later, if you want to test the metal of these basic
principles, with the assistance of one or more friends,
you can load a web server with a cgi style test script
containing my exemplified basic principles, which makes
a quick print of sorts originating from a data base file
which is modified using controls to highlight any errors,
then have each friend run repeated multiple instances of
this test script as quickly as is possible. No problems
will be encountered. The probability of two or more
instances of this test script being initiated at the
exact same moment, being initiated within a time frame
needed to create a problem, are greater than your odds
of winning a state lottery.
> There's a race condition between testing for the sentinel file,
> and actually creating it. So two processes will occasionally
> end up both believeing they have the exclusive access to the
> resource.
For a server experiencing exceptionally heavy traffic, such as
Yahoo, Microsoft and others of this size and intensity of business,
this race condition is an extremely remote possibility. I tend to
doubt, however, this originating author is Bill Gates. My one second
delay is usually more than adequate to handle these rare conditions.
This delay could be increased to two seconds which would virtually
elminate any race condition.
Nonetheless Randal, although your remarks are quite valid under
very rare circumstances, an owner or an operator of a system similar
to Yahoo or Microsoft, would not be here in this newsgroup asking
how to do this.
What absolutely foolproof methodology would you suggest for
these circumstances of emulating a file lock on a Win 32 box?
Godzilla!
------------------------------
Date: Sat, 17 Mar 2001 22:20:19 GMT
From: Benjamin Sugars <ben.sugars@home.com>
Subject: Re: Print to file
Message-Id: <Pine.LNX.4.21.0103171708420.31446-100000@localhost.localdomain>
On Sat, 17 Mar 2001, Godzilla! wrote:
> "Randal L. Schwartz" wrote:
>
> > Godzilla!> open(FILELOCK,"> filelock.tmp");
>
> > Basic fragile principles, that is.
>
> These principles displayed are, as stated, quite
> basic and, quite sound, well beyond fragile.
To the OP stuck trying get some work done and being distracted by Kira's
raving, you can safely ignore her.
If you need further proof of her errors -- even disregarding the race
condition -- consider how her "beyond fragile" solution would behave
should a process terminate abnormally (eg, SIGTERM) while it holds a lock.
Hint: filelock.tmp would still exist, so what would happen to the next
process doing C<-e "filelock.tmp">?
Cheers,
-Ben
--
Benjamin Sugars <ben.sugars@home.com>
------------------------------
Date: 17 Mar 2001 18:59:55 +0000
From: nobull@mail.com
Subject: Re: Simple Email @ Parsing Solution?
Message-Id: <u9hf0skyqc.fsf@wcl-l.bham.ac.uk>
Dave Davis <dave.davis@ultrainteractive.com> writes:
> I'm trying to grab an email address from a form, and paste it back into a
> sendmail message as a recipient. What's the simplest solution to handling
> the obvious problem (the @ character hangs... in the non-variable lines its
> escaped with /@ for sending).
There is no obvious problem. Can you produce a minimal, complete,
strict, warning-free script that illustrates the problem you are
encountering?
> I can fix this with a fairly long cut/reassembly routine, but I know there
> HAS to be some simple solution I'm missing.
I suspect you are trying to solve a non-existant problem.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 17 Mar 2001 19:41:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Simple Email @ Parsing Solution?
Message-Id: <slrn9b7ffe.7eb.abigail@tsathoggua.rlyeh.net>
Dave Davis (dave.davis@ultrainteractive.com) wrote on MMDCCLV September
MCMXCIII in <URL:news:B6D91659.112D%dave.davis@ultrainteractive.com>:
== I'm trying to grab an email address from a form, and paste it back into a
== sendmail message as a recipient. What's the simplest solution to handling
== the obvious problem (the @ character hangs... in the non-variable lines its
== escaped with /@ for sending).
I fail to see the problem you have. You have a value from a form, and
want to pass the value to an external program. Just do so.
== I can fix this with a fairly long cut/reassembly routine, but I know there
== HAS to be some simple solution I'm missing.
I can't fanthom what you need to cut and reassembly routines for.
You *do* use CGI.pm, don't you?
Abigail
--
use lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";
------------------------------
Date: 17 Mar 2001 19:44:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Sol 2.8, Perl 5.6.0 - Bug with getpwent?
Message-Id: <slrn9b7fkg.7eb.abigail@tsathoggua.rlyeh.net>
dennis (dennis.moreno@pop.safetran.com) wrote on MMDCCLIV September
MCMXCIII in <URL:news:3AB2838A.CCD277C7@pop.safetran.com>:
__ Can someone help with this code?
__
__ Solaris 2.8, perl 5.6.0
__
__ This code should sequentially read the /etc/passwd file and print out
__ the gcos field, login name field
__ and "No", if the password field contains *LK*(which means the account in
__ disabled), or "Yes" if it doesn't.
__
__ It seems like the reading of the /etc/passwd and /etc/shadow by
__ "getpwent" get out of sync.
getpwent gets its information from /etc/passwd.
That's right.
From /etc/passwd. *Not* /etc/shadow.
/etc/shadow contains the *LK*, while /etc/passwd will contain 'x' in
the password field.
Abigail
--
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Sat, 17 Mar 2001 21:08:20 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Sol 2.8, Perl 5.6.0 - Bug with getpwent?
Message-Id: <8nQs6.89$ez4.3964@eagle.america.net>
On Fri, 16 Mar 2001 21:20:13 GMT, dennis <dennis.moreno@pop.safetran.com> wrote:
>Can someone help with this code?
>
>Solaris 2.8, perl 5.6.0
>
>This code should sequentially read the /etc/passwd file and print out
>the gcos field, login name field
>and "No", if the password field contains *LK*(which means the account in
>disabled), or "Yes" if it doesn't.
>
>It seems like the reading of the /etc/passwd and /etc/shadow by
>"getpwent" get out of sync.
>
>Can anyone shed some light on what might be happening?
This is interesting.
$ uname -a
SunOS zweb 5.7 Generic_106541-11 sun4u sparc SUNW,Ultra-60
$ perl -wle 'setpwent;print join ":", getpwent'
root:52tc0Ygt39ltg:0:1::Super-User:Super-User:/root:/bin/sh
$ perl -wle 'setpwent;while(@a=getpwent){last if \
$a[0]eq"zpersist"}print join ":", @a'
zpersist:x:60004:60009::Conscious Persistence Agent:Conscious \
Persistence Agent:/:/bin/sh
$ sudo grep zpersist /etc/shadow
Password:
zpersist:*LK*:::::::
The first try *seems* to return root's password, but I checked and it
is not correct. It's the password from another user's NIS+ entry.
(The value's munged for posting here. I have administrator privileges
in NIS+, which is why I think anything other than `x' is returned in
the first place.)
The answer is in the manual.
getpwent(3C) explicitly says that the pw_passwd member of the passwd
struct is "no longer used" and directs the reader to the getsp*(3C)
functions.
The Perl manual says it should work, if the OS does it right:
... Shadow password files are only supported if your vendor
has implemented them in the intuitive fashion that calling the regular C
library routines gets the shadow versions if you're running under
privilege. Those that incorrectly implement a separate library call are
not supported.
The Solaris manual indicates that getpwent() is inappropriate and the
Perl manual insists that that's the only way to do it.
The value of the passwd field is invalid, so you cannot do what you
wanted to do with a Perl program using the getpw*() functions. The
task requires the getsp*() functions in Solaris and Perl doesn't
support them.
--
Garry Williams
------------------------------
Date: Sat, 17 Mar 2001 20:07:10 GMT
From: "Nancy" <pigpen@easynews.com>
Subject: Specify variable in a literal list
Message-Id: <OtPs6.9579$cn4.779506@news.easynews.com>
I'm not a programmer. I wish to incorporate the Business::UPS perl module
into another script.
use lib '.';
use Business::UPS;
($shipping,$ups_zone,$error) = getUPS(qw/GNDCOM 46818 11111 13/);
The above line passes the 4 required information items the Business::UPS
module and returns $shipping, $ups_zone, and $error properly. My problem is
I can't figure out how to properly format the line to use variables.
For example, I'd like to replace /GNDCOM 46818 11111 13/ with /$method 46818
$to_zip $weight/ but can't seem to get the syntax right. The variables would
come from a user input form, but I can't even get it to work when I declare
the variable as follows:
$weight = 13;
Hope this isn't too sketchy. Any help appreciated.
TIA!
nan-
------------------------------
Date: 17 Mar 2001 16:05:11 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Specify variable in a literal list
Message-Id: <m3hf0st8c8.fsf@mumonkan.sunstarsys.com>
"Nancy" <pigpen@easynews.com> writes:
> ($shipping,$ups_zone,$error) = getUPS(qw/GNDCOM 46818 11111 13/);
>
> The above line passes the 4 required information items the Business::UPS
> module and returns $shipping, $ups_zone, and $error properly. My
> problem is I can't figure out how to properly format the line to use
> variables.
>
> For example, I'd like to replace /GNDCOM 46818 11111 13/ with /$method
> 46818 $to_zip $weight/ but can't seem to get the syntax right.
If you write
# same as "\$method", "46818", "\$to_zip", "\$weight"
qw / $method 46818 $to_zip $weight / # Perl's quote-word operator
Perl's qw operator will treat each "word" literally. See the
documentation on qw in perlop
% perldoc perlop
What you need is for $method to be "interpolated" to 13 when passing
it to getUPS(). If you get rid of the qw operator and put in the
appropriate commas, you should be fine (you don't even need to quote
46818, since Perl knows it's a number and not a bareword.)
my ($shipping,$ups_zone,$error) = getUPS($method, 46818, $to_zip, $weight);
HTH
--
Joe Schaefer "When the end of the world comes, I want to be in Cincinnati.
Everything happens ten years later there."
--Mark Twain
------------------------------
Date: Sat, 17 Mar 2001 15:05:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Specify variable in a literal list
Message-Id: <slrn9b7grv.cpi.tadmc@tadmc26.august.net>
Nancy <pigpen@easynews.com> wrote:
> Subject: Specify variable in a literal list
Errr, if you put a variable in there, then it cannot be a _literal_ list :-)
>I'm not a programmer. I wish to incorporate the Business::UPS perl module
>into another script.
Then you need to become a wee bit of a programmer, as some
programming is going to be required to effect that change.
You need to figure out "lists" in Perl.
>use lib '.';
>use Business::UPS;
>
>($shipping,$ups_zone,$error) = getUPS(qw/GNDCOM 46818 11111 13/);
^^^^^^^^^^^^^^^^^^^^^^^^
The getUPS() function takes 4 arguments, so you need a 4-element
list in the parenthesis.
qw// returns a list of the split-up parts (4 parts for your string).
The return value from qw// is being used to supply the list of
arguments for getUPS().
You can just supply your own list of things instead of using
qw//, as below.
>The above line passes the 4 required information items the Business::UPS
>module and returns $shipping, $ups_zone, and $error properly. My problem is
>I can't figure out how to properly format the line to use variables.
qw// is a shortcut (quote words). Let's unshorten it:
... = getUPS('GNDCOM', 46818, 11111, 13); # 4 element list
or if you want 4 strings instead of 1 string and 3 numbers:
... = getUPS('GNDCOM', '46818', '11111', '13');
>For example, I'd like to replace /GNDCOM 46818 11111 13/ with /$method 46818
>$to_zip $weight/ but can't seem to get the syntax right.
It is easier to see what to replace now that the shortcut isn't
obscuring what is going on.
... = getUPS($method, '46818', $to_zip, $weight);
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 17 Mar 2001 22:33:57 GMT
From: "Jambo" <edinburghguy21@yahoo.com>
Subject: Starting a non-terminating program from within a CGI script (continued)
Message-Id: <pDRs6.4706$e16.2330299@news2.cableinet.net>
Sorry about that, pressed enter and the message got sent.
In my Perl CGI script, I have a system() call which runs the shell script.
The shell script in turn runs the java server as a background process,
meaning that the shell script does actually complete if run from the unix
prompt.
When I run this perl CGI script from the Web, everything works OK - the
shell script is run and the java program starts running, and keeps running.
The only problem is that on both Netscape and IE, the browser loading bar
never completes - it is continually loading the page in other words.
Is this because the java program which is run as a background process is
still a part of the CGI process? If I press the "Stop" button in IE, the
browser stops and everything is perfect again and the java program is still
runnning in the background (what I want to happen)
In Netscape, if I press "Stop", it claims that the page cannot be found
which is nonsense.
Any ideas on how to get the page to load fully, instead of waiting for the
java prog?
Would be very grateful if anyone could help
Thanks
Gary
------------------------------
Date: 17 Mar 2001 16:51:45 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Starting a non-terminating program from within a CGI script (continued)
Message-Id: <990pq1$4n6$1@boomer.cs.utexas.edu>
In article <pDRs6.4706$e16.2330299@news2.cableinet.net>,
Jambo <edinburghguy21@yahoo.com> wrote:
>In my Perl CGI script, I have a system() call which runs the shell script.
>The shell script in turn runs the java server as a background process,
>meaning that the shell script does actually complete if run from the unix
>prompt.
>
>When I run this perl CGI script from the Web, everything works OK - the
>shell script is run and the java program starts running, and keeps running.
>The only problem is that on both Netscape and IE, the browser loading bar
>never completes - it is continually loading the page in other words.
>
>Is this because the java program which is run as a background process is
>still a part of the CGI process? If I press the "Stop" button in IE, the
>browser stops and everything is perfect again and the java program is still
>runnning in the background (what I want to happen)
I assume you're doing this on Unix. (You didn't say.)
My guess is that it's because the web server has connected a pipe to
the CGI's standard output, and it's reading from that pipe waiting
for it to close. However, your CGI's child process inherit the
CGI's standard output and thus the connection to the pipe. Thus,
until they all close, the web server won't see them as finished.
One solution is to fork(), then do as it says in
"perldoc -q 'fork a daemon'", then exec() your child process.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: 17 Mar 2001 19:54:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Subroutine in separate files
Message-Id: <slrn9b7g73.7eb.abigail@tsathoggua.rlyeh.net>
Damian James (damian@qimr.edu.au) wrote on MMDCCLV September MCMXCIII in
<URL:news:slrn9b6s6r.50s.damian@puma.qimr.edu.au>:
`` Dave Cross chose Sat, 17 Mar 2001 13:49:20 +0000 to say this:
`` >...
`` >Note that any advice regarding the use of LWP as a solution to your
`` >problem is so completely off-track that anyone giving that advice
`` >should be laughed out of the newsgroup.
`` >
``
`` At first, I found this sentence puzzling in the extreme. I quickly realised,
`` however, that David was referring to comments made by some denizen of my
`` scorefile (one of the -9999 folk). So to clear things up, I disabled
`` scoring and rebuilt the thread.
``
`` The result surprised me: I had some time ago decided to kill not just
`` Godzilla's posts, but also any followups to them. This helps me to
`` entertain the illusion of a troll-free newsgroup. But I was still surprised
`` that I had managed to opt out of such a large thread in advance.
``
`` Do other people kill followups as well? In some ways I'm sad to miss uri's
`` comments, eg, even though I'd like to think that I'm saving my usenet time
`` for his 'better side' :-).
Yes, I kill anything that has a reference to a Godzilla post.
As for uri, I killfile him too, because he tends to bring up Godzilla
even when he's not replying to one of her posts. I guess he's in love.
Abigail
------------------------------
Date: Sun, 18 Mar 2001 08:48:10 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Subroutine in separate files
Message-Id: <slrn9b7msq.i70.mgjv@martien.heliotrope.home>
On 17 Mar 2001 14:12:57 GMT,
Damian James <damian@qimr.edu.au> wrote:
>
> Do other people kill followups as well? In some ways I'm sad to miss uri's
> comments, eg, even though I'd like to think that I'm saving my usenet time
> for his 'better side' :-).
Anything from Godzilla or any article with references to one in the
header never makes it to my eyes. The few times that I've checked, I
noticed that that is a crude, but very efficient rule, that does exactly
what I want it to do. I've never seen anything noteworthy in any of the
subthreads starting at her articles.
Martien
--
Martien Verbruggen |
Interactive Media Division | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd. | bundled with your Microsoft product.
NSW, Australia |
------------------------------
Date: 17 Mar 2001 19:56:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Username/password from an HTML form
Message-Id: <slrn9b7gbk.7eb.abigail@tsathoggua.rlyeh.net>
Mark Thompson (mark-lists@webstylists.com) wrote on MMDCCLIV September
MCMXCIII in <URL:news:i0v4bt464aim5fns512h6iuncgfq97c84l@4ax.com>:
,, I've set up a simple password protection system using basic
,, authentication with an .htaccess file and password file that works.
,, When someone requests a page that is protected, the browser brings up
,, a dialog box that asks for the username and password and if they enter
,, the correct information, it gives them what they're looking for.
Interesting, but that has nothing to do with Perl, does it?
,, What I'd like to do is have username and password fields on an HTML
,, form with a submit button instead of a popup window that has the same
,, functionality.
Yes, but what has that to do with Perl?
,, Is this something that is possible? I've spent all evening looking at
,, FAQs and Perl manuals but haven't been able to find anything that says
,, this is possible to do (I also haven't seen anything that says it's
,, not possible either.)
Of course it's possible.
Of course, the Perl manuals and FAQs don't tell you how to write a
browser. They tell you how to use the language.
,, I already posted this in the cgi newsgroup but decided after the fact
,, to post it here too since if this is possible, it will end up having
,, to be done in Perl by myself.
How would you do it in C?
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 17 Mar 2001 20:03:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: using variable content as constant name
Message-Id: <slrn9b7gon.7eb.abigail@tsathoggua.rlyeh.net>
Ralf Heydenreich (rheydenr@htwm.de) wrote on MMDCCLV September MCMXCIII
in <URL:news:3AB32419.5939701F@htwm.de>:
)) Hi,
)) I have to take the content of a string-variable for a constant
)) reference.
)) I want to do something like this:
))
)) use constant FOO => 2;
)) @data=qw/abc def efg hij/;
)) $bar="FOO";
)) print "The value is: ", $data[ $$bar ];
))
)) This should result to "The value is efg", but it don't do this! How can
)) I fix this problem?
use constant FOO => 2;
@data=qw/abc def efg hij/;
$bar = FOO;
print "The value is: ", $data [$bar];
But, if you make a constant, why not just use the constant at the right place?
use constant FOO => 2;
@data=qw/abc def efg hij/;
print "The value is: ", $data [FOO];
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
$\=$/;q<Just another Perl Hacker>->();
------------------------------
Date: Sat, 17 Mar 2001 21:39:00 -0000
From: "Paul" <paulthomson@hotmail.com>
Subject: way to check a pop3 mailbox without using additional modules?
Message-Id: <3ab3d941@news1.homechoice.co.uk>
Hi,
Does anyone know of a way to check a pop3 mailbox without using additional
modules to the basic perl 5 installation? The reason I ask is my isp makes a
hideous charge for installing modules :(
Thanks in advance for any pointers or resources,
Paul
BTW it is an NT server...
------------------------------
Date: 17 Mar 2001 16:44:28 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: way to check a pop3 mailbox without using additional modules?
Message-Id: <990pcc$4ja$1@boomer.cs.utexas.edu>
In article <3ab3d941@news1.homechoice.co.uk>,
Paul <paulthomson@hotmail.com> wrote:
>Does anyone know of a way to check a pop3 mailbox without using additional
>modules to the basic perl 5 installation? The reason I ask is my isp makes a
>hideous charge for installing modules :(
Modules are just files like any other. You don't need
special permission or whatever to install them. So, why
not install one yourself? You will of course have to tell
all your scripts how to get to it ("use lib '/some/dir'").
Note that I'm assuming your ISP charges for the service of
installing the modules, rather than for allowing you to
install them on the server yourself.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Sat, 17 Mar 2001 22:56:21 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: way to check a pop3 mailbox without using additional modules?
Message-Id: <pYRs6.104$ez4.4809@eagle.america.net>
On Sat, 17 Mar 2001 21:39:00 -0000, Paul <paulthomson@hotmail.com>
wrote:
>Does anyone know of a way to check a pop3 mailbox without using
>additional modules to the basic perl 5 installation? The reason I ask
>is my isp makes a hideous charge for installing modules :(
Sounds like you need another ISP. :-)
>Thanks in advance for any pointers or resources,
Study the POP3 protocol. (RFC 1939)
Read the perlipc manual page, section "TCP Clients with IO::Socket".
>BTW it is an NT server...
I can't imagine how this is relevant.
For one interpretation of "check a pop3 mailbox"...
Here's a start, assuming that "basic perl 5 installation" includes
IO::Socket::INET. You can check this with
$ perl -MIO::Socket::INET -e42
If that fails, then you *really* need to get another ISP and you need
to study the perlipc manual page section "Sockets: Client/Server
Communication" for the details using the low-level socket library
(which isn't much more that this, actually):
$ perl try
+OK Mailbox open, 128 messages
$ cat try
#!/usr/bin/perl -w
use strict;
use IO::Socket;
sub CRLF () { "\015\012" }
sub cmd {
my $fh = shift;
print $fh @_, CRLF;
my $rc = <$fh>;
return $rc if $rc =~ /^\+OK/;
die "error: $rc";
}
my $pop3 = IO::Socket::INET->new(
PeerAddr => 'localhost',
PeerPort => 'pop3',
)
or die "can't connect to 'localhost:pop3', $!";
my $resp = <$pop3>;
$resp =~ /^\+OK/ or die "$resp";
my $login = "garry";
my $passwd = "*****";
cmd($pop3, "user $login");
print cmd($pop3, "pass $passwd");
cmd($pop3, "quit");
exit 0;
$
--
Garry Williams
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 516
**************************************