[15664] in Perl-Users-Digest
Perl-Users Digest, Issue: 3077 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 17 14:10:43 2000
Date: Wed, 17 May 2000 11:10:20 -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: <958587020-v9-i3077@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 17 May 2000 Volume: 9 Number: 3077
Today's topics:
Newbie Perl Question - Reading File Info. <roy.wood@ukonline.co.uk>
Re: Newbie Perl Question - Reading File Info. <bmb@dataserv.libs.uga.edu>
Re: Newbie Perl Question - Reading File Info. newsposter@cthulhu.demon.nl
Re: Newbie Perl Question - Reading File Info. <roy.wood@ukonline.co.uk>
Re: Newbie Perl Question - Reading File Info. <billy@arnis-bsl.com>
Re: Odd behaviour, I think its my use of map()? (Bart Lateur)
Re: Odd behaviour, I think its my use of map()? <care227@attglobal.net>
Passing Hash to Subroutine using Keys mgray@wallacefloyd.com
Re: Passing Hash to Subroutine using Keys <tony_curtis32@yahoo.com>
Perl on 98 amerar@my-deja.com
Philosophy of source file size jdaves@gilanet.com
Re: Philosophy of source file size (Sam Holden)
Re: Q. sorting on a date (Michel Dalle)
qr operator and a variable as a pattern <wilma@orientation.com>
Re: Randomised function <bet@rahul.net>
Re: RE Question <godzilla@stomp.stomp.tokyo>
Re: RE Question <uri@sysarch.com>
Re: regex mind bender (for me) <nomail@nomail.com>
Re: regex mind bender (for me) <billy@arnis-bsl.com>
Sendmail? <mouimet@direct.ca>
Re: Sendmail? <sariq@texas.net>
Shopping cart problems <svowels@umich.edu>
Socket problems... <tim.blair@ntli.net>
Re: Socket problems... <franl-removethis@world.omitthis.std.com>
suid problem under Solaris 2.7 riglerej@my-deja.com
Re: suid problem under Solaris 2.7 <andrew.mcguire@walgreens.com>
Re: suid problem under Solaris 2.7 <rootbeer@redcat.com>
They won't allow perl! <fkrul@acc.com>
Re: They won't allow perl! <flavell@mail.cern.ch>
Re: They won't allow perl! (brian d foy)
Re: upload to server <thepoet1@arcormail.de>
using Net::Telnet without escape characters bahram22@my-deja.com
weirdness with symbol ref and new version of perl riglerej@my-deja.com
Re: What's this line which Perl added to AUTOEXEC.BAT? <waldo700NOwaSPAM@aol.com.invalid>
Re: Why does the contents of my file dissapear in an FT (Randal L. Schwartz)
Re: zen and the art of trolling [OT] <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 May 2000 17:24:44 +0100
From: "Roy Wood" <roy.wood@ukonline.co.uk>
Subject: Newbie Perl Question - Reading File Info.
Message-Id: <8fuh6d$6tu$1@apple.news.easynet.net>
Hi,
i'm new to Perl and i seem to be having some difficulty reading the contents
of a file and displaying the result.
The file is a single value (i was trying to test it and i figured that would
be the easiest :o(
i.e. - file test.txt
Line 1 = 12345
i have the code as follows to read the file....
##
open(INF,"path.../test.txt")
$testdata = <INF>;
close <INF>;
print "Number = $testdata";
##
now when i run this file it prints....
Number =
and that is it ? if i add the line
$testdata++;
before printing i get the result
Number = 1
hmmm.... Now my question is why is it not outputting my file contents. Is it
quite simply that it ISN'T reading the file and Perl does not output any
error for this fact or is it something else ?
Sorry if this a bit trivial but ANY HELP would be appreciated...
Cheers
MA
Perl Newbie for 3hours 21 minutes.....
------------------------------
Date: Wed, 17 May 2000 12:41:45 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: Newbie Perl Question - Reading File Info.
Message-Id: <Pine.GSO.4.21.0005171240080.29100-100000@dataserv.libs.uga.edu>
On Wed, 17 May 2000, Roy Wood wrote:
...
> open(INF,"path.../test.txt")
...
> hmmm.... Now my question is why is it not outputting my file contents. Is it
> quite simply that it ISN'T reading the file and Perl does not output any
> error for this fact or is it something else ?
You have to tell perl to tell you the error.
See `perldoc -f open'
--
Brad
------------------------------
Date: 17 May 2000 17:39:56 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: Newbie Perl Question - Reading File Info.
Message-Id: <8fulhc$fmi$1@internal-news.uu.net>
Roy Wood <roy.wood@ukonline.co.uk> wrote:
> i have the code as follows to read the file....
> ##
> open(INF,"path.../test.txt")
> $testdata = <INF>;
> close <INF>;
> print "Number = $testdata";
> ##
> now when i run this file it prints....
Looks like you didn't post the code you're having trouble with. When
I try to run your code I get:
Scalar found where operator expected at xx.pl line 2, at end of line
(Missing semicolon on previous line?)
syntax error at xx.pl line 2, near ")
$testdata "
Type of arg 1 to close must be HANDLE (not <HANDLE>) at xx.pl line 3, near "<INF>;"
Execution of xx.pl aborted due to compilation errors.
I assume your real code uses #!/bin/perl -w, use strict, and error checking
on the open. Please post your script again including these three things
that were missing. And make sure the script actually compiles ...
Erik
Erik
------------------------------
Date: Wed, 17 May 2000 18:38:30 +0100
From: "Roy Wood" <roy.wood@ukonline.co.uk>
Subject: Re: Newbie Perl Question - Reading File Info.
Message-Id: <8fulm0$9sl$1@apple.news.easynet.net>
cheers,
now that makes a bit more sense :o)
MA
Brad Baxter <bmb@dataserv.libs.uga.edu> wrote in message
news:Pine.GSO.4.21.0005171240080.29100-100000@dataserv.libs.uga.edu...
> On Wed, 17 May 2000, Roy Wood wrote:
> ...
> > open(INF,"path.../test.txt")
> ...
> > hmmm.... Now my question is why is it not outputting my file contents.
Is it
> > quite simply that it ISN'T reading the file and Perl does not output any
> > error for this fact or is it something else ?
>
> You have to tell perl to tell you the error.
>
> See `perldoc -f open'
>
> --
> Brad
>
------------------------------
Date: Wed, 17 May 2000 17:39:16 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: Newbie Perl Question - Reading File Info.
Message-Id: <8fulg1$jtr$1@nnrp1.deja.com>
In article <8fuh6d$6tu$1@apple.news.easynet.net>,
"Roy Wood" <roy.wood@ukonline.co.uk> wrote:
> Hi,
>
> i'm new to Perl and i seem to be having some difficulty reading the
contents
> of a file and displaying the result.
> The file is a single value (i was trying to test it and i figured
that would
> be the easiest :o(
>
> i.e. - file test.txt
> Line 1 = 12345
>
> i have the code as follows to read the file....
>
> ##
> open(INF,"path.../test.txt")
You *must* always-always-always{1000} check return values
from system calls. And if you do, perl will be happy to
report the problem.
my $file = '/path/to/file.txt';
open INF, $file or die "cannot open $file: $!\n";
...skipped...
Hope this helps.
Ilja.
P.S. -w switch and use strict; will help a lot also.
P.P.S. And yes, pls read 'perldoc -f open'.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 15:16:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Odd behaviour, I think its my use of map()?
Message-Id: <3923b4f8.1941708@news.skynet.be>
Drew Simonis wrote:
>> local $/ = "\n";
>
>
>Holy cow it worked! I can't thank you enough. Now I have both
>a solution and a probable cause. wow. Im happy.
>
>Now which module changed that silly value...
Good question. A module shoudln't do that unless you ask it to. Can you
list the modules you used, so I can check them out? And... are there any
custom modules, i.e. not available through CPAN?
> and...
>is there a listing of all silly values that I can learn
>from? Like newline, field seperator, $^W, etc?
Of the included docs, "perlvar" ("Perl predefined variables") contains
what you want.
--
Bart.
------------------------------
Date: Wed, 17 May 2000 13:19:49 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Odd behaviour, I think its my use of map()?
Message-Id: <3922D4B5.A9B8D85F@attglobal.net>
Bart Lateur wrote:
> >Now which module changed that silly value...
>
> Good question. A module shoudln't do that unless you ask it to. Can you
> list the modules you used, so I can check them out? And... are there any
> custom modules, i.e. not available through CPAN?
I'm using CGI.pm and DBI. Both CPAN mods, both the most current
versions. No where did I reset that variable myself manually.
------------------------------
Date: Wed, 17 May 2000 17:18:21 GMT
From: mgray@wallacefloyd.com
Subject: Passing Hash to Subroutine using Keys
Message-Id: <8fuk8a$igv$1@nnrp1.deja.com>
How do I pass this hash %infoformat to the subroutine called printit. I
dont get any errors but the print statement only prints a :. Can this
be done using foreach $keys (keys .....
# assign master hash (%infoformat) from from info hash
while (($fieldname) = each (%infoformat)){
while (($i,$j) = each(%info)) {
if ($fieldname eq $i) {
$infoformat{$fieldname} = $j;
}
}
}
#call printit
&printit (\$infoformat);
# print hash that is sent to it
sub printit {
%y = $$_[0];
foreach $key (keys %y) {
print $key . ": " . $y->{$key} . "\n";
}
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 May 2000 12:31:29 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Passing Hash to Subroutine using Keys
Message-Id: <87zoppf5hq.fsf@shleppie.uh.edu>
>> On Wed, 17 May 2000 17:18:21 GMT,
>> mgray@wallacefloyd.com said:
> How do I pass this hash %infoformat to the subroutine
> called printit. I dont get any errors but the print
> statement only prints a :. Can this be done using
> foreach $keys (keys .....
> &printit (\$infoformat);
^
^
What type of variable is `infoformat' ?
hth
t
------------------------------
Date: Wed, 17 May 2000 17:39:41 GMT
From: amerar@my-deja.com
Subject: Perl on 98
Message-Id: <8fulgr$ju2$1@nnrp1.deja.com>
Hello,
Simple question. I've never used Perl under Windows 98 before. How the
heck are you aupposed to get the system date? Can't seem to figure that
one out.......
Please CC a copy to: amerar@ci.chi.il.us
Thanks.
Arthur
amerar@ci.chi.il.us
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 15:34:33 GMT
From: jdaves@gilanet.com
Subject: Philosophy of source file size
Message-Id: <8fue67$b9d$1@nnrp1.deja.com>
Hi, all. I'm starting to write some larger perl programs, and would like
to get people's opinions on the best way of doing stuff.
I come from a fortran/C/C++ background,where I always do stuff like
declaring variables, using lots of subroutines, and using bunches of
source files to make stuff more readable. I've got some
programming philosophy questions about Perl in particular:
1) Is there any performance hit by having everything in a single
monolithic file? Is readability and maintainability the only advantage
to breaking up into multiple source files?
2) I've tried using 'use strict' while using multiple source files
(require "file1.pl";, and so on), and get error msgs (Global symbol
requires explicit package decl, variable not imported, etc). I've been
able to avoid this using modules (save files other than main.pl in
/usr/lib/perl5/foo/bar.pm). Is this the right way to do this, even when
I'm not really using objects? Also, can I keep bar.pm in the same dir
with the main perl script, or does it need to be under perl5?
Thanks in advance
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 May 2000 16:11:52 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Philosophy of source file size
Message-Id: <slrn8i5h67.hiu.sholden@pgrad.cs.usyd.edu.au>
On Wed, 17 May 2000 15:34:33 GMT, jdaves@gilanet.com <jdaves@gilanet.com> wrote:
>Hi, all. I'm starting to write some larger perl programs, and would like
>to get people's opinions on the best way of doing stuff.
>
>I come from a fortran/C/C++ background,where I always do stuff like
>declaring variables, using lots of subroutines, and using bunches of
>source files to make stuff more readable. I've got some
>programming philosophy questions about Perl in particular:
All of which are wonderful things ;)
>
>1) Is there any performance hit by having everything in a single
>monolithic file? Is readability and maintainability the only advantage
>to breaking up into multiple source files?
A few less system calls, I guess.
Plus reusability, all three of which are very important - the first two moreso.
>
>2) I've tried using 'use strict' while using multiple source files
>(require "file1.pl";, and so on), and get error msgs (Global symbol
>requires explicit package decl, variable not imported, etc). I've been
>able to avoid this using modules (save files other than main.pl in
>/usr/lib/perl5/foo/bar.pm). Is this the right way to do this, even when
>I'm not really using objects? Also, can I keep bar.pm in the same dir
>with the main perl script, or does it need to be under perl5?
You need to declare package variables under use strict. Something like:
use vars qw($variable1 @variable2 %variable3 $foo $bar $baz);
With a brand spankin' new perl you could use 'our' instead...
Modules are not just for objects. They are for modules, funnily enough.
Making a module for some functionality which can be encapsulated well enough
is usually useful, you can give it a name, put it in a package, and use it in
the next project too. Or go all out and publish it to CPAN...
You can keep modules anywhere perl looks for modules. The current working
directory is in that list. So is everything in the PERL5LIB environment
variable.
See perlfaq8:
How do I keep my own module/library directory?
Putting stuff in /usr/lib/perl5 is very likely a bad idea.
`perldoc perlmod` will supply you with lots of information about writing
modules...
--
Sam
If your language is flexible and forgiving enough, you can prototype
your belief system without too many core dumps.
--Larry Wall
------------------------------
Date: Wed, 17 May 2000 16:26:49 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Q. sorting on a date
Message-Id: <8fuhar$5oo$1@news.mch.sbs.de>
In article <Pine.GSO.4.10.10005151719060.25459-100000@user2.teleport.com>, Tom Phoenix <rootbeer@redcat.com> wrote:
> my @sorted_dates =
> map { $_->[0] }
> sort { $b->[1] <=> $a->[1] or $a->[0] cmp $b->[0] }
> map { [ $_, kissability($_) ] }
> @dates;
Somehow, I think Perl doesn't like me :
Undefined subroutine &main::kissability called at kiss.pl line 4.
;-)
Michel.
------------------------------
Date: Wed, 17 May 2000 19:02:31 +0200
From: Wilma Cray <wilma@orientation.com>
Subject: qr operator and a variable as a pattern
Message-Id: <gkj5is4b9ec18ru0562v9379jfg4u2gcau@4ax.com>
Hi!
I need this pattern as a variable: /\d/g
$_="43aa23aa653";
@foo = /\d/g;
foreach $i (@fpp)
{
print $i;
}
And now the same example with a variable as a pattern:
$bar=qr/\d/g/; # $bar=qr/\d\/g/; doesn´t work too
@foo = $bar;
foreach $i (@fpp)
{
print $i;
}
This doesn´t work.
Is there a solution?
thanx a lot
wilma
------------------------------
Date: Wed, 17 May 2000 13:56:01 -0400
From: Bennett Todd <bet@rahul.net>
Subject: Re: Randomised function
Message-Id: <20000517135601.L539@rahul.net>
Hash: SHA1
2000-05-16-18:42:45 Larry Rosler:
> > printable => [map { chr } (ord(' ') .. ord('~'))],
>
> Without commenting on the merits of the rest of your code, I was struck
> by that peculiarly roundabout way of saying this:
>
> printable => [ ' ' .. '~' ],
>
> or what you really mean, this:
>
> printable => [ "\x20" .. "\x7E" ],
I sure wish I could get either of your expressions to work.
Actually, I particularly prefer the first one, the second doesn't
appeal as much. While I sadly confess that my expression is every
bit as viciously ASCII-codeset dependant as any other, at least I
think mine documents a bit more what I have in mind than your second
one.
But at least with 5.005_03, neither of your expressions work.
I believe the range operator only expands the way you're describing
for those strings that support the "magic ++ string increment",
which is basically (from perlop) [a-zA-Z]*[0-9]*.
- -Bennett
Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE5ItzTL6KAps40sTYRAiNZAKCNiudcleWdRDqPmZrS6pyuB3G5ugCfdJnS
fX6lOrYaQ2myJ/l6bMvQ/d8=
=g2EQ
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 17 May 2000 09:20:05 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: RE Question
Message-Id: <3922C6B5.7A9BAF91@stomp.stomp.tokyo>
Xah wrote:
> Uri Guttman,
> Uri Guttman <uri@sysarch.com> wrote
> > this is fancy coding?
> > split( /,(?! )/, $line ) ;
> No, it's mumble jumble very much preferred by fancily-clad yokel like
> yourself. Godzilla is just too diffident to point that out.
> Godzilla's suggestion:
> > Replace comma/space with a special character.
> > Perform a split.
> > Replace the comma/space.
> for the question:
> >I want to parse lines like this:
> >"Some text with comma, bad bad",33,44,55
> >by commas, but not by commas followed by a space.
> is actually quite elegant and effective.
> The reason that Perl folks of beady eyes cannot see it,
> is because Perl/unix are habitually addicted to backwater
> 7-bits ISO 646:1991 character set. That regex obfuscation
> tickles them at heart too. Clarity would be the bane of Perl.
Confucius say, "Obfuscation make confuscation."
I'm too funny...
Hello Xah,
I have fixed your access problem to my site script.
Proxy servers are not allowed. However, yours is
a legit private proxy.
Funny, one of the people who screamed the loudest
about always using 7 bit, posted his article via
a Mozilla browser set for 8 bit. Ironic humor, that.
Yours is an insightful notion on clarity being a bane.
As a long time secondary teacher and, now a Professor
of English, I have come to learn in communication,
clarity is a most critical component of comprehension.
Long ago I learned an embarrassing lesson when
I first started teaching,
"Ms. Schilitubi, could you talk more plain?
I can't understand those big words."
As a result of this student's comment, I lowered
my language level and still maintained encouragement
for my students to raise their language level.
As this applies to programming, we can write
very fancy dancy techno-gibberish code and,
exclude a large percentage of readers from
understanding what is said.
This notion of 'everybody understands' is all
too well exemplified by a persistant assumption
here _everybody_ has Perl installed on his or
her home system.
see perlop
-f perlgeek
perlfaq4
These are not answers to questions. These
are ignorant comments by people who most
likely are covering for an inability to
answer with clarity. These type of comments
are based on an assumption all have Perl
installed on their home system. This is
not very wise. Most 'newbies' to Perl
do not have Perl on a home system. Simply
being a newbie is clue enough a person
lacks needed skills to install Perl on
a home system.
My opinion, most of the regulars here have
little interest in answering questions, their
interest lies in ego satiation via razzle
dazzle incomprehensible techno-gibberish.
My methodology, to answer in Plain English
to afford understanding by the widest possible
audience and, to often motivate a reader to
ask follow-up questions by creating challenges
to overcome in answer. I work hard at posting
answers and Perl code, with an intent of clarity
and with an intent of affording a practical
solution, although sometimes with a bit of
a challenge included so as not to nursemaid.
I am here to help, not to masturbate my ego.
Godzilla!
------------------------------
Date: Wed, 17 May 2000 16:36:31 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: RE Question
Message-Id: <x7snvhgmls.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> I am here to help, not to masturbate my ego.
then you and xah should meet and masturbate each other's ego. but in any
case both of you don't belong here. you hate perl, perl hackers and most
other things. but you love each other. how sweet. c.l.p.misc has now
made a match. elope already and go on a permanent honeymoon.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Wed, 17 May 2000 09:16:35 -0400
From: "Jonah" <nomail@nomail.com>
Subject: Re: regex mind bender (for me)
Message-Id: <8fudn0$1tn8$1@onlink3.onlink.net>
Andrew Johnson <andrew-johnson@home.com> wrote in message
news:vDrU4.14029$95.197239@news1.rdc1.mb.home.com...
> In article <8ft1dm$137i$1@onlink3.onlink.net>,
> Jonah <nomail@nomail.com> wrote:
> > This seems simple enough but I can't
> > solve it.
> >
> > I'm getting a value from a $q->textfield
> > and I need to check if it contains *only* spaces.
> >
> > not empty, but if it has 1 or more spaces and nothing else in it.
> >
> > my $var = $q->param('mytextfield');
> > print "yay" if $var =~ /\s+/;
>
> anchor your pattern to the start and end of the string:
>
> print "yay" if $var =~ /^\s+$/;
Thanks, I looked those symbols up and I see
how that works.
> or, if you really mean space characters and not just any
> whitespace (tabs, newlines,...)
>
> print "yay" if $var =~ /^ +\z/;
>
> or use a negative character class:
>
> print "yay" unless $var =~ /[^ ]/;
>
That's why I said the value was from a textfield, they won't
have tabs or newlines, you can't enter them in the field =)
------------------------------
Date: Wed, 17 May 2000 16:48:19 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: regex mind bender (for me)
Message-Id: <8fuigc$gcg$1@nnrp1.deja.com>
In article <8fudn0$1tn8$1@onlink3.onlink.net>,
"Jonah" <nomail@nomail.com> wrote:
...skipped...
> That's why I said the value was from a textfield, they won't
> have tabs or newlines, you can't enter them in the field =)
>
No, you should never-never make assumptions like
"<some-user-input> cannot contain <some-character>".
Yes, *some* browser may limit legal characters which
a user can type in a field.
But think: *everybody* may simulate a browser
and generate any GET/POST requests, with *any*
data one likes.
You may try it yourself in Perl - just install libwww-perl package.
Ilja.
P.S. Never trust a user - may be he is a HaCkEr.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 17:35:14 GMT
From: "Marcus" <mouimet@direct.ca>
Subject: Sendmail?
Message-Id: <mLAU4.20222$au2.221363@news1.rdc1.bc.home.com>
I am using Matt's cgi script to send a form via email. It used to work fine
on my old
server but now I am having the weirdest thing happen to me on my new
dedicated server (Red Hat Linux 6.1). The script will send out to any email
address like: hell@hello.com or hi@hi.ca but when you try and send to
something like: hello@mindlink.bc.ca or hello@sk.sympatico.ca it won't send.
I have verified the email address' I am trying to send to and it they work
otherwise. Any suggestions on where the problem lies or how I can fix it?
------------------------------
Date: Wed, 17 May 2000 12:44:53 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Sendmail?
Message-Id: <3922DA95.7773B8CF@texas.net>
Marcus wrote:
>
> I am using Matt's cgi script to send a form via email. It used to work fine
> on my old
> server but now I am having the weirdest thing happen to me on my new
> dedicated server (Red Hat Linux 6.1).
Perhaps Matt has the answer.
HTH!
- Tom
------------------------------
Date: Wed, 17 May 2000 12:57:17 -0400
From: "K. Scott Vowels" <svowels@umich.edu>
Subject: Shopping cart problems
Message-Id: <EbAU4.2023$R12.39046@news.itd.umich.edu>
Hey all,
*Disclaimer* Keep the flames to a minimum, I am not a coder.
A friend is developing a shopping cart function in Perl and is having
problems getting the information on the first form to replicate onto
upstream forms. It appears to be clearing the session when it refreshes in
the next form. Any thoughts or clues? I realize without looking at it, I'm
probably asking a stupid question, but...that's never stopped me in the
past:)
He seems pretty convinced that this is problem that has *never* been
solved...I said, "let me ask around".
Thanks in advance,
K. Scott
svowels@umich.edu
------------------------------
Date: Wed, 17 May 2000 16:34:59 +0100
From: "Tim Blair" <tim.blair@ntli.net>
Subject: Socket problems...
Message-Id: <5YyU4.2020$86.32675@news2-win.server.ntlworld.com>
Hi there, hoping someone can help...
I have a small perl server script that creates a socket, and simply listens
to it. When a client makes a connection, the server forks a new process to
deal with that connection, and carries on listening for connection requests.
On recieving certain messages from the connected client (Java), the server
sends a message back to the client. That's all nice and simple, and I can
cope with that.
The problem I'm having is this... After one certain message, I would like
the server to send a reply, then continually send (random) data to the
client, until the client sends another message, saying that it's had enough.
I'm completely at a loss for how to do this.
Now, I'm sure there's probably a nice, simple solution (problably involving
a while loop or something), but I'll be blowed if I can think of it.
Anyone care to help a poor, struggling programmer?
:o)
Thanks,
Tim.
------------------------------
Date: Wed, 17 May 2000 17:24:34 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
To: "Tim Blair" <tim.blair@ntli.net>
Subject: Re: Socket problems...
Message-Id: <m3r9b1f5t9.fsf@franl.andover.net>
"Tim Blair" <tim.blair@ntli.net> writes:
> The problem I'm having is this... After one certain message, I would like
> the server to send a reply, then continually send (random) data to the
> client, until the client sends another message, saying that it's had enough.
> I'm completely at a loss for how to do this.
You need to call select() in a loop, so that in between writing chunks of
data to the socket, you can test to see whether there is any data to be
read from the socket (i.e., the client's message saying it's had enough).
It would have this general form (I haven't compiled this code, so this is
just pseudo-Perl):
while (1)
{
my ($readbits, $errbits) = ('', '');
vec($readbits, fileno(SOCKET), 1) = 1;
$errbits = $readbits;
my $nfound = select($readbits, undef, $errbits, 0);
if ($nfound)
{
if ($errbits)
{
print "read error: $!\n";
exit($!);
}
my $msg = read_client_message() if $readbits;
break if $msg eq "STOP TRANSMITTING DAMMIT";
}
print SOCKET $data;
}
Hope this helps.
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.
------------------------------
Date: Wed, 17 May 2000 16:25:30 GMT
From: riglerej@my-deja.com
Subject: suid problem under Solaris 2.7
Message-Id: <8fuh55$etf$1@nnrp1.deja.com>
Before I get hundreds of responses telling me that writing suid scripts
is BAD, I will just say that I am very aware of the potential problems,
and trust my own programming skills to create a simple, secure script
for modifying my /etc/group file.
Now, as of a few months ago, I was running PERL 5.004. It was an
installation put in before I began working at my job. IMHO, it was a
botched installation, so I decided to upgrade to 5.005_3, and try to
install it properly. Everything has gone beautifully, except that a
SUID root script I wrote no longer works properly.
I have been reading lots of comments in newsgroups, and they either say
1) don't suid scripts (not an option), 2) write a C wrapper (not
terribly portable across architectures, or 3) use suidperl (sperl). The
funny thing is I can find NOTHING on how to set up and use sperl. When
I run the PERL distribution's "Cofigure" script, it tells me that
Solaris has secure suid scripts, and that suid emulation isn't
necessary, but this is not what I am seeing when I actually try to run
an suid script.
Any ideas? Can somebody point me to docs on sperl (I'd like to enable
this anyway, since I'm trying to homogenize my unix network, and I have
a number of Linux machines that may make use of the suid script).
Please CC jrigler@colorado.edu if you have a comment to the group, as my
access to usenet is via deja.com and it's been kinda buggy lately.
Thanks,
JR
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 11:49:22 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <3922CD92.7236F5E9@walgreens.com>
[ posted & mailed ]
riglerej@my-deja.com wrote:
>
> Before I get hundreds of responses telling me that writing suid scripts
> is BAD, I will just say that I am very aware of the potential problems,
> and trust my own programming skills to create a simple, secure script
> for modifying my /etc/group file.
What is wrong with groupadd, groupmod, and groupdel?
You will find them on both Solaris and Linux.
> Now, as of a few months ago, I was running PERL 5.004. It was an
> installation put in before I began working at my job. IMHO, it was a
> botched installation, so I decided to upgrade to 5.005_3, and try to
> install it properly. Everything has gone beautifully, except that a
> SUID root script I wrote no longer works properly.
What errors does it give, which part is broken? Post some minimal
code that illustrates your problem, and you will be better helped.
[ snip ]
> Any ideas? Can somebody point me to docs on sperl (I'd like to enable
> this anyway, since I'm trying to homogenize my unix network, and I have
> a number of Linux machines that may make use of the suid script).
I am not sure about sperl off hand, but you can probably do
what you want without it.
> Please CC jrigler@colorado.edu if you have a comment to the group, as my
> access to usenet is via deja.com and it's been kinda buggy lately.
OK, but just this once. ;^)
Regards,
anm
--
/*-------------------------------------------------------.
| Andrew N. McGuire |
| andrew.mcguire@walgreens.com |
`-------------------------------------------------------*/
------------------------------
Date: Wed, 17 May 2000 10:18:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <Pine.GSO.4.10.10005171010250.25459-100000@user2.teleport.com>
On Wed, 17 May 2000 riglerej@my-deja.com wrote:
> Everything has gone beautifully, except that a
> SUID root script I wrote no longer works properly.
Sounds as if you need set-id emulation on your system. That's not enabled
by default; did you ask for it when you configured perl?
> I have been reading lots of comments in newsgroups, and they either say
> 1) don't suid scripts (not an option),
Set-id programs are a necessity (not an option :-) for Unix systems. And
your application sounds like one to make set-id. Of course, it takes
careful attention to security issues; I'm sure you've read perlsec.
> 2) write a C wrapper (not terribly portable across architectures,
Have you seen the wrapsuid program from the perl distribution? It's in the
eg/ directory.
> or 3) use suidperl (sperl).
Good advice. :-)
> When I run the PERL distribution's "Cofigure" script, it tells me that
> Solaris has secure suid scripts, and that suid emulation isn't
> necessary, but this is not what I am seeing when I actually try to run
> an suid script.
Maybe your Solaris installation is broken, and lacks the /dev/fd
directory, or the proper entries in that directory? If you're not sure,
though, you'll probably need an expert on Solaris.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 17 May 2000 09:52:24 -0700
From: Frank Krul <fkrul@acc.com>
Subject: They won't allow perl!
Message-Id: <3922CE48.87622ADD@acc.com>
Hello,
I need help in coming up with an intelligent response to this:
---------------------------------
I also seriously think we should not install Perl on the Exodus
machines.
1. We do not know the stability of Perl running under NT for high volume
sites.
2. Perl runs out of the IIS process, every call to a perl script runs a
separate instance of Perl. This can be resource
intensive, and if there is something wrong with the script, it can
potentially bring the whole server down.
As an alternative, I suggest they run their Perl scripts off
CENSORED instead. I believe the CENSORED
team should be able to talk to CENSORED to host their Perl scripts
there.
----------------------
I have used perl for years on UNIX, but do not know of it's inherent
weaknesses on NT. Aby help would be appreciated.
------------------------------
Date: Wed, 17 May 2000 19:08:14 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: They won't allow perl!
Message-Id: <Pine.GHP.4.21.0005171902540.3970-100000@hpplus03.cern.ch>
On Wed, 17 May 2000, Frank Krul wrote:
> I also seriously think we should not install Perl on the Exodus
> machines.
> 1. We do not know the stability of Perl running under NT for high volume
> sites.
That's good. Perl is very stable under unix, why put Perl at risk
by running it on NT. Logical.
Come to that, why put the web server at risk by running it on NT...
but that's offtopic here and we wouldn't want an OS war, would we? ;-}
[BSOD protection shields raised, f'ups prophylactically set]
------------------------------
Date: Wed, 17 May 2000 13:22:59 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: They won't allow perl!
Message-Id: <brian-1705001322590001@rtp-cr45-dhcp-100.cisco.com>
In article <3922CE48.87622ADD@acc.com>, Frank Krul <fkrul@acc.com> wrote:
>I need help in coming up with an intelligent response to this:
>
>2. Perl runs out of the IIS process, every call to a perl script runs a
>separate instance of Perl. This can be resource
>intensive, and if there is something wrong with the script, it can
>potentially bring the whole server down.
if they are worried about stability, then start by getting rid of IIS
and NT. as with anything else - optimize in the right places :)
--
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ
<URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 17 May 2000 14:02:12 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: upload to server
Message-Id: <4o1uf8.a7o.ln@usenet-autoren.de>
news.btx.dtag.de <neumann@m-line-bremen.de> schrob:
> I need help. I want to upload binary files to my www-server.
> I wrote a Script, but it isn't able to open the local file. What is wrong
> or what have I forgotten :
> open (DATA, "<$file") || die &sorry ("Datei konnte nicht zum lesen geöffnet werden");
Just have a look at perldoc CGI
There it says $file is already a file handle to be read from.
You cannot use "open" on a file path on the clients computer.
Take away this line and it should work.
But please put a name in your From: that makes at least some sense -
I doubt you are t-online's news server itself :-)
BTW, there is a german FAQ in de.comp.lang.perl.cgi which answers those
frequently asked questions.
http://www.cgi-resources.com has complete scripts for thus tasks, you
don't have to invent the wheel a second time.
Greetings
Christian
------------------------------
Date: Wed, 17 May 2000 17:24:37 GMT
From: bahram22@my-deja.com
Subject: using Net::Telnet without escape characters
Message-Id: <8fukju$j3v$1@nnrp1.deja.com>
Hi,
I am using Net::telnet on ActivePerl on an WIN NT PC. I was wondering
if there is a setting or an option that will turn off the escaper
character sequences and have a normal stream output. For example, if I
do a 'dir', I like to get a clean output stream with the dir listing
only, and no escape sequences present.
Thanks a bunch
Bahram
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 17:36:48 GMT
From: riglerej@my-deja.com
Subject: weirdness with symbol ref and new version of perl
Message-Id: <8fulbf$jsh$1@nnrp1.deja.com>
In Perl 5.004 I had something like the following...
use strict;
use vars qw($F);
$F = "/some/file";
#
# Lock the output file. This returns a filehandle
#
my $OUT = lock($F);
print $OUT "Some text here\n";
"lock" is a subroutine that sets up a temporary file, and looks like
this...
sub lock {
my $f = shift;
$LOCKFILE = lockfilename($f);
$TMPFILE = sprintf("%s.%05d", $LOCKFILE, $$);
unlink $TMPFILE;
open(OUT, ">$TMPFILE") or die "$ME: open( >$TMPFILE ): $!\n";
# ESM this should actually sleep a bit
link($TMPFILE, $LOCKFILE) or do {
close OUT;
unlink $TMPFILE;
die "$ME: link: $!\n";
};
return \*OUT;
}
# "lockfilename" simply renames the file to filename.lock
sub lockfilename {
return $_[0] . ".lock";
}
It worked before, but now under Perl 5.005_3, I get the following error
message...
Can't use string ("/some/file") as a symbol ref while "strict refs"
in
use at perlscript.pl line 77, <IN> chunk 1.
I think this has something to do with how I return the filehandle from
the "lock" subroutine, but I'm not sure. Any ideas, suggestions? I am
far from a Perl guru, so please don't hesitate to dummy up your answer,
I won't be offended!
-JR
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 09:03:56 -0700
From: bjanko <waldo700NOwaSPAM@aol.com.invalid>
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <259fa2e0.8b10986f@usw-ex0101-008.remarq.com>
I fixed it by appending the Perl path to the path setting like
this:
@PATH C:\WINDOWS;C:\PERL\BIN
This allows me to run Perl from any directory.
What I gathered from others' explanations was that "SET C:
\Perl\bin" erased previous path settings. I was told to use
"SET" with the %Path% command as a way of appending the
directory to the Path list, but I didn't see the point of that
since I could type it into the path statement myself.
Despite the doubts of some, my computer did not boot with merely
SET path c:\perl\bin and now it boots fine.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 17 May 2000 09:52:09 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Why does the contents of my file dissapear in an FTP?
Message-Id: <m1wvktf7ba.fsf@halfdome.holdit.com>
>>>>> "Brad" == Brad Baxter <bmb@dataserv.libs.uga.edu> writes:
Brad> use Net::FTP::Bitrot;
I think what was needed was:
no Net::FTP::Bitrot;
no less qw(funny);
:-)
--
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!
------------------------------
Date: Wed, 17 May 2000 09:37:37 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: zen and the art of trolling [OT]
Message-Id: <3922CAD1.3BF038@stomp.stomp.tokyo>
Brad Baxter wrote:
> On Wed, 17 May 2000, Xah wrote:
> > Dear Paul:
> Dear Xah,
> You hate Perl and you hate Americans. Why don't you get
> a new job and move?
Bad enough, previously, Mr. Pecker elected to display
bigotry by targeting me alone out of a dozen or more
people participating in this off topic thread. Those
others posted off topic numerous times. I posted a
response once, after exercising tolerance for those
offensive and degrading remarks directed at me, and
was abused by Mr. Pecker with bigotry.
Mr. Baxter, your escalating this into the
realm of racism is most repugnant. Seems you
would have learned the last time vile and
vulgar racial slurs were directed at me, this
caused great turmoil and objection within this
group. Directing racial commentary at Mr. Xah,
is no less offensive to me as a Native American.
I both ask and demand you desist posting
commentary of a racially insulting intent.
Godzilla!
------------------------------
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 V9 Issue 3077
**************************************