[12807] in Perl-Users-Digest
Perl-Users Digest, Issue: 217 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 21 18:07:16 1999
Date: Wed, 21 Jul 1999 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 21 Jul 1999 Volume: 9 Number: 217
Today's topics:
Re: ****Perl tutorials!!!!**** <cassell@mail.cor.epa.gov>
Bulletin Board <emusick@garagedoor.org>
Re: CGI:calling subroutine from a form <gellyfish@gellyfish.com>
File Parsing Difficulty <lojeck@mizar.usc.edu>
Re: FORMS parsing <gellyfish@gellyfish.com>
Re: Fun with Net:NNTP <gellyfish@gellyfish.com>
Re: Fun with Net:NNTP (I R A Darth Aggie)
Re: I am looking for free flat db search script <cassell@mail.cor.epa.gov>
Re: Insecure $ENV{PATH} while running setuid (I R A Darth Aggie)
Re: Kinda FORK <cassell@mail.cor.epa.gov>
Re: Listing Files <gellyfish@gellyfish.com>
Re: newbie question: how put files from dir in array (Larry Rosler)
Re: newbie question: how put files from dir in array <cassell@mail.cor.epa.gov>
Perl usuage and Graphical Representation whos_john_galt@my-deja.com
Re: pipe "|" functionality: ksh can easily do, perl can <barmar@bbnplanet.com>
Re: pipe "|" functionality: ksh can easily do, perl can (Larry Rosler)
Problem compiling 'write' <Robert.Rawlinson@worldnet.att.net>
Re: problem with hash of arrays (Anno Siegel)
setuid and opening a file for writing (Mark Francis)
Shortening the length of a string <surgie@bellsouth.net>
Re: Timeout question <mike@crusaders.no>
Re: Uploading--HELP <cassell@mail.cor.epa.gov>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Jul 1999 14:48:45 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: ****Perl tutorials!!!!****
Message-Id: <3796403D.47CF5B8E@mail.cor.epa.gov>
IlIIIIIIII wrote:
>
> at http://devlib.cjb.net, a great web site
Oh yeah. A great web site. Yuck.
Enough glitter to make you long for the <blink> tag.
Enough traife to gag a pig.
A list of programming directories that lists Perl/CGI as if
there is no other use for Perl.
If you foolishly click there, you get a blank page. [Okay,
I have Java and JavaScript disabled like any sane person
visiting a never-before-seen site.]
It has a vote-for-your-favorite-language area which DOESN'T
WORK under the above conditions.
Another exciting virtualave.net production... And people
ask me why I'm not all excited about the Web. :-(
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 21 Jul 1999 16:46:06 -0500
From: "CompGuy" <emusick@garagedoor.org>
Subject: Bulletin Board
Message-Id: <37963dba@news.inil.com>
I've got a bulletin board with a CGI/Perl fourm and lots of cool stuff -
http://emusick.garagedoor.org/index.cgi?ubb
also check out my web site -
http://emusick.garagedoor.org
Erich Musick
PS Please give me some feedback!
------------------------------
Date: 21 Jul 1999 21:16:54 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CGI:calling subroutine from a form
Message-Id: <7n5dc6$195$1@gellyfish.btinternet.com>
On Wed, 21 Jul 1999 19:50:28 +0500 Faisal Nasim wrote:
> : Is there a way to call a subroutine from a form, like:
> : <form action= &delete_record>
> : Is this possible?
>
> nope
>
> <form action=yourfile.cgi?sub_name>
>
>
> in yourfile.cgi
>
> & { $ENV { QUERY_STRING } };
>
> Warning: Many Security Risks !!!!
>
Symbolic reference too ..
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 21 Jul 1999 14:45:00 -0700
From: Brian Lojeck <lojeck@mizar.usc.edu>
Subject: File Parsing Difficulty
Message-Id: <Pine.GSO.4.10.9907211437360.311-100000@mizar.usc.edu>
Let me start by saying that I've already dug into the LLama, Camel, and
Ram books heavily, and I'm pretty dang stuck on what should be a very
simple problem. (two actually)
The file is an html file, I need to parse down through it until I get to a
"marker" that I've inserted ( the marker is currently <!UUUUUUUUUU> but I
can change it), toss away that line, then read the rest of the lines into
an array.
while it seems it should work,
while (<HR> && !(/UUUUUUUUUU/){
}
just doesn't seem to pick up the tag. if it were c I'd simply read in the
lines one at a time and test, but I haven't found a way otehr then the
while(<Handle>) loop to read in lines from a file, so my old c tricks
don't seem to work...
the second problem is, while reading all the lines into an array, I need
to SPLIT them on a # (and that, sadly, can't be changed). the problem is,
no matter how I try to escape it, the # seems to be taken as a comment.
HELP!!!
thanks...
Brian Lojeck, lojeck@mizar.usc.edu
Learn as if you will live forever; live as if you will die tomorrow.
------------------------------
Date: 21 Jul 1999 20:39:26 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: FORMS parsing
Message-Id: <7n5b5u$177$1@gellyfish.btinternet.com>
On Wed, 21 Jul 1999 16:55:19 GMT assistmanager@my-deja.com wrote:
>
> i'd like to read in an html file and if it has a form in it.. out put
> the action and all the name/values..
The module HTML::Parser
> in some way that could be usefull
> if i was to make something that would easily allow automated submission.
>
The module LWP::UserAgent
both available from CPAN <http://www.perl.com/CPAN>
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 21 Jul 1999 20:35:26 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Fun with Net:NNTP
Message-Id: <7n5aue$174$1@gellyfish.btinternet.com>
On Wed, 21 Jul 1999 13:27:08 -0500 Darren greer wrote:
> I R A Darth Aggie wrote:
>
>> On Wed, 21 Jul 1999 11:20:24 -0500, Darren greer
>> <dgreer@websightsolutions.com>, in
>> <3795F348.458C8CE@websightsolutions.com> wrote:
>>
>> + I have been unable to find any documentation that gives me the details
>> + that I have been looking for.
>>
>> Even 'perldoc Net::NNTP'???
>>
>> James
>
> If you can make out exactly how to post to newsgroups using that
> documentation, you can read much deeper into than I can. No where in there
> does it say the format that MESSAGE should be in. Which I think is my main
> problem (looking at my code). Im just looking for clarification in that
> respect.
>
The Net::NNTP manpage doesnt need to document the format of the message
as this is documented in the Specification for Usenet messages that it is
the same for all programs whatever language they are written in. There is
an RFC whose number I cant remember right now but you should be able to
find it with a judicious search at <http://www.rfc-editor.org>..
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 21 Jul 1999 21:24:14 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Fun with Net:NNTP
Message-Id: <slrn7pceo4.pap.fl_aggie@thepentagon.com>
On Wed, 21 Jul 1999 13:27:08 -0500, Darren greer
<dgreer@websightsolutions.com>, in
<379610FC.6696BA21@websightsolutions.com> wrote:
+ If you can make out exactly how to post to newsgroups using that
+ documentation, you can read much deeper into than I can.
You're about 99% of the way there...
+ No where in there does it say the format that MESSAGE should be in.
It isn't the message...its the header...and yes, I got your code to work.
Here is a tip: comment out this line, and replace it:
#my $newsptr = Net::NNTP->new('news.mixcom.com');
my $newsptr = Net::NNTP->new('news.mixcom.com','Debug',10);
The server quite cheerfully tells you what's wrong. That's left as an
exercise for the student. If you're really stuck, I'll post my revision
to your code. I have a feeling that you're going to say "D0H!" when you
realize what it is... ;)
Interestingly enough, I was able to post using a $scalar
variable, not a @list. I don't know if that's a feature or a bug, tho.
As for the documentation on invoking the debug code, Net::NNTP is
less-than-satisfactory, particularly compared to its sibling Net::FTP.
I had a critical advantage over you in that I've used the Net::FTP
module (same author) and had that syntax down in a working
script. Usage of it is better described in Net::Cmd, tho.
James
------------------------------
Date: Wed, 21 Jul 1999 14:36:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: I am looking for free flat db search script
Message-Id: <37963D5F.8F596982@mail.cor.epa.gov>
Yeong Mo/Director Hana co. wrote:
I> David Cassell ÀÌ(°¡) <3795FDA7.C0160181@mail.cor.epa.gov> ¸Þ½ÃÁö¿¡¼
I> [snip]
I> >Excuse me, but you have made a small error. This is a newsgroup
I> >about programming in a particualr language. It is not a source
I> >for free programs. If you are looking for a script, rather than
I> >trying to write it yourself, you would have more success using
I> >one of the many search engines on the Web. Alta Vista, Yahoo,
I> >ad nauseam.
[I am re-arranging your response, since you placed it before
my words, instead of after them, as you are supposed to do in
Usenet.]
> Thanks for your advice.
>
> I'm trying to make a penpal script just for test.
> So, I need a search script to add there.
> It is better I get it from here so that to get others helpness.
No, it is *not* better that you get it here. This is not a
script archive. If you want free scripts, you can find thousands
of them on the web. A few of them even work right.
This is a place for programmers to ask for help with code
they have written, which does not work as desired. It is
not what you are looking for. If someone has given you such
an idea, please tell us who the culprit is, so that others
walking your path are not similarly deluded.
I do not want to appear rude, but it is important that you
understand this distinction. Perhaps you would do better
going to a website that furnishes scripts, such as
http://cgi.resourceindex.com/
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 21 Jul 1999 21:33:45 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Insecure $ENV{PATH} while running setuid
Message-Id: <slrn7pcfa1.pap.fl_aggie@thepentagon.com>
On Wed, 21 Jul 1999 14:22:24 -0400, Kelvin Tu <kelvin.tu@rnb.com>, in
<37960FE0.D40DAE00@rnb.com> wrote:
+ It looks like that perl sees setuid as an insecure operation and tried
+ to prevent it.
Not the setuid, but rather your PATH. You used an 'ls' command?
*which* 'ls' command would that be? perhaps it is one that I managed
to stick into your path. Perhaps *that* 'ls' is malicious, and merrily
issues an '/bin/rm -rf /lost+found/'[1], and then tells you what you
want.
That's the insecure operation.
+ Any one knows how to turn this check off.
Please read perlsec. You'll be better served working with perl than trying
to fight it in this instance.
James
------------------------------
Date: Wed, 21 Jul 1999 14:28:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Kinda FORK
Message-Id: <37963B9B.5B681EF6@mail.cor.epa.gov>
GiN wrote:
>
> i have one question:
>
> i opened a filehandle: <S>
>
> the program will read a line ($line) from <S> and work with it
> function($line)
>
> so this will do: while (<S>) {
> function($line);
> }
>
> but function() has to be finished to read another line.
>
> how can i read another line and do a function($line) without waiting
> for function($line) to finish?
I'm not really sure what you want. Mike Eiringhaus has posted
a response assuming you really want a fork() here. But it
sounds more to me like you just want to be able to read the
next line in, inside your while loop [perhaps some of the time].
If that is the case, then you'll want to look up more examples
of the angle operator <>, since anywhere you use <S> in scalar
context, the operator will snag one more line for you [unless
you've hit eof, of course].
BTW, your code as listed won't work, since you read a line
from S and store it in $_, then you throw the undefined
variable $line into your &function. But you knew that, right?
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 21 Jul 1999 20:18:44 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Listing Files
Message-Id: <7n59v4$16f$1@gellyfish.btinternet.com>
On Tue, 20 Jul 1999 17:08:38 -0700 Kevin M. Sproule wrote:
>
> Jonathan Stowe wrote in message <7n2mtk$1nh$1@gellyfish.btinternet.com>...
>>On Mon, 19 Jul 1999 21:04:14 -0700 Kevin M. Sproule wrote:
>>>
>>> Ashish Kadakia wrote in message <932424514.5244@www.remarq.com>...
>>>>Hi, I would like to list all the files starting with the
>>>>root directory..
>>>>Can anyone point me how to do that?
>>>>
>>>
>>> What the previous examples lack in functionality they make up for in
>>> brevity. ;) The request was to list "all" the files starting with the
> root
>>> directory. Here a a working WIN32 solution.
>>>
>>
>><snip over blown example>
>>
>>> To iterate is human, to recurse devine.
>>>
>>
>>Quite so, quite so ...
>>
>>Of course as others have pointed out File::Find is by far the best way
>>to go but if you must do it yourself - you neednt waste so many keystrokes:
>>
>>SNIP<
>
> Your example may work well on UNIX but the object here was to write
> something for WIN32.
On which platform it works perfectly well.
> The File::Find routine will walk the WIN32 file
> structure, but it returns "/"s instead of "\"s.
Then you might want to look at the File::Spec module if this worries you.
File::Spec comes with recent Perl distributions and allows you to write
programs that are portable across the various filesystems of the OS that
Perl will run on.
Of course Perl doesnt care what slashes you wear - it is only the shocking
excuse for a shell on Windows that insists on using '\' because of the
mistaken choice of '/' for the switch character *before directories
where even thought of in DOS*.
> Sure, my code is too long
> and not too perlish, but it works. I thought the whole idea of perl is that
> there is more than one way to do it! (timtowdi) Most responders to posts
> seem to think that there is only one way to do it.
>
Most reasonable posters think that whilst there may be more than one way to
do something, there is often only one sensible one.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 21 Jul 1999 14:35:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie question: how put files from dir in array
Message-Id: <MPG.11ffdd1948aa6ca3989d11@nntp.hpl.hp.com>
In article <7n58li$6cn$1@nnrp1.deja.com> on Wed, 21 Jul 1999 19:56:43
GMT, mike cardeiro <mikecard@my-deja.com> says...
> In article <7mje4p$3o22@news.cyber.net.pk>,
> "Faisal Nasim" <swiftkid@bigfoot.com> wrote:
>
> > opendir MYDIR , "/etc/yourdir" or die "error: $!";
> > @files = readdir MYDIR;
> > close MYDIR;
> >
> you'll probably also want to:
> shift @files;
> shift @files;
>
> since the first to entries will be . and .. which you probably don't
> want in your array.
There is no assurance that the first two entries are . and .. so they
should be filtered out explicitly.
@files = grep !/^\.\.?$/, readdir MYDIR;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 21 Jul 1999 14:40:58 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie question: how put files from dir in array
Message-Id: <37963E6A.6A71A59F@mail.cor.epa.gov>
mike cardeiro wrote:
>
> In article <7mje4p$3o22@news.cyber.net.pk>,
> "Faisal Nasim" <swiftkid@bigfoot.com> wrote:
>
> > opendir MYDIR , "/etc/yourdir" or die "error: $!";
> > @files = readdir MYDIR;
> > close MYDIR;
> >
> you'll probably also want to:
> shift @files;
> shift @files;
>
> since the first to entries will be . and .. which you probably don't
> want in your array.
...which is why one is usually better off using grep() with
readdir() to fix this problem right away, like so:
@files = grep !/^\.\.?$/, readdir MYDIR;
or
@files = grep !/^\.{1,2}$/, readdir MYDIR;
Larry Rosler prefers #1, since it has 2 fewer characters.
And we all want to win at Perl golf. :-)
Repeat after me: "I am Tiger Woods!"
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 21 Jul 1999 21:02:21 GMT
From: whos_john_galt@my-deja.com
Subject: Perl usuage and Graphical Representation
Message-Id: <7n5cgk$85t$1@nnrp1.deja.com>
Thanks for the assistance and the patience:
I am a student of Perl. I am learning through trial and error, and a as
many books as I am able to grasp. I am able to confidently manipulate
database information through the need of a Web based classified
publication, I maintain. I use a Unix vitual server and am starting to
venture towards the NT world. If I were needing to manipulate database
information on a LAN, I believe I could tackle the process of providing
graphical representation of searches, reports, etc., using HTML and a
browser. But, is that an elementary way of doing things? I have read
posts where programmers tell that they use Perl daily and have never
used it for CGI. If I had Perl operating locally on an NT and wanted to
display information graphically, what would I use?
Thanks again for the patience. It is not always the easiest to learn to
swim in the middle of a desert.
Joey
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 21 Jul 1999 21:06:53 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: pipe "|" functionality: ksh can easily do, perl can hardly do?
Message-Id: <NDql3.1499$KM3.434042@burlma1-snr2>
In article <7n3uhg$bdk$1@news.ml.com>,
Michael Wang <mwang@tech.cicg.ml.com> wrote:
>The following Perl script (not working) and Shell script (working)
>illustrate what I want to do:
>
>For differnet situations, I want to generate two LISTS.
>And depending on the existence/order of situation, I want the
>"COMBINATION" of the LISTS, and then I want to traverse the COMBINED LIST.
>I want to do this without having to save anything in @VARIABLES.
>This is because the LIST maybe LONG, and doing so will use a lot
>of memory. By using PIPE type of thing, memory gets used and then released,
>used again, released again. Any help to make the following Perl script
>working is greatly appreciated. Thanks.
Take a look at open("-|") in perl.
However, unless these lists are enormous (10's of megabytes) or your
machine is really scrapped for RAM, my experience is that it's not that bad
to store them in Perl's memory.
--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
------------------------------
Date: Wed, 21 Jul 1999 14:41:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pipe "|" functionality: ksh can easily do, perl can hardly do?
Message-Id: <MPG.11ffde69e81d7daa989d12@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7n3uhg$bdk$1@news.ml.com> on 21 Jul 1999 07:57:36 GMT,
Michael Wang <mwang@tech.cicg.ml.com> says...
+ For differnet situations, I want to generate two LISTS.
+ And depending on the existence/order of situation, I want the
+ "COMBINATION" of the LISTS, and then I want to traverse the
+ COMBINED LIST. I want to do this without having to save anything in
+ @VARIABLES. This is because the LIST maybe LONG, and doing so will use
+ a lot of memory. By using PIPE type of thing, memory gets used and
+ then released, used again, released again. Any help to make the
+ following Perl script working is greatly appreciated. Thanks.
+
+ #!/usr/local/bin/perl -w
+
+ use strict;
+
+ my $i;
+ my $j;
+ my @i=();
+ my @j=("a", "b"); # @j could be ("a"), ("b"), ("b", "a")
+
+ foreach $j ( do { # hope to get either (1..5), (6..10),
+ foreach $i (@j) {# (1..10), (6..10 1..5) depending @j
+ if ( $i eq "a" ) { # generate long list, do not want
+ map { $_ } (1 .. 5); # to put in variable to save
+ } else { # memory, in each of the if-else
+ map { $_ } (6 .. 10); # branch.
+ }
+ }
+ }
+ ) {
+ print $j;
+ }
It is entirely possible that I don't understand your goals corrctly.
But the following program (essentially a one-liner) accomplishes what
the above seems to be intended to do.
#!/usr/local/bin/perl -w
use strict;
my @j = ("a", "b"); # @j could be ("a"), ("b"), ("b", "a")
foreach my $j ( map { $_ eq "a" ? 1 .. 5 : 6 .. 10 } @j ) {
print $j;
}
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 21 Jul 1999 17:06:41 -0400
From: Robert Rawlinson <Robert.Rawlinson@worldnet.att.net>
Subject: Problem compiling 'write'
Message-Id: <37963660.42C57980@worldnet.att.net>
This is a multi-part message in MIME format.
--------------9B15EB466B5EF3CBF6AC341B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am new to Perl. I wrote the following program borrowing heavily from
code in the perl camel See attachment.
When I compile I get the message:
syntax error at tsmdrrport.pl line 26, near "write"
Execution of tsmdrrport.pl aborted due to compilation errors.
I can't seem to understand what is wrong. Can anyone help?
--
Robert A. Rawlinson
E. Eileen Rawlinson ________
3456 Franklin Road | [][] \________________
Felicity, Oh 45120 ___ |_______ |
(513) 876-3256 ___/___|___+___ | [] [][] |
(517) 382-7263 | | | | | |
=()--------()---= -----------()()----=
--------------9B15EB466B5EF3CBF6AC341B
Content-Type: application/x-perl;
name="TSMDRRport.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="TSMDRRport.pl"
#!C:\Perl\bin\perl -w
format STDOUT_TOP =
page @<<<
$%
SMDR REPORT
CHECKING TO&FROM NUMBER 4488
STARTING: 06/03 AT ENDING: 06/14 AT
C C OR C S TM R DI
O L O G O G ACCOUNT
D L TY IN N R TY U FC MI OR
E I PE ORIGIN ID FO S P TERM ID T DATE TIME DUR OT CALLED NUMBER DIGITS OUTPULSED SS AUTHCODE
-- --- -- ------------ -- -- - -- ------------ - ------ ------ ------ -- ------------------------ ---------------- -- -------------
.
format STDOUT =
@< @<< @< @<<<<<<<<<<< @< @< @ @< @<<<<<<<<<<< @ @<<<<< @<<<<< @<<<.< @< @<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<
$RecCode, $CustGroup, $OrigType, $OrigId, $InfoDigits, $ConsNum, $SubGrp, $TermType, $TermId, $RouteInfo, $JulianDate, $Time, $Duration, $OrgFC, $TermFC, $Called
.
While (<STDIN>) {
( $RecCode, $CustGroup, $OrigType, $OrigId, $InfoDigits,
$ConsNum, $SubGrp, $TermType, $TermId, $RouteInfo, $JulianDate,
$Time, $Duration, $OrgFC, $TermFC, $Called ) =
split (/:/);
write;
};
--------------9B15EB466B5EF3CBF6AC341B--
------------------------------
Date: 21 Jul 1999 21:41:00 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem with hash of arrays
Message-Id: <7n5epc$s7t$1@lublin.zrz.tu-berlin.de>
badri <badri@wpi.edu> wrote in comp.lang.perl.misc:
>Hi,
> This a piece of code that I used to create a hash of arrays. Each array
>has 256 elements. For any new key, when I try to create an initial list
>of numbers it works fine. But when I try to retrieve a reference to the
>elements of an already present key from the hash to manipulate the
>list, it gives a segmentation fault.
>
>--- Code starts here ----
>
>#!/usr/bin/perl -w
>
># Initialization of the variables ;
>
>$pos = 0;
>$number = 0;
>
>use MLDBM 'DB_File';
>use Fcntl;
>
>tie (%hash, 'MLDBM', 'testfile.db', O_CREAT|O_RDWR, 0660) or die $!;
[more code snipped]
You can't store references in a tied hash, not without extra
gymnastics like Storable, Data::Dumper or friends. Looking
at cpan, I see a module MLDBM::Serializer::Data::Dumper, which
may be specially suited for use with MLDBM.
The error should probably be detected before a segfault happens,
but in any case references contain live pointers which are useless
in a second run of the same program.
Anno
------------------------------
Date: Thu, 22 Jul 1999 07:44:45 +1000
From: mark@NO-SPAM.lavalink.com.au (Mark Francis)
Subject: setuid and opening a file for writing
Message-Id: <mark-2207990744450001@kilimanjaro.lavalink.com.au>
I have a setuid perl script. The first thing it does is changes UID and
EUID to that of a specified user (can't change GID and EGID for some
reason, but I'll worry about that later).
sub change_uid()
{
my $user = $_[0];
my @pwfields = getpwnam($user);
# change uid and gid
$> = $< = $pwfields[2];
$( = $) = $pwfields[3];
# clear the path
$ENV{'PATH'} = '';
}
Sometime later I want to be able to write a new file. After scouring
perlipc, I've got:
sub write_file()
{
my $new_file = $_[0];
my $sleep_count = 0;
do {
$pid = open(KID_TO_WRITE, "|-");
unless (defined $pid) {
warn "cannot fork: $!";
die "bailing out" if $sleep_count++ > 6;
sleep 10;
}
} until defined $pid;
if ($pid) { #parent
while ($bytesread = read($data, $buffer, 1024)) {
print KID_TO_WRITE $buffer;
}
close(KID_TO_WRITE) || warn "kid exited $?";
} else { #child
($EUID, $EGID) = ($UID, $GID);
$ENV{PATH} = "";
open (FILE, "> $new_file")
|| die "can't open $new_file: $!";
while (<STDIN>) {
print FILE;
}
exit
}
}
This is almost character for character from perlipc on how to safely write
a file when running setuid. But, it still craps out with "Insecure
dependency in open while running with -T ....".
perlsec says to do much the same thing as above, but I can't see where the
problem lies.
Mark
------------------------------
Date: Wed, 21 Jul 1999 17:58:13 -0400
From: "Travis Surgnier" <surgie@bellsouth.net>
Subject: Shortening the length of a string
Message-Id: <grrl3.632$Hf6.661@news2.mco>
I'm working on a project which outputs several variables from a database.
One of these is a description which can get rather long. I'd like to know
how to shorten it to $X characters. I've looked through the perlfaq and
found nothing, and substr dosn't look to be what I need. If anyone can help,
it would be greatly appreciated.
Travis Surgnier
------------------------------
Date: Wed, 21 Jul 1999 23:56:39 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Timeout question
Message-Id: <Zmrl3.673$r34.5315@news1.online.no>
Bruce McFarlane <bmc@DELETEpeterboro.net> wrote in message
news:C5ol3.1$uc.153@198.235.216.4...
>The following block works 99% of the time but occasional the inevitable
happens and it goes >into a loop. Does perl have a timeout function and can
I add it to this block somehow?
A cheap and dirty workaround, but what the heck...
>while (($tname eq $sname) || ($xname =~ /$sname/m)) {
> &retry;
last if $n++ > $max_tries;
>}
------------------------------
Date: Wed, 21 Jul 1999 14:57:13 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Uploading--HELP
Message-Id: <37964239.44B327C0@mail.cor.epa.gov>
Bill wrote:
>
> Just a quick question.......
>
> This script works in netscape 4.51 but not in Explorer5.0. It is a perl
> script and I have been trying to make it go in both browsers. I will
> foward the perl script to you.
[snip of way too much code-like traife]
Once you realize that the code works in a browser, you should
see that the problem is with MSIE 5.0 . Not the code. So I
suggest that you ask this in a newsgroup which focuses on the
faulty browser. The experts there amy be able to tell you what's
wrong with MSIE 5.0 . I would suggest something in the
microsoft.public.inetexplorer.ie5beta.* hierarchy.
And since it *is* listed as beta, why are you surprised this
doesn't work? Have you tried it with IE 4.x?
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 217
*************************************