[7422] in Perl-Users-Digest
Perl-Users Digest, Issue: 1047 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 19 05:17:22 1997
Date: Fri, 19 Sep 97 02:00:37 -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 Fri, 19 Sep 1997 Volume: 8 Number: 1047
Today's topics:
Re: Advanced Perl Programming Tutorial (Tad McClellan)
Capitalizing the first letter via regex <czukowski@qualcomm.com>
Re: Capitalizing the first letter via regex <eike.grote@theo.phy.uni-bayreuth.de>
Help with CGI perl scripts (James H. Woest)
Re: Hint executing passed script fragments? (dave)
Re: How to assign new vals to hash elements? (dave)
Linux Perl Bug ? <bdesta@qualcomm.com>
Re: Nested subs and local vs my (Bart Lateur)
Re: Parsing e-mail folder (newbie) (Jim Dennis)
Re: pattern matching (Martin Str|mberg)
Re: Perl on win32 book gat@gatman.SPAMBUFFER.com
Sequential replace -- big problem? (CherngJyh Lin)
Simple packet loss measurement <teohcb@eeye.com.sg>
Re: simple script (Bart Lateur)
ssh and perl <sjofaasj@geocities.com>
Re: strange behaviour of sort in perl 5.004.03 <rpsavage@ozemail.com.au>
Re: strange behaviour of sort in perl 5.004.03 (Ilya Zakharevich)
Re: Submit Using Image (Lutz Albers)
Uploading files larger than 50k from webpage IMPOSSIBLE <golo1517@mail.student.uu.se>
Where am I missing it gatcat@gatman.SPAMBUFFER.com
Re: while (/\b([A-Z])\l\1(.*?)\b/g) { print "$&\n"; } <Philip.Abercrombie@MCS.VUW.AC.NZ>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Sep 1997 22:57:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Advanced Perl Programming Tutorial
Message-Id: <78tsv5.klb.ln@localhost>
[ emailed, posted ]
John Donnelly (johnd@xor.com) wrote:
: ties from the latest release of Perl (5.003).
s/m/m one of/;
s/se/ses/;
;-)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 15 Sep 1997 12:25:56 -0700
From: Christopher Zukowski <czukowski@qualcomm.com>
Subject: Capitalizing the first letter via regex
Message-Id: <341D8BC4.7009BB51@qualcomm.com>
To all,
I am trying to figure out how to capitalize the first character of
an otherwise all lower case string.
IE: random
want to be
Random
Any suggestions?
Thank
-------------------------------------------------------
Christopher Zukowski
czukowski@qualcomm.com
PGP Fingerprint: 4471 22ED F5F7 FF67 520E OE97 5F84 427B
"Poor soul was to high strung."
--------------------------------------------------------
------------------------------
Date: Fri, 19 Sep 1997 09:15:23 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Capitalizing the first letter via regex
Message-Id: <3422268B.167E@theo.phy.uni-bayreuth.de>
Hi,
Christopher Zukowski wrote:
>
> I am trying to figure out how to capitalize the first character of
> an otherwise all lower case string.
Take a look at the 'perlfunc' manual page and search for 'ucfirst()'.
Bye, Eike
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: 19 Sep 1997 01:45:40 GMT
From: woest@elrond.sp.TRW.COM (James H. Woest)
Subject: Help with CGI perl scripts
Message-Id: <5vslg4$nkt$1@cronkite.sp.trw.com>
CGI-script newbie questions:
I am attempting to send HTML form information from a web page
to a user via a Perl script. I am entering text into a <textarea>
box, and then using sendmail to mail the text to a user, but
I have run into some problems:
1.) When a quotation mark (") is included in the form data,
all text after the quotation mark is omitted from the
email message. I assume this happens because the
print statement that I use to assemble the mail
message sees this quotation mark as the end of
the text and stops there. Is there anyway around
this? Also, are there any other characters that can
cause problems like this?
2.) In the <textarea> tag, I am using the "wrap=physical"
attribute to ensure that a carriage-return/line-feed
sequence is put at the end of every line. However,
the message still arrives in the mail message as a
single line, with no CR/LF's. I know that the "wrap"
tag is a non-standard extension, but is there any way
to make this work, or simulate its effects?
Thanks in advance for any help you can give me.
James Woest
woest@elrond.sp.trw.com
------------------------------
Date: Fri, 19 Sep 1997 02:06:55 GMT
From: over@the.net (dave)
Subject: Re: Hint executing passed script fragments?
Message-Id: <3421cf7a.11948000@news.one.net>
Tom Phoenix <rootbeer@teleport.com> wrote:
>On Wed, 17 Sep 1997, dave wrote:
>
>> How should a running perl script execute perl script fragments that
>> are received from a shell script?
>
>Do you mean that a shell script is running the Perl script, and giving the
>Perl script snippets of Perl to execute? You could do this with eval, if
>you trust the snippets.
I have a Perl script using Tk that is a running screen manager of
sorts.
I want to make it easy to modify lots of existing ksh scripts so that
they request Tk prompts (via the screen manager) rather than do line
input from stdin. This will be necessary if I'm unable to convince
the ksh programmers to convert to Perl/Tk. Unfortunately these folks
aren't solely dedicated to programming and have little time to invest
in a new language.
Each ksh script would be a descendant of the Perl screen manager, but
not necessarily a direct child.
It sounds simple enough for the Perl screen manager to eval a received
snippet and send back a list of return values ... well maybe returning
values won't be so simple. Anyway, the snippet would just call a
subroutine to do a simple prompt, menu or entry form. Tk is invisible
to the caller.
I trust the ksh scripts, since they are also system software, but
would like to have any safeguards that are easy to implement. I heard
about the Safe module, but I'm hoping to get some input before I go
forward any further.
Thanks,
Dave
P.S. Sorry about the email address, but I have found it effective at
reducing spam. I tried another ISP once where I STARTED with
disguised headers and hardly got any unwanted email. Wish I had done
it with my current ISP.
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: Fri, 19 Sep 1997 01:00:29 GMT
From: over@the.net (dave)
Subject: Re: How to assign new vals to hash elements?
Message-Id: <3421cea9.11739559@news.one.net>
Doug Seay <seay@absyss.fr> wrote:
>I can't think of any solution better than your foreach loop. Why do you
>think that there should be something "shorter than the foreach loop"?
It seems to me that Perl has plenty of scalar assignment operators.
And at least on one level, Perl is a language of one liners.
If what you said is true, then I think Perl could use a special hash
assignment operator. Let's pretend it would be the ":-)" operator and
would be used as follows:
%hashA :-) %hashB;
which would simply assign values in hashA with values for matching
keys in hashB, without modifying the structure of hashA, so that any
references to hashA values would still be valid.
It could also be used to modify a hash with args to a subroutine,
like:
sub Login
{
%hash = ( 'user' => 'guest', 'password' => 'guest' );
%hash :-) @_;
...
}
which would ignore passed key/value pairs whose keys weren't already
in the hash. Might help keep unexpected things from happening when
the hash is later processed.
I use hashes and references a lot, sometimes even when they aren't
necessary (the consistent use of key/value pairs appeals to me). So
the :-) operator is on my wish list, :-).
Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: Mon, 15 Sep 1997 09:20:37 -0700
From: Brahma Desta <bdesta@qualcomm.com>
Subject: Linux Perl Bug ?
Message-Id: <341D6041.63E7@qualcomm.com>
The following piece of code, in Linux Perl 5.004, only
works if the first two print statements are either
removed or are of the form print "num1 = ", $num1;
In the current form, the xor produces a 0 whereas the
real answer should be 55217.
I guess it has something to do with the conversion
between strings and numbers ?
$num1 = 11230;
$num2 = 64623;
print "num1 = $num1 \n"
print "num2 = $num2 \n"
print int($num1 ^ $num2);
System Specs: Slackware 3.3 : kernel version 2.0.30 : Pentium 200 MMX.
------------------------------
Date: Fri, 19 Sep 1997 08:36:47 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Nested subs and local vs my
Message-Id: <342a386d.4822964@news.tornado.be>
I know this is a bit off-topic, but your code snippet triggered this
question.
gbacon@adtran.com (Greg Bacon) wrote:
> sub outerfun {
> my $b;
>
> my $inref = sub {
> $b = $i;
> print "...";
> }
>
> $inref->();
> }
Are the next two statements functionally equivalent? If not, what's the
difference?
$inref->();
&$inref();
Bart Lateur
bart.mediamind@tornado.be
------------------------------
Date: 18 Sep 1997 20:18:35 -0700
From: jimd@antares.starshine.org (Jim Dennis)
Subject: Re: Parsing e-mail folder (newbie)
Message-Id: <m3afhaat4k.fsf@antares.starshine.org>
In article <yjz4t7jd5ru.fsf@tobias.corp.adobe.com>
Tobias Hoellrich <thoellri@tobias.corp.adobe.com> writes:
"David W. Wong" <hmw-dave@pplus.best.com> writes:
>> In the next few days I will need to create (or help create) a script
>> that will parse the e-mail folder file on a UNIX (actually, SGI IRIX)
>> system to get the most recent message and output that message to an
>> external text file. The file will be inserted (via server-side include)
>> into an HTML file.
>>
>> To better illustrate the situation, here it is: the crew of a yacht on
>> an ocean voyage will be e-mailing their status, messages, etc. to an
>> e-mail account on our central server. The most recent message will be
>> posted to the HTML page, where visitors of the site can read the
>> message.
>>
>> I'm not looking for a complete solution, but if anyone has/can explain
>> how to create a script that will parse the mail folder file and extract
>> the most recent message, it would be tremendous help.
>>
>> Thanks in advance,
>>
>> Dave
>> dave@hmw.com
> Looks like you should get "procmail" and process the incoming mail on
> your SGI box, filter out the message and simply generate a HTML from
> it. "procmail" is available from:
> ftp://ftp.informatik.rwth-aachen.de/pub/packages/procmail/procmail.tar.gz
> Hope that helps
> Tobias
Certainly you can use procmail and/or MH. You can also
look for MHonArc (MH Online Archiver) and hypermail. These
can automatically parse mail messages into HTML as well.
Some notes:
'procmail' is normally installed as a "delivery agent"
or as a "filter" -- each message is piped
through your procmail scripts as it arrives.
I wrote an article on the subject near the
beginning of this year -- it's available at
the Linux Gazette pages at http://www.ssc.com/lg/
'MH' is the Rand "Mail Handling" suite. It is comprised
of many small shell programs which "incorporate"
(inc), "compose" (comp), "forward" (forw), "reply"
(repl), "organize" (refile), "summarize" (scan),
and otherwise manage (rmm to remove, pick to search
and select, ali to expand lists and aliases, etc)
your mail. The remarkable feature of MH is that
each message is split into a separate file.
Sysadmin's hate this on multi-user systems (chews
up alot of inodes!) but it is really convenient
for a number of reasons. Basically it allows you
use normal shell file management functions and
programs to manage your mail folders. It also
allows you to have "subfolders" (which are simply
subdirectories under you folder directories) and
"shared folders" (which are simply chmod'ed to
allow group access).
I use mh-e and emacs Gnus to read my MH mail.
For your purpose you could use MH's inc command
to split the mail spool into separate files,
and then you can use perl to parse and play with
each file in turn. As another message pointed
out there are easy ways (using the MH pick command,
for example) to pick just the most recent message,
or all of the messages sent after a certain time
(you can use the normal Unix 'find' to deal with
the message file dates, and the MH 'pick' command to
deal with dates from the message headers), and
messages to or from a particular address or
with a given keyword in the subject or body.
Raw MH commands are really for programmers and
scripters. Most people who use MH pick a
front end (such as the emacs mh-e mode, or
one of the X Windows exmh or xmh interfaces).
I haven't used MHOnArc yet -- and I only did a minimal
set-up of hypermail once. So your best bet is to
do a Yahoo! search to find some sites that use these.
All of these tools are freely available -- and I think
they call come as source code. So you should be able
to modify any of them to suit your more specific needs.
(Although I'd probably wrap shell or perl wrappers
around hypermail or MHOnArc -- to fix the results --
rather than trying to change their code directly.
--
Jim Dennis (800) 938-4078 consulting@starshine.org
Proprietor, Starshine Technical Services: http://www.starshine.org
PGP 1024/2ABF03B1 Jim Dennis <jim@starshine.org>
Key fingerprint = 2524E3FEF0922A84 A27BDEDB38EBB95A
------------------------------
Date: 17 Sep 1997 20:37:41 GMT
From: ams@ludd.luth.se (Martin Str|mberg)
Subject: Re: pattern matching
Message-Id: <5vpf2l$cf8$1@news.luth.se>
Joseph June (jjune@midway.uchicago.edu) wrote:
[Klippa, klapp, kluppit perlisms.]
: Obviously I have no problem matching X-AAAAAAAA... but after getting the
: match... i need to move up a few line before start generating the new
: set... or else the old set's beginning will be left and mixed up with the
: new one..
:
: another possiblity is to do a multiple line match... like match
:
: :rule_adtr (
: :src_adtr (
: : Sever_Name
: )
: :dst_adtr (
: : X-AAAAAAAAA
:
:
:
: instead of just X-AAAAAAAAA... which I do not know how to do either...
: if anyone has any idea... it will be most appreciate it...
: Regards,
: Joseph June
:
Yes, I think multiline match is best here, IMHO. Something along these
lines:
if($input =~ m/:rule_adtr\s+\(
\s+:src_adtr\s+\( # Beginning of src_adtr found.
\s+:\s+Sever_Name # Sever_name found.
\s+\) # End of src_adtr.
\s+:dst_adtr\s+\( # Beginning of dst_adtr found.
\s+:\s+X-AAAAAAAAA # Aaaah, this
# we'll exchange
# for GK!
and tail matches as well perhaps # More nice comments
/sx # s for pretending it's a single line while it
# isn't and x for nice layout with comments.
) # End of if($input.
{
# Match found some prints perhance?
}
------------------------------
Date: Fri, 19 Sep 1997 02:23:23 GMT
From: gat@gatman.SPAMBUFFER.com
Subject: Re: Perl on win32 book
Message-Id: <3421e171.14962746@news.gate.net>
I got my Gecko book and I got a free t-shirt. I'm up for a little bit
a learnin.
------------------------------
Date: Fri, 19 Sep 1997 06:45:10 GMT
From: a00lcj00@mail.dt.nchc.gov.tw (CherngJyh Lin)
Subject: Sequential replace -- big problem?
Message-Id: <342315a4.84323994@netnews.nchc.gov.tw>
Hello:
I got a problem in processing a string replace. Could any
body know how to write the "replace" subprogram as below?
Thanks!
========================
$before = "abcdefgabcd";
@a = qw/ab efg cd/;
@b = qw/AB EFG CD/;
$after = &replace($before);
========================
$after must become: "ABcdEFGabCD"
(SEQUENTIAL search @a in $before and replace with @b. NOTE that
first "cd" doesn't be replaced because of sequential search!)
The program must be efficient because I want to deal with a big file.
Thanks in advance.
Lin.
------------------------------
Date: Fri, 19 Sep 1997 13:50:10 +0800
From: Teoh Cy Boon <teohcb@eeye.com.sg>
Subject: Simple packet loss measurement
Message-Id: <34221292.8B5BDD5B@eeye.com.sg>
This is a multi-part message in MIME format.
--------------124A8D5FC4CD3DFD0241C14B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi!
Here's a little program to measure packet loss due to routers
enroute. It runs 'traceroute' to get the route and then 'ping'
to get the packet lossage info.
It's written and tested on Linux 2.0.18 and IRIX 6.3. Comments,
suggestions and bug reports are welcome. Pass it around if you
find it useful.
Regards,
--
Teoh Cy Boon
Electric Eye Pte Ltd Phone: (65) 7700537, (65) 7777755
26 Ayer Rajah Crescent Fax : (65) 7700585
#05-01 Singapore 139944 Email: teohcb@eeye.com.sg
--------------124A8D5FC4CD3DFD0241C14B
Content-Type: application/x-shar; name="packetloss.shar"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="packetloss.shar"
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1997-09-19 13:38 SGT by <teohcb@bluefin.eeye.com.sg>.
# Source directory was `/home/teohcb/tmp'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
# This format requires very little intelligence at unshar time.
# "if test", "echo", "mkdir", and "sed" may be needed.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3417 -rwxr-xr-x packetloss
#
echo=echo
if mkdir _sh08207; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= packetloss ==============
if test -f 'packetloss' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'packetloss' '(file already exists)'
else
$echo 'x -' extracting 'packetloss' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'packetloss' &&
X#!/usr/bin/perl
X# Measure packet loss at each node along the
X# path to a particular host
X#
X# (C) 1997 Teoh Cy Boon. All rights reserved.
X
X# look for a particular executable
X# bombs out if a particular program
X# cannot be found
X# usage: &search_for_exe("prog-1", "prog-2", .. );
X#
Xsub search_for_exe {
X local(@exe_tolookfor_list) = @_;
X local(@built_in_path_list, $cc, @site_path_list, $path_env);
X local(@final_search_list, $path, $fpath, $exe, %result);
X
X # built-in list of likely executable depositories
X @built_in_path_list =
X ( "/usr/bin", "/bin", "/usr/etc", "/usr/sbin", "/sbin",
X "/opt/bin", "/usr/local/bin", "/usr/bin/X11",
X "/usr/X11R6/bin", "/usr/ucb", "/usr/freeware/bin");
X
X # Look at the PATH environment
X @site_path_list = undef;
X $path_env = $ENV{"PATH"};
X if($path_env ne undef) {
X $path_env =~ s/^\:|\:$//g;
X @site_path_list = split(/\:+/, $path_env);
X }
X # do the biz ..
X foreach $exe (@exe_tolookfor_list) {
X #print "\n-- $exe ---\n";
X $result{$exe} = undef;
X # try PATH based list first, then the built-in list
X $cc = 0;
X while(($result{$exe} eq undef) &&
X (@site_path_list[$cc] ne undef)) {
X $fpath = @site_path_list[$cc++]."/".$exe;
X #print "PATH: Trying $fpath ..";
X if(-x $fpath) {
X $result{$exe} = $fpath;
X #print "Got it!";
X }
X #print "\n";
X }
X $cc = 0;
X while(($result{$exe} eq undef) &&
X (@built_in_path_list[$cc] ne undef)) {
X $fpath = @built_in_path_list[$cc++]."/".$exe;
X #print "DEFS: Trying $fpath ..";
X if(-x $fpath) {
X $result{$exe} = $fpath;
X #print "Got it!";
X }
X }
X # if all that fails .. then bomb out
X die("Fatal: Can't find required program \'$exe\'\n")
X unless ($result{$exe} ne undef);
X }
X return %result;
X}
X
X###########################################################################
X# Cool stuff starts here
X
X# look for requisite programs
X%PRG_LIST = &search_for_exe("traceroute", "ping");
X
X$TR = $PRG_LIST{"traceroute"};
X$PG = $PRG_LIST{"ping"};
X
X$packet_c = 10; # Max. # of packets to send via PING
X
X$argc = @ARGV;
Xdie "Usage: packetloss host\n" unless ($argc == 1);
X$target_host = @ARGV[0];
X
X# get packet route info
Xopen(ROUTE, "$TR $target_host |")
X ||die("Unable to execute $TR, $!\n");
X
X$hop_c = 0;
Xwhile($r = <ROUTE>) {
X $r =~ s/^\s+//g;
X @tmp = split(/\s+/,$r);
X $host_name = @tmp[1];
X $host_ip = @tmp[2]; $host_ip =~ s/\(+|\)+//g;
X if($host_name ne "*") {
X $duplicate_route_host = 0;
X foreach $host (@route_hostname_list) {
X if($host eq $host_name) {
X $duplicate_route_host = 1;
X }
X }
X if($duplicate_route_host == 0) {
X # add unique route host
X push(@route_host_list, $host_ip);
X push(@route_hostname_list, $host_name);
X print stderr "[".($hop_c+1)."] ";
X $hop_c ++;
X }
X }
X}
Xclose ROUTE;
Xprint stderr "\n\n[ $hop_c hops to $target_host ]\n\n";
X
X$rh_c = 0;
X$s = sprintf("%-4s %-32s %-18s %-12s", "Hop", "Host",
X "Host IP", "Packet Loss");
Xprint stderr "$s\n";
Xforeach $host (@route_host_list) {
X open(PING, "$PG -q -c $packet_c $host|")
X || die("Unable to execute $PG, $!\n");
X $lc = 0;
X while($p = <PING>) {
X if($p =~ /packet\s+loss/gi) {
X $s = sprintf("%-4d %-32s %-20s %-12s",
X $rh_c+1, @route_hostname_list[$rh_c], $host,
X (split(/\s+/, (split(/\,+/, $p))[2]))[1]);
X print stderr "$s\n";
X }
X }
X close PING;
X $rh_c ++;
X}
Xprint stderr "\n";
X
SHAR_EOF
: || $echo 'restore of' 'packetloss' 'failed'
fi
rm -fr _sh08207
exit 0
--------------124A8D5FC4CD3DFD0241C14B--
------------------------------
Date: Fri, 19 Sep 1997 09:12:21 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: simple script
Message-Id: <342c3fdc.6725071@news.tornado.be>
Jiri medlen <jmedlen@lpd.sj.nec.com> wrote:
>Does anybody know, how make assignmet work??
>$num = system ('grep -c \'GET /HTTP\'
>c:\netscape\server\httpd-80\logs\access');
>
>Platform Windows NT 4.0
>Perl 5
Just a warning. Even between single quotes, you need to double the
backslashes. Maybe that's why grep fails (as I guess it does).
Second, I think you'd have to redirect the output from grep. I'm not
sure on how to do this, as I don't use NT.
HTH,
Bart.
------------------------------
Date: Thu, 18 Sep 1997 14:13:04 +0200
From: "Sjofaasj!" <sjofaasj@geocities.com>
Subject: ssh and perl
Message-Id: <34211AD0.4F6DBC39@geocities.com>
When I execute a command remotely by ssh (secure shell) on the
command-line (eg ssh -l root machineX commandY) no problem, when I try
to do the same in a Perl-script (something like system("ssh", "-l root",
"machineX")), ssh returns "Server refused our key. Permission denied".
What's wrong?
Herman
---
sjofaasj@geocities.com
http://www.geocities.com/SunsetStrip/3193
------------------------------
Date: Fri, 19 Sep 1997 12:55:10 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: strange behaviour of sort in perl 5.004.03
Message-Id: <3421DB7E.649D@ozemail.com.au>
Andreas Schmidt wrote:
>
> I'm porting some perl-modules from perl 5.003 to 5.004.03. Most things
> were easy, but there is a strange behaviour when using perl's sort ^^^^^^^
[snip]
Which OS?
Are you using IRIX? Under IRIX 6.2/Perl 5.003, @ara = sort(@ara); puts the first element of the (sorted?)
input array into all elements of the output array.
------------------------------
Date: 19 Sep 1997 06:03:53 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: strange behaviour of sort in perl 5.004.03
Message-Id: <5vt4k9$gct@agate.berkeley.edu>
In article <3421898E.1364@team-konzept.de>,
Andreas Schmidt <andi@team-konzept.de> wrote:
> I'm porting some perl-modules from perl 5.003 to 5.004.03. Most things
> were easy, but there is a strange behaviour when using perl's sort
> function with an anonymous function as argument:
>
> In perl 5.003 I used quite often code like:
>
> my @lala = sort { return &foo( $a, $b ); } @lolo;
..
> After spending a long time with looking for errors, I realized that
> everything is fine, if I remove the word return in the anonymous
> function, or if i pass the result of &foo( $a, $b ) to a local variable
> before returning it. But just return &foo( $a, $b ) did not work..
Sure it would not, why do you think it would? Would you think this
will print xxx:
sub a { map {print 'x'; return 1} 1..3 }
a
? The sort BLOCK is not a subroutine too.
If it worked earlier, than it might have been a bug in the older version.
Ilya
------------------------------
Date: Thu, 18 Sep 1997 11:11:24 +0200
From: lutz@muc.de (Lutz Albers)
Subject: Re: Submit Using Image
Message-Id: <lutz-ya023480001809971111250001@news>
In article <8cg1r4qh8w.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:
>>>>>> "Mike" == Mike Heins <mheins@prairienet.org> writes:
>
>Mike> @map = `cat whatever.map`;
>
>Oooh. A second "useless use of cat" in a week of clpm!
>
> use IO::File;
> @map = IO::File->new("whatever.map")->getlines;
>
>Thou Shalt Not Needlessly Fork. :-)
Thou Shalt Check The Return Code Of System Calls :-)
Sorry, couldn't resists ...
--
Lutz Albers, lutz@muc.de, pgp key available from <http://www.pgp.net>
Do not take life too seriously, you will never get out of it alive.
------------------------------
Date: Fri, 19 Sep 1997 09:24:43 +0200
From: "Gvran Lvfstrvm" <golo1517@mail.student.uu.se>
Subject: Uploading files larger than 50k from webpage IMPOSSIBLE?
Message-Id: <342228BA.AAA44D64@mail.student.uu.se>
I am using perl 5.004 and have made a script that is supposed to handle
file uploads from webpages.
The script uses cgi-lib.pl 2.14 for stripping the form-data, and I use
the <INPUT TYPE=file> construction in Netscape within the form.
Now, the script works really good if I upload files smaller than about
50k. Above that, the webserver reports 'Premature EOF' and 'Pipe Ended'.
It seems to me like Perl gets choked with data, and cuts the stream
after about 50k.
Is this a built-in feature of perl, or?
Below is a sample of the code, really messy stuff, but tou should be
able to get the idea.
Any suggestions as to how I can solve this would be greatly appreciated.
Thanks,
Gvran Lvfstrvm.
*-----------
require 5.001;
use strict;
require 'cgi-lib.pl';
MAIN:
{
my (%cgi_data,%cgi_cfn, %cgi_ct, %cgi_sfn, $ret,$buf, $file );
$cgi_lib::writefiles = "d:/temp/";
$cgi_lib::maxdata = 500000;
$ret = &ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn);
if (!defined $ret) {
&CgiDie("Error in reading and parsing of CGI input");
}
elsif (!$ret) {
&CgiDie("Missing parameters\n",
"Please complete the form <a href='ul.htm'>ul.htm</a>.\n");
}
elsif (!defined $cgi_data{'upfile'} or !defined $cgi_data{'note'}) {
&CgiDie("Data missing\n",
"Please complete the form <a href='ul.htm'>ul.htm</a>.\n");
}
print &PrintHeader;
print &HtmlTop("File Upload Results");
print <<EOT;
<p>You've uploaded a file. Your notes on the file were:<br>
<blockquote>$cgi_data{'note'}</blockquote><br>
<p>The file has been spooled to disk as: <i>$cgi_data{'upfile'}</i><br>
The file's reported name on the client machine is:
<i>$cgi_data{'filename'}</i><br>
The file's reported Content-type was:
<i>$cgi_ct{'upfile'}</i><br>
<hr>
<pre>
EOT
$file = $cgi_lib::writefiles.$cgi_data{'filename'};
open (UPFILE, $cgi_sfn{'upfile'}) or
&CgiError("Error: Unable to open temporary file $cgi_sfn{'upfile'}:
$!\n");
$buf = "";
open (DOWNFILE, ">$file") or
&CgiError("Error: Unable to create file $file: $!\n");
$buf = "";
binmode (UPFILE);
binmode (DOWNFILE);
while (read (UPFILE, $buf, 16384)) {
print DOWNFILE $buf;
}
close (UPFILE);
close (DOWNFILE);
print "</pre>\n";
print "<h2>Saved ".$file."<h2>";
unlink ($cgi_sfn{'upfile'}) or
&CgiError("Error: Unable to delete temporary file",
"Error: Unable to delete temporary file $cgi_sfn{'upfile'}: $!\n");
print "<hr>Temporary file $cgi_data{'upfile'} has now been removed\n";
print &HtmlBot;
$cgi_lib::writefiles = $cgi_lib::writefiles;
$cgi_lib::maxdata = $cgi_lib::maxdata;
}
------------------------------
Date: Fri, 19 Sep 1997 02:40:41 GMT
From: gatcat@gatman.SPAMBUFFER.com
Subject: Where am I missing it
Message-Id: <3421e5f1.16115395@news.gate.net>
Using perl script -- works fine in Unix.
Have moved same over to NT and renamed script with .plx extension and
removed shbang line.
Original variable for send mail was:
$mailprog = '/usr/lib/sendmail';
ISP tells me that their mail program is COMMENTS.EXE and located in
cgi-bin directory.
My interpretation to correct this was as follows:
$mailprog = '/cgi-bin/COMMENTS.EXE';
Where am I missing it??
Prompt reply a big help - Thanks
John Gattuso
gatman@gate.nospam.net
------------------------------
Date: 19 Sep 1997 14:42:14 +1200
From: Phil Abercrombie <Philip.Abercrombie@MCS.VUW.AC.NZ>
Subject: Re: while (/\b([A-Z])\l\1(.*?)\b/g) { print "$&\n"; }
Message-Id: <6wwwkem3cp.fsf@bats.mcs.vuw.ac.nz>
kendall shaw <kshaw@plight.lbin.com> writes:
> Hi,
>
> I want to find all words like Llewelyn. My snippet doesn't work
> with my perl 5.0004. Any ideas?
>
> Kendall
What do you mean "like Llewelyn"?
If you mean that they start with a repeated letter, first uppercase
then lowercase, (which is what I'm guessing from your regex),
then you could either construct a very big r.e. to do it or you could
write it like this:
while(/\b(\w)(\1).*?\b/gi) {
next unless $1 eq uc $2 && $2 eq lc $1;
print $&;
}
This finds Lloyd and Aaron, but not aardvark or eerie.
-phil
------------------------------
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 1047
**************************************