[7094] in Perl-Users-Digest
Perl-Users Digest, Issue: 720 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 11 00:07:24 1997
Date: Thu, 10 Jul 97 21:02:34 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 10 Jul 1997 Volume: 8 Number: 720
Today's topics:
Re: I just dont't get this -- opening a new filehandle topaz56@one.net
Re: I just dont't get this -- opening a new filehandle (Tung-chiang Yang)
Re: mixing up a list (Greg Bacon)
Re: monitor web page, How? (beryte)
Re: Newbie Array pass by reference question <ajohnson@gpu.srv.ualberta.ca>
Re: Newbie Win95 Perl Q <acepalk@bc.cybernex.net>
Open File on another server? <buck@huron.net>
Output to a file (David Zeng)
Re: Perl 4 to Perl 5? (Marshall Pierce)
Perl and Porter Stemming Algorithm (Kevin Bass)
Re: Perl and Sockets <mattias.lonnqvist@uidesign.se>
Re: Perl executing system commands on NT (Nathan V. Patwardhan)
Re: Perl is 20 times slower on Cray J90 than SGI! (brian d foy)
Re: Perl is 20 times slower on Cray J90 than SGI! <zot@ampersand.com>
Re: PERL system call (Even Holen)
problem w/associative array member as filehandle <binky@zeus.corp.teradyne.com>
Q: duping filehandles, OO (Marek Rouchal)
Q: Mail::Send <dhaen@eeiwzb.et.tu-dresden.de>
Re: removing every other character from a string (M.J.T. Guy)
Re: reverse chop? (beryte)
Re: reverse chop? (Greg Bacon)
Re: shift on an empty array returns ( undef ) in a list (Ivan Kohler)
Re: Sockets (Greg Bacon)
SSI on apache (cREATURE dEM0N)
Stripping text from a file <steveb@nation-net.com>
Subtle difference in library organization causes script (Bill Costa - UNH Computing & Information Srvs)
Re: system call and print <Y_Hu@fccc.edu>
Re: Tainted problem (dave)
Use of Reverse function <mchhabra@rms1.com>
Re: Use of Reverse function (beryte)
Re: Use of Win32::File and official perl5.004_01 on NT (Jamie O'Shaughnessy)
Re: Use of Win32::File and official perl5.004_01 on NT <rheald@futuresource.com>
Re: Using ANSIColor in write formatted screen output <rra@stanford.edu>
Re: Using ODBC & Ms Access with Perl for NT <coke@adrenalin.com>
Re: what are .pod files <ajohnson@gpu.srv.ualberta.ca>
Re: while (<FILEHANDLE>) (Tad McClellan)
Re: Wierd Angle Bracket Error (Tad McClellan)
Re: Wierd Angle Bracket Error (Jeff Stampes)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Jul 1997 13:28:42 GMT
From: topaz56@one.net
Subject: Re: I just dont't get this -- opening a new filehandle
Message-Id: <33c390e0.42152196@news.mindspring.com>
>I guess you don't expect to be asking any more perl questions then?
>
>That is a pretty effective way of ensuring that large numbers of
>people will never see another of your posts.
>
>The sound of all those killfile keys being pressed is deafening...
>
>
As if asking them here is worth a wit...
There are several people in this group who have gone out
of their ways to be more than polite, helpful & patient...
To them I apologize...
But as for you Tad (I figure that you are still waiting for a
response) & some of the other regulars in this group, what
I said earlier still holds...
You would rather flame someone than help them -- just review
your latest posts @ deja news...
I stand by what I said before, you're a bunch of assholes...
Best, Tom
Thomas Porter, Ph.D./ tporter@dtool.com
THE DIGITAL TOOL
http://www.dtool.com
"Never attribute to malloc
that which can be adequately explained by stupidity"
------------------------------
Date: Thu, 10 Jul 1997 01:14:47 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: I just dont't get this -- opening a new filehandle
Message-Id: <tcyangED2wsn.L3w@netcom.com>
What you accused could be right -- that some people flame instead of
offering help. However, you need to ask yourself two questions
(1) Are they really flames? Do they use 'a__holes' in their "flames"?
(2) Are there some people deserving a good flame?
If you put "Ph. D" in your signature, I believe you should be able to
figure out the answers.
==================================
topaz56@one.net wrote after zapping the scum of the universe:
: (deleted)
: But as for you Tad (I figure that you are still waiting for a
: response) & some of the other regulars in this group, what
: I said earlier still holds...
: You would rather flame someone than help them -- just review
: your latest posts @ deja news...
: I stand by what I said before, you're a bunch of assholes...
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 10 Jul 1997 23:45:27 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: zatezalo.2@osu.edu
Subject: Re: mixing up a list
Message-Id: <5q3s6n$fhi$2@info.uah.edu>
[Posted and mailed]
In article <33c56b04.5845515@nntp.service.ohio-state.edu>,
zatezalo.2@osu.edu (Shane) writes:
: If I've got an arry of 100 elements, all in order, what's the easiest way to
: totally mix-em up?
Credit our friend Merlyn with this beauty.
sub shuffle {
my @new = ();
push @new, splice @_, rand @_, 1 while @_;
@new;
}
@a = (1 .. 100);
print join "\n", shuffle(@a), "";
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 10 Jul 1997 23:17:05 GMT
From: beryte@leb.net (beryte)
Subject: Re: monitor web page, How?
Message-Id: <33c56d5f.3678427@news.telecom.at>
Bin Chen <266443@emc.fedex.com> wrote:
>How do know who is accessing you web page? Are there any scripts
>available for this purpose?
The easiest way would be to 'grep' the 'access_log' file;
See with your sysadmin, you shouldn't have any problem doing so.
Try also a more appropriate NG such as
comp.infosystems.www.authoring.cgi
bye,
beryte
------------------------------
Date: Thu, 10 Jul 1997 18:27:50 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Newbie Array pass by reference question
Message-Id: <33C56FF6.531E4A8B@gpu.srv.ualberta.ca>
mashfiel wrote:
!
! Hi all,
! Well, as the subject line says I'm a newbie. That said, here's the problem.
! I've been creating a program, and after getting it to work, I decided to
! 'tune' it, by using the 'use strict' statement, (yep, everything was global
! before! ) Anyway, I have it all working but for one part. The problem
! arises when I go to pass an array to a sub which will then edit it. Since
! my program will probably not make sense, I've taken a microcosmic view of
! my problem and present it here, in a very simple bit of code:
an excellent approach!
! #!/usr/local/bin/perl
! use strict;
! {
! my @Array = ();
! {
! my $i = 0;
! for (;$i<5; $i++)
! {
! &Initialise($i, \@Array);
! }
! }
! &printArr(@Array);
! }
!
! sub Initialise{
! my ($index, @subArr) = @_;
! @$subArr[$index] = $index;
! }
[snip rest of code]
! When I run this program I receive the following message:
!
! Global symbol "subArr" requires explicit package name at test2.pl line 17.
seems there's a typo in your Initialize() routine
you have
my ($index, @subArr)=@_;
^
should be
my ($index, $subArr)=@_;
^
a reference to an array is a scalar
but you dereference it in the next line just fine :-)
regards
andrew
------------------------------
Date: Wed, 09 Jul 1997 10:43:30 -0400
From: Richard Kuzsma <acepalk@bc.cybernex.net>
To: Michael Boswell <bozi@connexus.apana.org.au>
Subject: Re: Newbie Win95 Perl Q
Message-Id: <33C3A392.35F3@bc.cybernex.net>
Michael Boswell wrote:
>
> Hi, Im using HTTPD on my local computer, I load up the TCP/IP stack
> and everything seems fine. I' m just starting to write perl code, but
> all i'm trying to do is a simple form input, process and output. As
> far as I can tell the parsing and processing is ok. The output isn't
> working ? I'm writing the correct HTML format - content-type etc.. But
> netscape returns with a Document contains no data error. I just don't
> know what this means.
>
> BTW im using action=get.
>
> thanks
>
> bozi
There is probably a syntax error in your Perl script. Personally, I
don't use Netscape when testing Perl scripts. It never gives me good
syntax-error readouts. I tend to have more luck with MS Internet
Explorer, which tells me on what lines script errors occurred, and
sometimes offers suggestions as to what the problem might be.
Note that I am still a novice Perl programmer. There are undoubtedly
many ways to debug Perl scripts which I have not yet discovered. But for
the meantime, I use MSIE's browser.
adios,
~ Pal
acepalk@bc.cybernex.net
------------------------------
Date: Thu, 10 Jul 1997 23:18:07 -0400
From: Stephen Hill <buck@huron.net>
Subject: Open File on another server?
Message-Id: <33C5A5EA.EC37909B@huron.net>
How do you open a file which is on another server?????
buck@huron.net
------------------------------
Date: 9 Jul 1997 17:09:58 -0700
From: dizzy@soda.CSUA.Berkeley.EDU (David Zeng)
Subject: Output to a file
Message-Id: <5q198m$pi@soda.CSUA.Berkeley.EDU>
Hi, there,
Thanks for the lots of help last time I posted a question. Well, I
have another question.
After reading and processig data from a file, I wanted to output the
parsed information to another file, line by line. What I did is that
I opened up another file by:
open(OUTFILE, ">$outname") or die (blah, blah...)
and later printed each line into a file from a for loop like this:
print OUTFILE $outline;
The files I am reading are quite long, with over 100 lines. If I limit
the number of line printed into OUTFILE is 40 or less (around 40), then
I get the result I want. If I read in more than 40 lines, the file
created by OUTFILE turns out to be empty.
What kind of problem is this? I couldn't have run out of memory here
and caused some kind of failure of Perl functions? I got 64MB on a
Sparc 5. Is there some built-in limitation on my format of printing
lines into another file?
Thanks for any help.
David Zeng
------------------------------
Date: 9 Jul 1997 17:40:44 GMT
From: piercem@col.hp.com (Marshall Pierce)
Subject: Re: Perl 4 to Perl 5?
Message-Id: <5q0ies$aqu$1@nonews.col.hp.com>
Definitely weird. I tried a simple test and it worked fine (assuming
value of _TOP). I've been trying to get it to work by defining $^ and
writing, or not defining $=, and lots of other stuff with no luck.
I have a workaround of changing the name of the _TOP and writing it as
$~ instead.
I'd be willing to post the script (it'd be interesting to hear about
better ways to do the whole thing, anyway - it's 352 lines).
Marshall Pierce (piercem@col.hp.com) wrote:
: Well, I'm finally forced to start work on converting my perl 4 scripts
: to perl 5.003 - and guess what? My very first script has a problem
: writing my _TOP format.
: - why, if I open a file for write, and have filehandle_TOP and filehandle
: formats defined, select $~=filehandle and write, does the _top not
: get written in 5?
--
Marshall V Pierce /_ __ TIS - WWUSP Technology Team
marshall_pierce@hp.com / //_/
USA (719) 590-3461 / http://hpweb.cs.itc.hp.com/wwusp/piercem/
------------------------------
Date: Wed, 09 Jul 1997 16:06:13 GMT
From: akil1@mindspring.com (Kevin Bass)
Subject: Perl and Porter Stemming Algorithm
Message-Id: <5q0cug$79l@camel2.mindspring.com>
Is there a perl version of the Porter Stemming Algorithm? If so, where
can I find it.
Kevin Bass
------------------------------
Date: Wed, 09 Jul 1997 15:46:27 +0200
From: Mattias Lvnnqvist <mattias.lonnqvist@uidesign.se>
Subject: Re: Perl and Sockets
Message-Id: <33C39633.5F6A@uidesign.se>
> I am working on a client/server app that is written in Perl. I am
> looking to read in a filename from the command line, pass it to the
> server, have the server open up the file and send its contents back to
> the client application. I have gotten past reading in the filename from
> the command line, but I am gaving a hard time with the actual socket
> stuff. Do I use read()/write() or do I use send()/recv()? I have looked
> all over the Net for stuff and through the camel books, but can't find a
> very good explanation. Any examples of this in Perl that you can point
> me to on the net or any help that you can provide would be most
> appreciated. Thank you for your help.
Try "http://www.cs.uno.edu/~golden/teach.html"
/Mattias
--
This was a message from Mattias Lonnqvist * mailto:malo@uidesign.se
http://www.uidesign.se/~malo * phone +46 - (0)13- 37 12 05
Unsolicited commercial email is subject to an archival fee of $400.
See <http://www.uidesign.se/~malo/mail.html> for more info.
------------------------------
Date: 10 Jul 1997 22:31:48 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl executing system commands on NT
Message-Id: <5q3nsk$62q@fridge-nf0.shore.net>
Tom Phoenix (rootbeer@teleport.com) wrote:
: Really? This is the first I've heard of it. :-) Maybe they aren't closing
: their pipes, or maybe they think EOF is a character that must be sent.
I noticed the same problem with postmail and other companion products.
I don't think it's Perl tho. I've been able to do some other things
with pipes on NT that seem to work fine.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Wed, 09 Jul 1997 12:46:52 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl is 20 times slower on Cray J90 than SGI!
Message-Id: <comdog-ya02408000R0907971246520001@news.walrus.com>
In article <33C3A298.41C6@lmtas.lmco.com>, Brett Denner <Brett.W.Denner@lmtas.lmco.com> wrote:
> Justin Banks wrote:
> #!/usr/local/bin/perl -w
> for (0 .. 1000000) { $a = 0 }
>
> and the following C program (compiled with "cc prog.c -o prog"):
>
> void main()
> {
> int i; float a;
> for (i=0; i <= 1000000; i++)
> { a = 0; }
> }
>
> Both programs do essentially the same thing.
you are doing the same thing in much different ways! in your perl
example you have to deal with creating that HUGE list. try doing
the same thing in perl
for ($i = 0; $i <= 1000000; $i++)
{
$a=0;
}
this is a lot closer to your C example :)
--
brian d foy comdog@computerdog.com
------------------------------
Date: 09 Jul 1997 22:30:39 -0400
From: Mark Atwood <zot@ampersand.com>
Subject: Re: Perl is 20 times slower on Cray J90 than SGI!
Message-Id: <v6vi2jk59s.fsf@tick.dev.ampersand.com>
Brett Denner <Brett.W.Denner@lmtas.lmco.com> writes:
>
> #!/usr/local/bin/perl -w
> for (0 .. 1000000) { $a = 0 }
>
Ouch.
Refer to the comment "the tail wagging the dog" in the Camel book,
and rewrite that as the C style "3 part" for loop.
That "(0 .. 1000000)" has to allocate and populate a list of
a million and one scalars, which a a BIT of an overkill just
for an ascending index loop.
--
Mark Atwood | Thank you gentlemen, you are everything we have come to
zot@ampersand.com | expect from years of government training. -- MIB Zed
------------------------------
Date: 10 Jul 1997 16:58:51 GMT
From: evenh@ra.pvv.ntnu.no (Even Holen)
Subject: Re: PERL system call
Message-Id: <slrn5sa54g.rot.evenh@ra.pvv.ntnu.no>
In article <Pine.OSF.3.95.970710175206.9607D-100000@waiy>,
Andrew Williams wrote:
>Please could some one help me!
>
>I am trying to use system to call an external program. This works fine
>but I don't really want to see the output on the screen or pipe it to a
>file as there is a lot of output (approx 1Mb). Therefore I would like to
>send it to null but don't seem to be able to.
>
>Please email me if you have any ideas.
I guess this really is a FAQ, but try something like:
system ("doSometing >/dev/null 2>&1");
or you could try:
`doSomething`; # But this doesn't take care of STDERR
or you could try redirecting both STDOUT and STDERR somewhere before
doing your system call...
I do like the first one best... If you wonder why it works then look
up 'man sh'.
Regards,
Even Holen
--
<>< Even Holen, evenh@pvv.ntnu.no, http://www.pvv.ntnu.no/~evenh/ :-)
------------------------------
Date: Wed, 09 Jul 1997 12:25:17 -0400
From: Michael Batchelder <binky@zeus.corp.teradyne.com>
Subject: problem w/associative array member as filehandle
Message-Id: <33C3BB6D.5088@zeus.corp.teradyne.com>
Greetings, all;
I'm attempting to use an element of an associative array as a
filehandle to a print statement, e.g.
print $filehandles{$index} "Some text\n";
I get an error message:
syntax error in file testfh.pl at line 5, next 2 tokens "} "Some
text\n""
Execution of testfh.pl aborted due to compilation errors.
This seems like a legit statement. The values of $index and
$filehandles{$index} are well-behaved quantities... Anyone have
an idea of what's wrong?
TIA,
Michael
------------------------------
Date: 9 Jul 1997 08:50:16 GMT
From: marek@buffalo.HL.Siemens.DE (Marek Rouchal)
Subject: Q: duping filehandles, OO
Message-Id: <5pvjc8$8f1$1@mosquito.HL.Siemens.DE>
Keywords: dup, filehandle, objects
Hi *!
I've RTFM and tried everything that came to my mind, but I just didn't
find out what the correct object-oriented syntax for duping filehandles
is. Here's the code snippet with the ugly kludge ($kid_* were created
by Filehandle::pipe):
[...]
$kid_wtr->autoflush(1);
$kid_rdr->autoflush(1);
*KWTR = $kid_wtr;
*KRDR = $kid_rdr;
open(STDOUT,">&KWTR") || die "dup failed: $!";
open(STDIN, "<&KRDR") || die "dup failed: $!";
exec "$cmd";
[...]
This is the only way to dup the kid_* filehandles to STDIN/STDOUT that works.
I've tried:
*STDOUT = $kid_wtr; # works for perl, but not for exec'ed programs.
and
open(STDOUT,">&$kid_wrt") || die "dup failed: $!"
# dies with "Invalid Argument"
I'm using perl5.00305/Solaris 2.5.1/Ultra-1. Any help is appreciated!
(NB: I do not want to use IPC::open2() or IPC::open3().)
Kind regards,
Marek
+--------------------------------------------------------------------+
Marek Rouchal
SIEMENS AG Phone : +49 89/636-25849
HL CAD SYS Fax : +49 89/636-23650
Balanstr. 73 mailto:Marek.Rouchal@hl.siemens.de
81541 Muenchen PCmail:Marek.Rouchal.PC@hl.siemens.de
+--------------------------------------------------------------------+
------------------------------
Date: Wed, 09 Jul 1997 14:31:06 +0200
From: Dirk Haenelt <dhaen@eeiwzb.et.tu-dresden.de>
Subject: Q: Mail::Send
Message-Id: <33C3848A.229A@eeiwzb.et.tu-dresden.de>
hi,
i have a problem by using the Mail package from Tim Bunce.
When i will send a mail with this source:
++++++
#!/usr/bin/perl -w
use Mail::Send;
$mail = new Mail::Send;
$mail->subject('Important Notice');
$mail->to('user@host');
$mail->set('X-Text', 'a test entry');
$mail->add('X-Text', 'a test entry');
$mh = $mail->open();
print $mh "Hier kommt der Brieftext.";
$mh->close();
++++++
i send the mail, this is ok, but there is no subject in
the header of mail. the subject was wrote into the body of message.
here is the mail:
++++++
>From user@host Wed Jul 9 13:55:36 1997
Return-Path: user
Received: (from user@localhost) by host (8.7.5/8.7.3) id NAA22488 for
www; Wed, 9 Jul 1997 13:55:35 +0200
Date: Wed, 9 Jul 1997 13:55:35 +0200
From: Dirk Haenelt (user) <user@host>
Message-Id: <199707091155.NAA22488@host>
To: user@host
Status: RO
~s Important Notice!
Hier kommt der Brieftext.
+++++
can everybody help me ???
the set and add methode is no working too !?
i use perl v 5.002
and MailTools-1.09.tar.gz
linux 2.0.27
pse answers as mail too !
many thanks,
--
Dipl.Ing. Dirk Haenelt [DG1HTK]
ETI, Grundlagen, TU-DRESDEN
Tel. :+49 351 4635354 Fax.: 4637111
mailto:dhaen@eeiwzb.et.tu-dresden.de http://141.30.118.28
HAM :DB0TUD.#SAX.DEU.EU
------------------------------
Date: 9 Jul 1997 09:31:54 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: removing every other character from a string
Message-Id: <5pvlqa$541@lyra.csx.cam.ac.uk>
Tim Smith <trs@azstarnet.com> wrote:
>I'm read'ing from a binary file where every other character describes
>the color of the previous (ASCII) character. I don't care about the
>color, I just want the ASCII text. Is there a better way than just
>using s/(.)./$1/gs to strip out every other character? It seems that
>unpack() might work, but I can't figure out how to do it.
$_ = pack 'a' x ((length)/2), unpack 'ax' x ((length)/2), $_;
Mike Guy
------------------------------
Date: Thu, 10 Jul 1997 22:18:40 GMT
From: beryte@leb.net (beryte)
Subject: Re: reverse chop?
Message-Id: <33c55fb4.178273@news.telecom.at>
...but in case you still need a reverse chop ;-)
$string = "XHello there!";
$string = scalar (reverse $string);
chop($string);
print scalar (reverse $string);
But go for
$string =~ s/^.//;
Also take a look at message "Use of Reverse function" (July 9, 1997)
in this same NG and the reply from Mike Stok.
beryte
------------------------------
Date: 10 Jul 1997 00:20:48 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: eglamkowski@mathematica-mpr.com
Subject: Re: reverse chop?
Message-Id: <5q19t0$97o$3@info.uah.edu>
[Posted and mailed]
In article <33C27DF2.578@mathematica-mpr.com>,
the count <eglamkowski@mathematica-mpr.com> writes:
: Is there any trivial way to remove the first character of a string?
$str =~ s/^.//s;
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Thu, 10 Jul 1997 19:52:01 GMT
From: ivan@voicenet.com (Ivan Kohler)
Subject: Re: shift on an empty array returns ( undef ) in a list context, not an empty list?
Message-Id: <33c53890.140168105@netnews.voicenet.com>
Glen Culbertson <nnyxcu@ny.ubs.com> wrote:
>Ivan Kohler wrote:
>>
>> Hello,
>>
>> Took me quite some time to track down a bug caused by my misunderstanding of
>> the shift command. In a scalar context, when shift'ing an empty array,
>> shift returns the undefined value, as expected. In a list context, however,
>> I was assuming (wrongly) that shift on an empty array would return an empty
>> list. Instead, it returns a list with one scalar value (undef).
>>
>> I searched through the perl-porters' archive, and couldn't find anywhere
>> where a decision was made one way or the other with regards to this
>> behavior. My question is twofold; One, would it be desirable to modify the
>> behavior of shift so that it does return an empty list (and, I suppose, how
>> would I go about proposing such a thing), and two, can anyone think of a
>> less "kludgy" way to emulate my desired behavior than what I'm currently
>> using:
>>
>> {
>> my($temp) = shift @array;
>> $temp ne undef ? $temp : ();
>> }
>>
>
> 2. How about
>
>@target = @array ? shift @array : ();
>
> ? _Slightly_ more simple.
Doesn't look like it is going to get any more simple. Thanks!
> 1. Arrays are lists of scalars. Shift returns one element from the list,
> therefore its return vaule is a scalar (undef if there are zero elements).
Yep, and that seems intuitive in a scalar context. In a list context, the
empty list seemed to me to be more intuitive than a list of one undef
scalar. But of course I've never designed a language, which is why I was
posing the question.
FYI, The actual application was inside a construct something like this:
push @result, [
map {
shift @{ $HoL{$_} }
} (
.
.
.
)
]
Where "HoL" is of course a hash of lists.
> It would be very convoluted and inconsistent to have it behave otherwise.
> For instance, assigning a scalar variable to an array variable results in the
> array having one element, the value of which is the value of the scalar; e.g.:
>
>$x = 6;
>
> now saying
>
>@x = $x;
>
> is equivalent to saying
>
>@x = (6);
>
> If the the scalar variable is undefined, then the resulting array after the
> assignment has one element, undef.
>
> This is also the result you get if you assign the result of shift on an
> empty array to another array; i.e., if neither $x nor @x is defined, then both
>
>@y = shift @x;
>
> and
>
>@y = $x;
>
> give the same result: $y[0] == undef.
>
>
> IMHO, this consistency is probably better for all of us in the long run than the
> special behavior you would like to see.
Ivan Kohler
VoiceNet Staff
ivan@voicenet.com
"I may not have the world to give to you
but maybe I have a tune or two." -JG/RH
------------------------------
Date: 10 Jul 1997 00:37:52 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: Geoff Sherman <gssherma@schmelze.corp.hp.com>
Subject: Re: Sockets
Message-Id: <5q1at0$97o$4@info.uah.edu>
[Posted and mailed]
In article <33C3F743.3176@schmelze.corp.hp.com>,
Geoff Sherman <gssherma@schmelze.corp.hp.com> writes:
: I am looking for examples of FULL Perl sockets on the Net. I am trying
: to find something that reads in command line data, writes it to a socket
: from the client, the server reads the name from the socket, opens the
: file with that name, writes the data across the socket, and then have
: the client read the socket and print what was in the file. Any help?
If I'm parsing properly, you want some sort of remote cat. If so, here you
go:
#! /usr/bin/perl -Tw
# rcatd -- Greg Bacon <gbacon@cs.uah.edu>
use IO::Select;
use IO::Socket;
$lsn = new IO::Socket::INET(Listen => 1,
LocalPort => 1234,
Proto => 'tcp');
$sel = new IO::Select( $lsn );
while(@ready = $sel->can_read) {
foreach $fh (@ready) {
if($fh == $lsn) {
# Create a new socket
$new = $lsn->accept;
$sel->add($new);
}
else {
my $tainted = <$fh>;
$tainted =~ s/^\s+//;
$tainted =~ s/\s+$//;
$tainted =~ m!^([\w/]+)!; # you'll probably want to
# apply more checks e.g.
# $1 ne /etc/passwd
my $file = $1;
unless (open FILE, $file) {
print { $fh } "Failed open $file: $!\r\n";
}
else {
my $buff = '';
while (sysread FILE, $buff, 4096) {
$buff =~ s/\n/\r\n/g;
print { $fh } $buff;
select undef, undef, undef, 0.5;
}
}
$sel->remove($fh);
$fh->close;
}
}
}
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Wed, 09 Jul 1997 22:37:27 GMT
From: creature.demon@unicall.be (cREATURE dEM0N)
Subject: SSI on apache
Message-Id: <33c5125a.59964631@news.unicall.be>
I want to use SSI on my site, for a banner rotator. But how do i
configure apache to use SSI. My provider uses apache as webserver. But
he does'nt know how to do it.
Someone told me to put as .htacces file in my directory. This is how
my .htaccess file looks :
Options Indexes FollowSymLinks Includes ExecCGI
Options includes
AddType text/x-server-parsed-html .shtml
ErrorDocument 401 /cgi-bin/guardian.cgi?401
ErrorDocument 403 /cgi-bin/guardian.cgi?403
ErrorDocument 404 /cgi-bin/guardian.cgi?404
ErrorDocument 500 /cgi-bin/guardian.cgi?500
I have chmodded 644 the file. But it dont want to do it, he even don't
load the guardian script. Does someone know how to do this ?
Like i sayd, nothing is working, nor the advertiser, nor the
guardian.cgi
------------------------------
Date: Thu, 10 Jul 1997 11:47:32 +0000
From: Steve Burton <steveb@nation-net.com>
Subject: Stripping text from a file
Message-Id: <33C4CBD1.1EAEA118@nation-net.com>
I am very new to perl.
What i am trying to achieve it for perl to search a text file and find
"abc" and strip the line that is on and the next line and generate a
file with what is left.
Thanks
Steve
------------------------------
Date: 9 Jul 1997 21:49 EST
From: w_costa@unhb.unh.edu (Bill Costa - UNH Computing & Information Srvs)
Subject: Subtle difference in library organization causes script failure.
Message-Id: <9JUL199721495841@unhb.unh.edu>
Well -- subtle to me anyways. I'm using Perl on two different machines
that are both running the same version of Digital Unix (V4.0B) and the
same version of Perl -- as confirmed by:
+---------------------------------------------------------------------
| % perl -v
|
| This is perl, version 5.004
|
| Copyright 1987-1997, Larry Wall
|
| Perl may be copied only under the terms of either the Artistic License
| or the
| GNU General Public License, which may be found in the Perl 5.0 source
| kit.
|
which gave the same results on both machines.
On one machine the following script compiles and runs, but on the other
it doesn't.
+---------------------------------------------------------------------
| #!/usr/bin/perl -w
|
| use DB_File;
| use Fcntl;
|
| tie %h, "DB_File", "hashed", O_RDWR|O_CREAT, 0644, $DB_HASH;
|
| # Add a key/value pair to the file.
| print "Adding an apple.\n";
| $h{apple} = "orange";
| print "\$h{apple} = $h{apple}\n";
|
| # delete
| delete $h{"apple"};
| print "after delete: \$h{apple} = $h{apple}\n";
| untie %h;
|
On machine A, the execution works fine:
+---------------------------------------------------------------------
|
| % DB_File.test.pl
| Adding an apple.
| $h{apple} = orange
| after delete: $h{apple} =
|
On machine 2, it doesn't compile:
+---------------------------------------------------------------------
|
| % DB_File.test.pl
| Can't locate DB_File.pm in @INC at DB_File.test.pl line 3.
| BEGIN failed--compilation aborted at DB_File.test.pl line 3.
|
The first thing I checked, of course was the contents of @INC on both
machines. The following command yields identical results on machine A
and 2:
+---------------------------------------------------------------------
|
| % perl -e 'foreach $item (@INC) { print "$item\n" }'
| /usr/local/lib/perl5/alpha-dec_osf/5.004
| /usr/local/lib/perl5
| /usr/local/lib/perl5/site_perl/alpha-dec_osf
| /usr/local/lib/perl5/site_perl
| .
I then checked what files could be found with these paths. On machine
A (the machine that works):
+---------------------------------------------------------------------
|
| % find `perl -e 'foreach $item (@INC) { print "$item\n" }'` \
| ? -print | fgrep DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/autosplit.ix
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.so
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.bs
| /usr/local/lib/perl5/alpha-dec_osf/5.004/DB_File.pm
| /usr/local/lib/perl5/alpha-dec_osf/5.003/auto/DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.003/auto/DB_File/DB_File.so
| /usr/local/lib/perl5/alpha-dec_osf/5.003/auto/DB_File/DB_File.bs
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/autosplit.ix
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.so
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.bs
| /usr/local/lib/perl5/alpha-dec_osf/5.004/DB_File.pm
| /usr/local/lib/perl5/auto/DB_File
| /usr/local/lib/perl5/auto/DB_File/autosplit.ix
| /usr/local/lib/perl5/DB_File.pm
| /usr/local/lib/perl5/man/man3/DB_File.3
|
On machine 2 where it doesn't work:
+---------------------------------------------------------------------
|
| % find `perl -e 'foreach $item (@INC) { print "$item\n" }'` \
| ? -print | fgrep DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/autosplit.ix
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.so
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.bs
| /usr/local/lib/perl5/alpha-dec_osf/5.004/DB_File.pm
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/autosplit.ix
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.so
| /usr/local/lib/perl5/alpha-dec_osf/5.004/auto/DB_File/DB_File.bs
| /usr/local/lib/perl5/alpha-dec_osf/5.004/DB_File.pm
| /usr/local/lib/perl5/man/man3/DB_File.3
|
As you can see, Machine A has both V5.003 and V5.004 files on it, where
in contrast V5.004 was a fresh install on Machine 2.
Soooo.... My questions are: Is it the V5.003 files that are allowing me
to run on Machine A? Or is it the *lack* of the
/usr/local/lib/perl5/auto/DB_File
/usr/local/lib/perl5/DB_File.pm
directories on Machine 2?
Since the system manager for both machines will be out for another
week, I'd appreciate any suggestions for a work around to get this
working on Machine 2. I took a stab in the dark at this myself with
the following line added to my script on Machine 2:
BEGIN {
push(@INC,'/usr/local/lib/perl5/alpha-dec_osf/5.004');
}
but that only caused a different set of compile time error message:
+---------------------------------------------------------------------
|
| % DB_File.test.pl
| Identifier "main::DB_HASH" used only once: possible typo at
| DB_File.test.pl line 11.
| Can't locate object method "TIEHASH" via package "DB_File" at
| DB_File.test.pl line 11.
|
I mention this only in case it might provide additional insight as to
what is going on.
Thanks in advance for any advice!
Later....BC
## ## ## ## +----------------------------[ Bill.Costa@UNH.EDU ]---+
## ### ## ## | Bill Costa |
## #### ## ## | Computing & Information Srvs |
## ## ## ######## | Kingsbury Hall PHONE: +1-603-862-3056 |
## ## #### ## | University of New Hampshire FAX: +1-603-862-4778 |
## ## ### ## | Durham, NH 03824-3591 USA |
####### ## ## +----------------[ No good deed goes un-punished. ]---+
------------------------------
Date: Wed, 09 Jul 1997 09:39:35 -0400
From: Ying Hu <Y_Hu@fccc.edu>
To: Tim Yao-ting Lee <tylee@unixg.ubc.ca>
Subject: Re: system call and print
Message-Id: <33C39497.167E@fccc.edu>
Tim Yao-ting Lee wrote:
> open( FILE, "result.log" );
try:
open FILE,">>result.log";
Ying
------------------------------
Date: Tue, 08 Jul 1997 22:21:22 GMT
From: over@the.net (dave)
Subject: Re: Tainted problem
Message-Id: <33c2b9e1.3191362@news.one.net>
Oliver Giller <oliver@inetu.net> wrote:
>I am having a problem with taint in a set-uid perl script.
>I am writing a file out to /tmp/ and then trying to open this file with
>an editor. The editor is pulled from $ENV{'EDITOR'}.
>
>I keep getting the error
> Insecure PATH at /usr/share/perl/vedit.lib line 332.
>
>I have tried a number of ways of untaining the variables.
>Here is the code.
>
> $ENV{'EDITOR'} =~ /^-P(\w+)$/; # attempt 1 at untaiting
> $editor = $1;
>
> $command = "$editor $sectionFileName";
> $command =~ /^(.*)$/; # attempt 2 at untaiting
> $command = $1;
>
> system ("$command");
>
>
As the message implies, I think the PATH variable is tainted, so the
system command itself is having a problem. According to the book,
doing a
$ENV{PATH} = '/bin:/usr/bin';
$ENV{IFS} = "" if $ENV{IFS} ne "";
should take care of this problem, but perhaps not with untainting the
EDITOR variable.
I'll assume that your script belongs to a restricted account so I
won't condemn you for invoking EDITOR without knowing the details :)
But why do folks continue to surround hash keys with apostrophe's when
the camel book says you don't need them?
Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: 9 Jul 1997 21:37:01 GMT
From: "maninder chhabra" <mchhabra@rms1.com>
Subject: Use of Reverse function
Message-Id: <01bc8cb0$39ed0a60$126644c6@rms-1>
Hi,
I ma trying to read string backwards. I tried using reverse function in the
scalar context but it does'nt do anything. Let me know if there is any
solution to this.
Mani
------------------------------
Date: Wed, 09 Jul 1997 22:38:12 GMT
From: beryte@leb.net (beryte)
Subject: Re: Use of Reverse function
Message-Id: <33c411d8.2456323@news.telecom.at>
maninder chhabra <mchhabra@rms1.com> wrote:
>I ma trying to read string backwards. I tried using reverse function in the
>scalar context but it does'nt do anything. Let me know if there is any
>solution to this.
#!/path/to/perl
$body = "etyreb !spleh siht epoH"; # Scalar context
$rev_body = reverse $body; # Reversing
print "\n\t $rev_body \n"; # Printing
#beryte
------------------------------
Date: Wed, 09 Jul 1997 12:15:20 GMT
From: joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
Subject: Re: Use of Win32::File and official perl5.004_01 on NT and other problems on NT
Message-Id: <33c380c5.2667859@newshost.us.oracle.com>
Yep, that fixed it.
Jamie
------------------------------
Date: Wed, 09 Jul 1997 15:50:02 -0500
From: Rien-always-been-Heald <rheald@futuresource.com>
To: joshaugh@uk.oracle.com
Subject: Re: Use of Win32::File and official perl5.004_01 on NT and other problems on NT
Message-Id: <33C3F97A.144E@futuresource.com>
This is just an inquiry on my part to somebody whom I am assuming is
using Perl in a Win32 environment?
If you are using Perl in a Win32 environment, are you using the LWP
libraries? If so, how'd you get them installed?
Thanks.
Rien Heald
------------------------------
Date: 09 Jul 1997 04:11:54 -0700
From: Russ Allbery <rra@stanford.edu>
To: ben@dha.unon.org
Subject: Re: Using ANSIColor in write formatted screen output
Message-Id: <m32058tr7p.fsf@windlord.Stanford.EDU>
[ Posted, mailed, copy to perl5-porters. ]
ben <ben@dha.unon.org> writes:
> I have a Perl script that updates a screen display about once a second
> with a system{'clear'}; write; sequence. The flicker isn't too bad and it
> does it does the job (monitoring diald pipe for Linux). I would like to
> insert color into the screen output, but format treats the the escapes
> strangely. I have used ANSIColor to colorize a scalar variable. I can see
> the variable in the screen output, in color, but its at the top left
> corner of the screen instead of the bottom. I have read and searched a
> lot on the perl sites and dejanews but have not found an answer.
Looks like something's a bit screwy with format's handling of escape
sequences. I'm not sure why.
windlord:~> perl
$_ = "\e[34mTesting\e[0m\n";
print;
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<
$_
.
write;
produces the correct thing from the print (the word Testing in blue), but
the write produces:
[34mTesting [0m
So why is the escape being translated into a space under Perl 5.004_01?
That also seems inconsistent with what was observed above.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 8 Jul 1997 22:56:33 GMT
From: "Chris Oke" <coke@adrenalin.com>
Subject: Re: Using ODBC & Ms Access with Perl for NT
Message-Id: <01bc8bf2$5f553f20$371c9bcf@pc10.adrenalin.com>
Miran Sepic <miran.sepic4@mss.tel.hr> wrote in article
<01bc8b7e$cb0df140$7a000047@pc_miran>...
> I am looking for the following information:
>
> How can I use MS Acess Database (.mdb) in Perl script?
>
Win32::ODBC (look for it in CPAN or at http://www.roth.net/odbc/ )
Hope that helps
Chris
------------------------------
Date: Thu, 10 Jul 1997 00:45:52 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: what are .pod files
Message-Id: <33C47710.6E84F72F@gpu.srv.ualberta.ca>
Charles E. Burleson wrote:
>
> I have seen many references to .pod files, and programs that convert pod
> to html. What are and how are .pod files generated?
> thanks
>
pod (plain old documentation):
search for POD in the 'perlsyn' manpage, then take
a look at the 'perlpod' manpage.
regards
andrew
------------------------------
Date: Thu, 10 Jul 1997 17:09:31 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: while (<FILEHANDLE>)
Message-Id: <rim3q5.9v6.ln@localhost>
Tim Smith (trs@azstarnet.com) wrote:
: In article <33C53B92.41C6@sed.nist.gov>,
: Jack Coursey <jcoursey@sed.nist.gov> wrote:
: >Try to teach myself Perl out of a poor book for those new to the
: >language
: You really, really should get a decent book. If it's a poor book it's
: a poor book. If it doesn't explain simple concepts well, how could
: it explain the complex concepts well? Get the Programming Perl book,
: 2nd edition, and read the first two chapters straight through. Borrow
: from a friend or from the library if you can't afford the book. Or
: just go to the bookstore and sit on the floor reading it - it's that
^^^^^^^^^
: imperative (because "iff the line input operator is the only thing inside
^^^^^^^^^^
No it isn't.
The Camel is a wonderful book, and you really must read it, but
the citation you give is also in the free man pages (perlop) that are
*included with the perl distribution*.
--------------
assignment happens. I<If and ONLY if> the input symbol is the only
thing inside the conditional of a C<while> loop, the value is
automatically assigned to the variable C<$_>. The assigned value is
--------------
Cool huh?
And it is FREE!
And (if you have perl) you ALREADY have it!
When I have a perl question, I look in (in this order):
1) man pages ( *.pod files from the distribution)
2) Perl FAQ
3) any of the O'Reilly books
4) any other book that you got duped into buying (you should have bought
all three of the O'Reilly books first ;-)
a) "Learning Perl"
b) "Programming Perl"
c) "Mastering Regular Expressions"
5) search dejanews
6) poke around at http://www.perl.com
If all of those fail to provide an answer, _then_ I would resort
to posting an original question.
7) post a question to comp.lang.perl.misc
I have never made it to step 7 yet...
: the conditional of a while loop, the value is automatically assigned to
: the special variable $_", page 53).
Use the docs, Luke. ;-)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 8 Jul 1997 16:45:23 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Wierd Angle Bracket Error
Message-Id: <jdcup5.888.ln@localhost>
Joshua Marotti (jpm@iti-oh.com) wrote:
: I have the following chunck in my script...
: while (!($params = /;/))
^
^ ???
you probably want =~ there to do a pattern match?
while ($params !~ /;/) # use the 'negative match' binder instead of
# the not (!)
: {
: $line = <$filehandle>
^
^ no semicolon...
: $params = "$params $line";
$params .= " $line";
: }
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 9 Jul 1997 22:01:22 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Wierd Angle Bracket Error
Message-Id: <5q11ni$5ct$1@neocad.com>
Joshua Marotti (jpm@iti-oh.com) wrote:
: while (!($params = /;/))
while ($params !~ /;/)
: {
: $line = <$filehandle>
: $params = "$params $line";
$params .= $line;
: }
Not testing this, I'd guess the while loop is messing you up.
Your statement is checking to see if you managed to successfully
assign /;/ to $params. Not what you want.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 720
*************************************