[7187] in Perl-Users-Digest
Perl-Users Digest, Issue: 812 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 4 15:17:22 1997
Date: Mon, 4 Aug 97 12:00:22 -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 Mon, 4 Aug 1997 Volume: 8 Number: 812
Today's topics:
$$a implemented in 4.036? <pittelli@ehsct7.envmed.rochester.edu>
Re: $$a implemented in 4.036? <merlyn@stonehenge.com>
Re: [Q] Converter between ELM filter-rules file to proc (Sven Guckes)
Re: About DB_File! (robert)
Re: array growth question <rootbeer@teleport.com>
Buy any Perl book in print (Ira Krakow)
Re: Carriage Return Problem <rootbeer@teleport.com>
cpu strain <tetnys@ibm.net>
Re: execution with parametres (Tina Marie Holmboe)
Got the answer <flash16@lightspeed.net>
How to manage a million accts..help (Seth Perlman)
NT and PERLIS (D. Austin)
NT Server/perl ISAPI <kerry@lumber.com>
Re: perl install (Nathan V. Patwardhan)
Re: Perl Resource Kit: What the hell's O'Reilly talking (Marjorie Roswell)
Re: Printing to absolute screen position <rootbeer@teleport.com>
Re: Printing to absolute screen position <jbokma@caiw.nl>
problem - 'if' condition is always true <galactus@drizzle.com>
Re: problem - 'if' condition is always true <rootbeer@teleport.com>
Re: Process number of executable run with system(); xewj@odin.sunquest.com
REGEX <adrianh@pobox.co.uk>
Re: s/^\s+|\s+$//g; not working correctly on Win32? <rootbeer@teleport.com>
Re: sprintf padding question <rootbeer@teleport.com>
Re: The Most Dangerous Script on the NET (Matthew Burnham)
Re: Unable to create sub carelf@demon.nl
Re: What happens when.... (Alan Williams)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 03 Aug 1997 22:11:34 -0600
From: Randal Pittelli <pittelli@ehsct7.envmed.rochester.edu>
Subject: $$a implemented in 4.036?
Message-Id: <870664067.6439@dejanews.com>
I develop on 5.003, but need to have backwards compatibility to 4.036...
Is $$a implemented on 4.036, particularly on Unix variants?
e.g.,
$a = "b";
$b = "hello";
print $$a;
=> hello
Thanks,
Randy
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 03 Aug 1997 21:42:34 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Randal Pittelli <pittelli@ehsct7.envmed.rochester.edu>
Subject: Re: $$a implemented in 4.036?
Message-Id: <8coh7ev9s4.fsf@gadget.cscaper.com>
>>>>> "notMerlyn" == Randal Pittelli <pittelli@ehsct7.envmed.rochester.edu> writes:
notMerlyn> I develop on 5.003, but need to have backwards
notMerlyn> compatibility to 4.036...
Why? 4.036 is dead. And if that isn't enough, there are serious
CERT-ifiable security holes on *every* version of Perl prior to 5.004.
If that isn't enough to get the admin to update, I'd move elsewhere,
because YOUR DATA ISN'T SAFE.
notMerlyn> Is $$a implemented on 4.036, particularly on Unix variants?
Nope. Just stop using Perl versions that weren't written in the last
five years... :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 393 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 4 Aug 1997 09:37:24 GMT
From: guckes@math.fu-berlin.de (Sven Guckes)
Subject: Re: [Q] Converter between ELM filter-rules file to procmailrc file?
Message-Id: <slrn5ub8mk.8hp.guckes@banach.math.fu-berlin.de>
> Ricardo Marek <ricky@ornet.co.il> wrote:
> > Does such animal exist? (to convert the ELM filter-rules file
> > into a procmailrc file
rdadams@access5.digex.net (Dick Adams):
> I was really hoping to see an answer to this question posted!!
man procmail
man procmailex
HTH.
Sven
------------------------------
Date: 4 Aug 1997 11:14:18 +0200
From: robert@ICK.il.fontys.nl (robert)
Subject: Re: About DB_File!
Message-Id: <5s46ha$cb@bsd1.hqehv-internal.ilse.net>
e74632@majakka.uwasa.fi (Ari Pekka Niinimdki):
>Can I store "hash of hashes" into the DB-database?
Try installing the MLDBM module, which can do just that:
ftp://ftp.perl.com/CPAN/modules/by-module/MLDBM/
robert
------------------------------
Date: Sun, 3 Aug 1997 08:32:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tim Gray <tim@hcirisc.cs.binghamton.edu>
Subject: Re: array growth question
Message-Id: <Pine.GSO.3.96.970803083049.7094G-100000@kelly.teleport.com>
On 2 Aug 1997, Tim Gray wrote:
> It would seem to me that anything that is 1)this easy for a new
> programmer to have a problem with and is 2)something the developers
> are discussing might deserve a place in the FAQ.
Sounds good to me. When you have something written up, could you send it
to the FAQ suggestions address, found near the beginning of the FAQ? :-)
Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 Aug 1997 12:22:16 GMT
From: ikrakow@shore.net (Ira Krakow)
Subject: Buy any Perl book in print
Message-Id: <5s4hho$cup@fridge-nf0.shore.net>
You can buy any Perl book in print at:
http://www.shore.net/~ikrakow/perlbooks.html
------------------------------
Date: Sun, 3 Aug 1997 08:26:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jebeze Alexander <bez@interlook.com>
Subject: Re: Carriage Return Problem
Message-Id: <Pine.GSO.3.96.970803081508.7094E-100000@kelly.teleport.com>
On Sat, 2 Aug 1997, Jebeze Alexander wrote:
> The users who have posted have hit the carriage return extensively in
> their postings. I did not anticipate this yet never expected it to be a
> problem.
That sounds redundant. :-)
> each additional paragraph is bold faced and seems as
> though it were a separate entry (separated by three blank entries).
It sounds as if you could simply strip out the excess carriage returns
with a tr/// (or something similar). Couldn't you?
> 1) I use cgi-lib.pl to parse the form
It's too bad that you don't use CGI.pm. You may want to convert your
script, since then you can easily debug it with the perl debugger.
> 2)Here is the code that explicitly saves the info.
>
> open (QUEST1, ">>$in{'day'}1.txt");
You should really check that that open() was successful. And if (as I
suspect) $in{day} comes from the remote user, you should _really_ (REALLY)
make sure that it's in the format you expect. (Funny data in there could
be a security hole, perhaps, and an annoyance at a minimum.) Something
like this, perhaps.
die "Bad 'day' format ('$in{day}')"
unless $in{day} =~ /^\w{1,10}$/;
$file = "$in{'day'}1.txt";
open QUEST1, ">> $file"
or die "Can't append to '$file': $!";
> print QUEST1 "$in{'name'}::$in{'1'}\n";
> close (QUEST1);
And if you suspect that there are extra newlines in those entries, you'd
want to strip those out before printing, I suspect.
> 3)Here is the code that reads the info
>
> while (<FILE>) {
> ($filename,$filetext) = split (/::/,$_);
> print "<B>$filename</B><P>\n";
> print "$filetext<P><HR><P>\n";
> }
Yep, that's assuming that the filename and filetext have no embedded
newlines. (Or double colons! :-)
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 04 Aug 1997 19:32:58 -0700
From: "Ekim E. YARDIMLI" <tetnys@ibm.net>
Subject: cpu strain
Message-Id: <33E690DA.514A@ibm.net>
hello all,
i'm planing to build a 20000 entries two dimensional array file, and
would like to do a search though this file, though i don't have a clue
about how much cpu power it will take to do this search.
I'm planing to use a remote host, and wonder if this might cause any
harm to the rest of the os?
thanks in advance
____________________________________________________________________
Ekim E. YARDIMI - tetnys@ibm.net
------------------------------
Date: 4 Aug 1997 12:42:23 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: execution with parametres
Message-Id: <5s4inf$5f0$2@news1.sol.no>
In article <5s4e7n$shn@rc1.vub.ac.be>,
Vincent Hebbelynck <vhebbeli@vub.ac.be> writes:
> I ld like to execute my script passing some parametres.
> ex scr.pl a b c
> with the parametres a b c
>
> Is it possible? i guess it is.
> how can i do it?
It isn't very hard, actually... parameters passed to a Perl-script are
stored in the array @ARGV - from which you can pick them out when you need
them. More about this can be found in man perlvar...
--
Tina Marie Holmboe tina@mail.scandinaviaonline.se
The opinions expressed above are mine, and should in no way or under any
circumstances be associated with Scandinavia Online AB unless this disclaimer
is explicitly revoked.
------------------------------
Date: Sun, 03 Aug 1997 09:31:32 -0700
From: Dan Gordon <flash16@lightspeed.net>
Subject: Got the answer
Message-Id: <33E4B263.99499254@lightspeed.net>
Somebody emailed me with the answer last night so I thought that I would
post the answer in case anybody else has this problem
You need to use the codebase parameter in the applet header, here's what
I used to make it work
print "<applet codebase=http://www.whatever.com/java/ code=animBtn.class
width=32 height=32>\n";
Hope this helps you out :)
Dan
------------------------------
Date: 4 Aug 1997 01:11:21 -0400
From: seth@fellspt.charm.net (Seth Perlman)
Subject: How to manage a million accts..help
Message-Id: <5s3o9p$au@fellspt.charm.net>
How do AOL and other huge sites manage a million+ accounts?!! Hello???
NIS and NIS+ appears to have scalability problems when faced with very
large numbers of unix accounts(ie: /etc/passwd entries).
A possible solution appears to be to manage etcpasswd and etcgroups
in a relational database, get the source code for ypserv and substitute all
dbm/ndbm lookups with my own relational database lookups.
ypserv only needs to pass a string(ex: etcpasswd row, etcgroup row...)
back to any NIS clients making their requests via ypbind. If I did that, I
should be rid of this screwy ODBM/NDBM bug.
Hasn't anyone tried this before? Can anyone else share their experiences in
this regard and hopefully their solutions, if they have found one?
...Seth
In article <33e0cb9d.2428378918@news>,
Andre Oliveira Dias <aod@unisys.com.br> wrote:
>seth@fellspt.charm.net (Seth Perlman) wrote:
>
>>Using NDBM_File I get the following error msg after it loaded 69595 lines:
>>
>>ndbm store returned -1, errno 2, key "506217" at uidnew.pl line 34,
>><PASSWD> chunk 69596.
>>
>>-rwx------ 1 seth prog 2025 Jul 21 02:39 uidnew.pl
>>-rw-r--r-- 1 seth prog 669040640 Jul 21 02:40 byuidndbm.pag
>>-rw-r--r-- 1 seth prog 81920 Jul 21 02:40 byuidndbm.dir
>>
>>Any insights into this? Is it possible to load a couple million rows
>>into dbm or ndbm maps...is there any way to get these modules to accept
>>this or do odbm and ndbm have builtin scalability limits?
>>
>
[See Andre's remarks in his posting under the subject:
"Re: Use ODBM_File/NDBM_File...help"
--
Seth Perlman Unix/Sybase Consultaant
6000 Rusk Avenue
Baltimore, Md. 21209
(410) 358-4355 seth@charm.net
------------------------------
Date: 3 Aug 97 17:20:58 GMT
From: ollie@cintranet.co.uk (D. Austin)
Subject: NT and PERLIS
Message-Id: <33e4bdfa.0@ispc-news.cableinet.net>
I have installed perl32win and perlis and have set up the registry to point to
perlis.dll.
when i call a script from a browser on another machine on my network the
calling page loads fine but when i submit i get "http/1.0 500 server error (
dll initialization failed" in my browser.
When i look in the application log it says the event detail is "PerlIS was
unable to load Perl300.dll". This seems strange as they are both in the
perl\bin directory. when i open a dos window perl\bin is in the path too.
does anyone have any ideas as this is maddening.
thanks
------------------------------
Date: Mon, 04 Aug 1997 09:13:58 -0700
From: Kerry Cakebread <kerry@lumber.com>
Subject: NT Server/perl ISAPI
Message-Id: <33E5FFBD.B592A131@lumber.com>
Hi,
This is probably more of an NT IIS question, than a perl one, but:
I'm trying to get NT Server (Internet Information Server from MS) to
use perl scripts as CGIs. I have the .pl extension associated with the
perl interpreter, and can run .pl files from the command line...
Further, I have the directory (c:\inetpub\scripts\programName\) marked
as "allow execution of files" in the Inet Info Svr Properties dialog.
Coming at it from Internet explorer, it works fine. Coming at it from
Netscape, I get a message like it wants to download the file.pl It
prompts me to save it on my hard drive. My netscape is configured as
default...is there a change I should make to Netscape's mime-types? Or
is this a server-side issue?
Thanks,
Kerry Cakebread
AIFP
kerry@lumber.com
------------------------------
Date: 4 Aug 1997 01:13:53 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: perl install
Message-Id: <5s3ach$go3@fridge-nf0.shore.net>
Suzan (yquem@hotmail.com) wrote:
: I want to install perl on my system (win95). I downloaded the latest
: release (perl5.004_01 from perl.com) and extracted the tar file.
: ok for that.
Did you grab the readme that resides in the same directory as the Perl
distribution? If not, please do - it contains a bunch of good
information about installing the distribution on your system.
Good luck!
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Mon, 04 Aug 1997 15:24:57 GMT
From: roswell@umbc.edu (Marjorie Roswell)
Subject: Re: Perl Resource Kit: What the hell's O'Reilly talking about??
Message-Id: <33e5f41c.6719754@news>
Too bad they want to charge $150.
On Sun, 03 Aug 1997 13:55:17 -0700, Michael Schilli
<mschilli@mission.base.com> wrote:
>Hi folks,
>
>have you seen the newest announcement from O'Reilly? According to
>
> http://www.oreilly.com/catalog/prkunix/desc.html
>
>a "Perl Resource Kit" will be available in Fall 97. What? Here's the
>description:
>
> Software tools on the Kit's CD include:
>
> * A Java-enhanced Perl compiler, written by Larry Wall, creator
> of Perl
> ...
>
>Is this a joke or what?
>
>-- Michael
>
>----------------------------------------------------------
> Michael Schilli http://mission.base.com/mschilli
>----------------------------------------------------------
------------------------------
Date: Sun, 3 Aug 1997 08:37:38 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Printing to absolute screen position
Message-Id: <Pine.GSO.3.96.970803083319.7094H-100000@kelly.teleport.com>
On Sat, 2 Aug 1997, Adam Naylor wrote:
> I need to print to an absolute screen position from perl, so that I can
> update that same line with new information.
I think you want one of the curses-type modules from CPAN. Hope this
helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 Aug 1997 08:36:04 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: Printing to absolute screen position
Message-Id: <01bca0b1$8af68ac0$c50ab2c2@tschai>
Adam Naylor <NOSPAMadam@funnel.demon.co.uk> wrote in article
<33E398B4.2E17E7F6@funnel.demon.co.uk>...
> Hi gurus,
>
> I need to print to an absolute screen position from perl, so that I
can
> update that same line with new information.
>
> Example:
>
> 12 of 100
> 13 of 100
> 14 of 100
>
> .......but preferably overwriting the earlier print without calling
> 'clear'.
>
> I realise this is probably dead simple but I can't find it anywhere
in
> the man pages!
On most systems you can print backspaces (8) or delete characters
(127)
assuming your line is in $line:
print $line; # print the line
print char(8) x length($line); # move to the start of the current
line
Don't print a \n after $line 8-).
John
--
----------------------------------------------------------------------
Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)
http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]
email: jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: 4 Aug 1997 09:49:28 GMT
From: Adam Quigley <galactus@drizzle.com>
Subject: problem - 'if' condition is always true
Message-Id: <5s48j8$aac$1@brockman.serv.net>
i should qualify this a little. this script works exactly how it should
(or rather, how I think it should) on a DEC OSF machine. i move this
over to a Linux box (kernel 2.0.19 I'm pretty sure) and this particular
statement no longer works right. i actually figured out a few debugging
commands and nailed it down to this line.
if ((-d $to_be_sent) || ($to_be_sent =~ /.html/)) { &get_file; }
nothing changed (in the script) between the machines and it still works on
the dec. the entire script is below if you want to check it out.
&get_file is the function this line is sitting in. the reason for this
line is that i don't want to mail a directory (i have no idea what that
would even try to do!) or an html file. so if the filename ends up being
a directory or an html file then it's suppose to call the function and try
again. only this turns out true every time and becomes an infinite loop.
what bothers me is that it worked on one machine so i can't begin to try
and figure out what's wrong.
is there another way to do this?
thanks,
Adam
galactus@drizzle.com
-----script in entirety below------
#!/usr/local/bin/perl -- -*-Perl-*-
$humor_path = "/home/galactus/public_html/humor";
$list_path = "/home/galactus/humor_list/";
$list_of_files = "humor_to_go";
$done_list = "sent_humor";
$temp = "blah.tmp";
$addresses = "members";
open(LIST, "$list_path$list_of_files");
open(DONE, ">>$list_path$done_list");
open(NEWLIST, ">$list_path$temp");
@files = <LIST>;
&get_file;
foreach $f (@files) { print NEWLIST "$f"; }
close LIST; close DONE; close NEWLIST;
unlink ("$list_path$list_of_files");
rename ("$list_path$temp", "$list_path$list_of_files");
open(MEMBERS, "$list_path$addresses");
#while (<MEMBERS>) {
# chop;
# exec 'mail','-s',"\"$subject\"",$_,'<',$to_be_sent;
# system("mail -s \"$subject\" $_ < $to_be_sent");
#}
@to = <MEMBERS>;
chomp @to;
$to = join (", ", @to);
open (MAIL, "| /usr/lib/sendmail -oi -oem -t") or die "cannot fork: $!";
open (MESSAGE, $to_be_sent) or die "cannot open message $to_be_sent: $!";
print MAIL <<EOH;
To: "Adam Quigley" <galactus\@drizzle.com>
From: "Humor List" <galactus\@drizzle.com>
Bcc: $to
Subject: [HUMOR] $subject
EOH
print MAIL <MESSAGE>;
close MESSAGE;
close MAIL;
if ($? != 0) { die "sendmail failed with status $?" }
sub get_file {
srand;
$to_be_sent = splice (@files, rand @files, 1);
print DONE "$to_be_sent";
chop $to_be_sent;
$to_be_sent =~ s/^\.//;
$to_be_sent = $humor_path.$to_be_sent;
@subject_almost = split(/\//,$to_be_sent);
$subject = pop @subject_almost;
END
# if (-d $to_be_sent || $to_be_sent =~ /.html/) { &get_file; }
if ((-d $to_be_sent) || ($to_be_sent =~ /.html/)) { &get_file; }
}
------------------------------
Date: Mon, 4 Aug 1997 09:21:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Adam Quigley <galactus@drizzle.com>
Subject: Re: problem - 'if' condition is always true
Message-Id: <Pine.GSO.3.96.970804090805.27878H-100000@kelly.teleport.com>
On 4 Aug 1997, Adam Quigley wrote:
> Subject: problem - 'if' condition is always true
>
> i should qualify this a little. this script works exactly how it should
> (or rather, how I think it should) on a DEC OSF machine. i move this
> over to a Linux box (kernel 2.0.19 I'm pretty sure) and this particular
> statement no longer works right. i actually figured out a few debugging
> commands and nailed it down to this line.
>
> if ((-d $to_be_sent) || ($to_be_sent =~ /.html/)) { &get_file; }
Maybe perl thinks it's true because it is true. :-)
This may not make a difference, but you almost certainly want to backwhack
the dot in that regular expression. And maybe you want to use $ as well?
But try putting something like this in, in place of that line.
if (-d $to_be_sent) {
warn "# Yep, it's a dir";
} elsif ( $to_be_sent =~ /\.html$/ ) {
warn "# Yep, it matches";
} else {
warn "# Nope, it shouldn't call get_file";
}
if ((-d $to_be_sent) || ($to_be_sent =~ /.html/)) {
warn "# Yes, I'm calling &get_file";
&get_file;
} else
warn "# No, I'm not calling &get_file";
}
Of course, you'll want to run this in a way in which warnings won't be a
problem. If you're not sure to do this, write back. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 Aug 1997 17:45:07 GMT
From: xewj@odin.sunquest.com
Subject: Re: Process number of executable run with system();
Message-Id: <5s54f3$aoe$1@iggy.sunquest.com>
In article <33E5DFA5.41C6@lmtas.lmco.com>,
Brett Denner <Brett.W.Denner@lmtas.lmco.com> wrote:
>Tom Phoenix wrote:
>> > I need to run an executable with the system() command and save its
>> > process number to a file.
>> By the time that Perl is executing your code, the process started by
>> system is dead and gone. Maybe you want to fork a child process and
>> keep its process id?
>When I run my perl script that starts a (long-running) program with
>system(), I can type "ps -u denner" (denner is my userid) and get a
>listing of all processes I own that are currently running. Each process
>has an associated PID, which I can use to delete the process with a
>"kill PID" command (I know you know this). I was hoping there was a way
>to obtain the PID that is displayed by the ps command so I can delete
>that process later.
Then don't use system();
try this:
$pid=`prog & echo "\$!"`;
also, this: open(PROG,"|prog") or this: open(PROG,"prog|")
returns the pid of the spawned program.
------------------------------
Date: Sun, 03 Aug 1997 11:16:39 -0400
From: Adrian Hawryluk <adrianh@pobox.co.uk>
Subject: REGEX
Message-Id: <33E4A0D6.2A486796@pobox.co.uk>
Hi, without me having to parse the man page perlre and perlop and then
doing a trial and error testing to setup the neural network in my head,
is there an explicit BNF and precedence order listing somewhere?
Thanx in adv.
Adrian
------------------------------
Date: Sun, 3 Aug 1997 08:46:48 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: s/^\s+|\s+$//g; not working correctly on Win32?
Message-Id: <Pine.GSO.3.96.970803083951.7094J-100000@kelly.teleport.com>
On Fri, 1 Aug 1997, Tad McClellan wrote:
> Subject: Re: s/^\s+|\s+$//g; not working correctly on Win32?
> It seems to be bigger than just the Windoze port...
Agreed. The Perl developers are discussing it now, and they've even come
up with an even smaller test case which exhibits the bug.
perl -we 'print "Bad\n" if "a\nb" =~ m/^b|c/'
(For the benefit of the folks playing along at home, the ^ anchor should
match only at the beginning of the string, and never at an internal
newline.) Since this behavior has been around since the bad old days of
Perl4, it may mean that when this is fixed, some existing scripts will
change behavior in ways both subtle and mysterious.... :-P
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 3 Aug 1997 08:29:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tim Gray <tim@hcirisc.cs.binghamton.edu>
Subject: Re: sprintf padding question
Message-Id: <Pine.GSO.3.96.970803082718.7094F-100000@kelly.teleport.com>
On 2 Aug 1997, Tim Gray wrote:
> Subject: Re: sprintf padding question
> Unfortunately the perlfunc man page does not describe it in detail, at
> least not in the man pages that come with 5.001. All it says is,
> "formatted by the usual printf conventions of the C language"
>
> Has this changed with the latest version of the manpages?
Yes; now perl implements (s)printf internally, rather than calling your
system's version. Thus, the docs were put into perlfunc(1) directly,
rather than referring you to your system's manpages. This was done for the
5.004 release, which is much more stable than previous ones. I encourage
everyone to install it. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 03 Aug 1997 14:30:30 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: The Most Dangerous Script on the NET
Message-Id: <33e46285.647436@news.enterprise.net>
silvern@vetrol.com wrote:
>Please let me know where to find
>"The most dangerous script on the net"
Why?
--
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.mindweb.co.uk/
------------------------------
Date: Mon, 4 Aug 97 10:15:31 +0100
From: carelf@demon.nl
Subject: Re: Unable to create sub
Message-Id: <9708041015.aa07473@kantoor.demon.nl>
#
# Unfortunately, I am getting a similar error message
# Unable to create sub named "" at , line 1073.
# Line 1073 is the line following the open statement in sub blabla0.
#
# This is the code:
#
sub blabla0
{
open(IDXF,"/usr/local/bin/grep.gnu \'$_[0]\:\' $filename |")
|| die "Could not do grep: $!";
while($testvar=<IDXF>)
{
if($testvar=~/^$_[0]\:(.*)/)
{
close(IDXF);
return($1);
}
close(IDXF);
return(0);
}
}
#
# The error message disappears when I use this code:
#
sub blabla1
{
open(IDXF,"$filename") || die "Could not open : $!";
while($testvar=<IDXF>)
{
if($testvar=~/^$_[0]\:(.*)/)
{
close(IDXF);
return($1);
}
}
close(IDXF);
return(0);
}
#
# Of course the while loop is not necessary in sub blabla0,
# but I wanted to make the contrast extra clear.
#
# I tried all sorts of things, like escaping chars with a backslash,
# but nothing helped so far.
#
# If it would work, sub blabla0 should be far faster than sub blabla1
# when $filename would be a very large file, should not it?
#
# Maybe someone can tell me off hand if I am doing something
# terribly wrong? :)
#
------------------------------
Date: 3 Aug 1997 17:15:10 +0100
From: alan@bearsden.demon.co.uk (Alan Williams)
Subject: Re: What happens when....
Message-Id: <5s2aqe$joo@bearsden.demon.co.uk>
This problem is pretty operating system specific and I only really
know about Un*x.
> What happens when two or more people try to write to a file that is
> already open (ie, another person is already writing to it?).
In general under Un*x if you are allowed to write to a file
at all, you can write to it whatever anyone else is doing.
> Is there a way to stop this from happening?
There are two possible cases:
a) Anyone who wants to write to the file will be using your
scripts, and you can make sure that they cooperate using flock.
b) Some processes may be uncooperative so you can use a trick
such as:
+++++
$filename = "whatever";
$newfilename = $filename . "-" . $$ # or whatever
until( rename $filename $newfilename ){
sleep 1;
}
# Open $newfilename, process the file, and write it back.
rename $newfilename $filename;
-----
The rename operation is atomic, so if two processes try to rename
a file only one can succeed. If the failed process is using code
like this, it will loop round until the process that succeeded
has finished and restores the original filename.
This setup will fail if the file is being manipulated by
processes that are really determined to be uncooperative. If
this is unlikely you can take the risk. If the contents of the
file are vital and you have to ensure consistency then your only
recourse is to create a user to own the files, make any programs
that write the file set user ID to that user, and make sure that
they use flock or some such device to enforce mutual exclusion.
Alan
--
--
Alan Williams +44 (0)1603 460800
15 Albury Walk
NORWICH NR4 6JE alan@bearsden.demon.co.uk
England
------------------------------
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 812
*************************************