[9500] in Perl-Users-Digest
Perl-Users Digest, Issue: 3095 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 8 12:07:27 1998
Date: Wed, 8 Jul 98 09:01:35 -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 Wed, 8 Jul 1998 Volume: 8 Number: 3095
Today's topics:
Re: Placeholders in Perl? <jdporter@min.net>
Porting JPL to HP-UX Problems <phenning@phoenix-int.com>
Re: Proper locking of DBM files? <sbekman@iil.intel.com>
Re: Protecting a HTML <chinhw@postone.com>
Re: question about inline editing <tchrist@mox.perl.com>
Re: question about inline editing (Allan Hawdon)
Save attachment as a seperate file biaolu@my-dejanews.com
Searching a file <ozslot@alphalink.com.au>
Re: Strange file behavior... <jdf@pobox.com>
Re: Strange file behavior... <prsnyder@bewley.net>
Re: Strange file behavior... <prsnyder@bewley.net>
Sybperl script fails to exit after last line tonyprideaux@my-dejanews.com
Re: tough regexp - help needed otis@my-dejanews.com
Re: tough regexp - help needed <jdf@pobox.com>
Re: tough regexp - help needed (brian d foy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 08 Jul 1998 15:35:47 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Placeholders in Perl?
Message-Id: <35A393A0.24E7@min.net>
Brian Coffey wrote:
>
> should also match the reg. expression. Is there such a thing as a
> template or placeholder in Perl? Something like this?
>
> nmos_ M2( .SUBSTRATE(X1), .G(X2), .D(X3), .S(X1));
> pmosob M1( .SUBSTRATE(X1), .D(X3), .S(X4), .BG(X4), .G(X2));
Regular expressions are what you want.
Here's a simple solution, which may not take into account
some of the forms of input you'll actually see.
(Note: the two regexes should be on one line, even if they
get wrapped by your newsreader.)
for (<DATA>) {
chomp;
my %rec;
undef %rec;
if (
/nmos_ M2\( \.SUBSTRATE\((\w+)\), \.G\((\w+)\), \.D\((\w+)\),
\.S\((\w+)\)\);/
) {
@rec{qw( SUBSTRATE G D S )} = ($1,$2,$3,$4);
}
elsif (
/pmosob M1\( \.SUBSTRATE\((\w+)\), \.D\((\w+)\), \.S\((\w+)\),
\.BG\((\w+)\), \.G\((\w+)\)\);/
) {
@rec{qw( SUBSTRATE D S BG G )} = ($1,$2,$3,$4,$5);
}
if ( defined %rec ) {
print join(', ', map { "$_=$rec{$_}" } sort keys %rec ),"\n";
}
else {
print "Invalid line: '$_'\n";
}
}
__DATA__
nmos_ M2( .SUBSTRATE(VSS), .G(I_DIFF), .D(ZN), .S(VSS));
pmosob M1( .SUBSTRATE(VSS), .D(ZN), .S(VDD), .BG(VDD), .G(I_DIFF));
__END__
--
John Porter
------------------------------
Date: Wed, 08 Jul 1998 10:04:58 -0400
From: "P.J. Henningson" <phenning@phoenix-int.com>
Subject: Porting JPL to HP-UX Problems
Message-Id: <35A37C8A.E87D8D7F@phoenix-int.com>
Has anyone had any problems (or even success) porting JPL
(from the Perl Resource Kit) to HP-UX 10.20
------------------------------
Date: Wed, 08 Jul 1998 17:06:27 +0300
From: Bekman Stanislav <sbekman@iil.intel.com>
To: "=?iso-8859-1?Q?J=F8rn=2DMorten?= Innselset" <vibes@hipdrome.org>
Subject: Re: Proper locking of DBM files?
Message-Id: <35A37CE3.3359@iil.intel.com>
J=F8rn-Morten Innselset wrote:
> =
> I'm writing an end user web frontend to a hash file used by Apache's
> rewrite module, and as usual I cut some corners by cutting and pasting
> code sniplets. I think my application is ready for it's first release -=
> my only concern is simultanous access to the hash file through DB_File.=
> =
> The question is - is the following enough to ensure that two users
> updating the file within the same split microsecond won't wreck my db?
> =
> tie %p, DB_File, $passwd_db, O_RDWR|O_EXLOCK, undef, $DB_HASH
It isn't. See the DB_File section in Camel . Should be like:
use Fcntl;
$db_obj =3D tie %wdb, 'MLDBM', $full_mldb_name, O_CREAT|O_RDWR,
$mldb_mode or die $!;
$fd =3D $db_obj->fd;
open DB_FH, "+<&=3D$fd" or die "dup $!";
=
# Get the exclusive write lock
unless (flock (DB_FH, LOCK_EX | LOCK_NB)) {
print "$$: CONTENTION; must have exclusive lock! Waiting for write
lock ($!) ...." if $debug;
unless (flock (DB_FH, LOCK_EX)) { die "flock: $!" }
}
=
# use unless (flock ($fh, LOCK_SH | LOCK_NB)) for read lock
# do the changes
# Release the dbm and lockfile =
$db_obj->sync(); # to flush =
undef $db_obj;
untie %wdb;
close DB_FH; =
But read the chapter anyway...
______________________________________________________________________
Stas Bekman mailto:sbekman@iil.intel.com http://www.eprotect.com/stas =
Visit: http://www.eprotect.com/stas/TULARC (Perl,CGI,Linux,Web,Java,PC)
Linux receives a 'Product of the Year Award' for Best Technical Support
http://www.infoworld.com/cgi-bin/displayTC.pl?97poy.supp.htm
------------------------------
Date: Wed, 8 Jul 1998 23:32:59 -0700
From: "Chin Heng Wee" <chinhw@postone.com>
Subject: Re: Protecting a HTML
Message-Id: <6o03h9$9b2$1@newton2.pacific.net.sg>
brian d foy wrote in message ...
>bad. bad. bad. exercise as to why left to the reader.
Why do you mean by this?
>see the CGI Meta FAQ and the perlsec man page. if you can't answer
>your own question after checking these resources you shouldn't be
>playing at this level yet. that may sound harsh, but we're talking
>about the security of your server.
Thanks, will look into it. But I like to point out that sometime it is not
by choice that I choose to play at this level. Like it or not, what the
customer wants, I have to give it. With a tight deadline and low budget, I
cannot afford the time or man power to understand the problem thoroughly.
Just enough to help me to complete my task. Hope that you understand.
>>I don't know much about perl security, or what it might be.
>
>so why attempt to answer security questions? these are serious
>matters best left to people not guessing.
>
Thanks Jim.
Regards,
Heng Wee
------------------------------
Date: 8 Jul 1998 14:01:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: question about inline editing
Message-Id: <6nvu4e$n4o$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Alexander Farber <eedalf@eed.ericsson.se> writes:
:is it possible to find out when you finished processing
:one file and starting another when using <> ?
Sure. Form perlfunc under eof:
# reset line numbering on each input file
while (<>) {
print "$.\t$_";
close(ARGV) if eof; # Not eof().
}
The key is that eof() and eof are different. eof() is
just this one. eof is all of them.
Here's an excerpt from the 5.005 releases perlsyn manpage:
# inspired by :1,$g/fred/s//WILMA/
while (<>) {
?(fred)? && s//WILMA $1 WILMA/;
?(barney)? && s//BETTY $1 BETTY/;
?(homer)? && s//MARGE $1 MARGE/;
} continue {
print "$ARGV $.: $_";
close ARGV if eof(); # reset $.
reset if eof(); # reset ?pat?
}
--tom
--
pos += screamnext[pos] /* does this goof up anywhere? */
--Larry Wall in util.c from the perl source code
------------------------------
Date: 8 Jul 98 15:59:10 GMT
From: udaa460@alder.cc.kcl.ac.uk (Allan Hawdon)
Subject: Re: question about inline editing
Message-Id: <f141Q+Bbju62@alder.cc.kcl.ac.uk>
In article <35A36687.D3C29520@eed.ericsson.se>, Alexander Farber <eedalf@eed.ericsson.se> writes:
> Hi,
>
> is it possible to find out when you finished processing
> one file and starting another when using <> ? For example
> if you'd like to enter letter # in the beginning of each
> line after <BODY> in several *.html files:
>
> undef $^I;
>
> while (<>)
> {
> print '# ' if $body_found;
> print;
>
> $body_found = 1 if /<BODY>/;
>
> $body_found = 0 if end_of_actual_file; # how ?
What's wrong with using eof() ?
------------------------------
Date: Wed, 08 Jul 1998 15:34:15 GMT
From: biaolu@my-dejanews.com
Subject: Save attachment as a seperate file
Message-Id: <6o03hn$4jd$1@nnrp1.dejanews.com>
I am try to write a Perl program which will save my unix e-mail attachment as
a new file yet keep the original format. For example, I may receive a mail
from someone that attached his resume as a .doc file, the program should save
the attached file as a .doc file but seperately. Any idea? Thanks!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 09 Jul 1998 01:10:37 +1000
From: David Hamilton <ozslot@alphalink.com.au>
Subject: Searching a file
Message-Id: <35A38BED.4FC65DE3@alphalink.com.au>
I am having some problems loading a text file into a variable and then
not writing to the file if an E-mail address is already in the file. I
have read all the documentation I could find on this. This code writes
to the file no matter what and there are many occurences of $email
already in the file.
$email=($INPUT{'email'});
open (REMOVED, "removed.txt");
$remfile = <REMOVED>;
close (REMOVED);
unless ($remfile =~ /$email/)
{
open (REMVD, ">>removed.txt");
print REMVD "$email\n";
close (REMVD);
}
------------------------------
Date: 08 Jul 1998 10:47:22 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Philip Snyder <prsnyder@bewley.net>
Subject: Re: Strange file behavior...
Message-Id: <zpekfiph.fsf@mailhost.panix.com>
Philip Snyder <prsnyder@bewley.net> writes:
> However, I can't seem to be able to upload a .pdf to overwrite the
> old one.
What do you mean by "upload"?
> I've tried going through and using `rm $pdf_write/$file` (which
> is how I delete them in the delete script) and I've tried to just open
> them for writing (no append -> open (FILEHANDLE, ">$filename)). Still no
> luck.
What do you mean by "no luck"? What does the $! variable contain when
the open() fails?
Are you using -w?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Wed, 08 Jul 1998 10:16:29 -0500
From: Philip Snyder <prsnyder@bewley.net>
Subject: Re: Strange file behavior...
Message-Id: <35A38D4D.BFEDC809@bewley.net>
Hiya. Well, when I say upload, I mean upload. :) As of Netscape 2 (I
think... maybe it was 3?), there has been a file upload form item. Well,
that is how the maintainer will be putting the file on the server. The
maintainer is pretty dumb when it comes to the real thing. He's never
done a command prompt ftp before and I DO NOT want him screwing up
everything I worked on because he can't figure out how to pull up a
directory. :)
As for the open... well thats a kicker right there. It doesn't fail. It
just fails doing something else shortly after the open (I believe I
might be closing in on this problem at them moment too...)
Am I using -w? Whats that? Is that another file checking thing? JUST
KIDDING! Yep. I've got that turned on like any good perl programmer.
I really do think I will have this problem solved in an hour or two, so
don't worry too much about it!
-Philip
prsnyder@bewley.net
If love is blind then blind I'll be, for I would much rather love than
see.
Jonathan Feinberg wrote:
>
> The following message is a courtesy copy of an article
> that has been posted as well.
>
> Philip Snyder <prsnyder@bewley.net> writes:
>
> > However, I can't seem to be able to upload a .pdf to overwrite the
> > old one.
>
> What do you mean by "upload"?
>
> > I've tried going through and using `rm $pdf_write/$file` (which
> > is how I delete them in the delete script) and I've tried to just open
> > them for writing (no append -> open (FILEHANDLE, ">$filename)). Still no
> > luck.
>
> What do you mean by "no luck"? What does the $! variable contain when
> the open() fails?
>
> Are you using -w?
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
> http://pobox.com/~jdf/
------------------------------
Date: Wed, 08 Jul 1998 10:19:56 -0500
From: Philip Snyder <prsnyder@bewley.net>
Subject: Re: Strange file behavior...
Message-Id: <35A38E1C.76BB8E72@bewley.net>
UPDATE: I have gotten this to work finally. I actually ended up with a
much nicer looking setup too, so hey, it's all good. :) I will post the
IP of the server whenever I get the darn ISDN router in. Thanks to all
who tried to help before I got it! :P
-Philip
prsnyder@bewley.net
If love is blind then blind I'll be, for I would much rather love than
see.
Philip Snyder wrote:
> As for the open... well thats a kicker right there. It doesn't fail. It
> just fails doing something else shortly after the open (I believe I
> might be closing in on this problem at them moment too...)
------------------------------
Date: Wed, 08 Jul 1998 15:03:31 GMT
From: tonyprideaux@my-dejanews.com
Subject: Sybperl script fails to exit after last line
Message-Id: <6o01o2$24n$1@nnrp1.dejanews.com>
I've written a small Sybperl script which I run from Cron throughout the day.
However, occasionally, after it has executed the last lines in the script,
the process goes into a cpu loop and has to be terminated with a kill -9. The
last three lines are: print LOG "Goodbye world!!\n"; close LOG; exit 0;
The print statement executes everytime so it is getting to the end.
I'm running this on AIX 4.1.4 with Perl 5.004 and Sybperl 2. Has anyone got an
idea as to why my script is sometimes looping when it should be exiting?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 08 Jul 1998 13:48:56 GMT
From: otis@my-dejanews.com
Subject: Re: tough regexp - help needed
Message-Id: <6nvtc8$rot$1@nnrp1.dejanews.com>
In article <6nufuq$fjc$5@client3.news.psi.net>,
abigail@fnx.com wrote:
> otis@my-dejanews.com (otis@my-dejanews.com) wrote on MDCCLXXI September
> MCMXCIII in <URL: news:6nu75i$fc8$1@nnrp1.dejanews.com>:
> ++ Hello,
> ++
> ++ perl regular expression problem :)
> ++
>
> (Something with HTML)
>
> Don't apply regexs on the entire document - that won't work.
>
> use HTML::Parser;
unfortunately this is not an option for me in this project.
while I posted this in a perl newsgroup (because it requires knowledge of
regular expressions, and a perl newsgroup is most probably the best for that),
the code is actually java (OROMatcher package).
So my original question still stands :)
Thank you,
Otis
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 08 Jul 1998 10:32:22 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: otis@my-dejanews.com
Subject: Re: tough regexp - help needed
Message-Id: <3eccgxyx.fsf@mailhost.panix.com>
otis@my-dejanews.com writes:
> In article <6nufuq$fjc$5@client3.news.psi.net>, abigail@fnx.com
> wrote:
> >
> > Don't apply regexs on the entire document - that won't work.
> while I posted this in a perl newsgroup (because it requires
> knowledge of regular expressions, and a perl newsgroup is most
> probably the best for that), the code is actually java (OROMatcher
> package).
>
> So my original question still stands :)
As does Abigail's original answer: a regex solution won't work, since
your problem is not solvable is terms of regular expressions. Surely
someone has written an HTML parser in java?
Followups set.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Wed, 08 Jul 1998 11:47:48 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: tough regexp - help needed
Message-Id: <comdog-ya02408000R0807981147480001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6nvtc8$rot$1@nnrp1.dejanews.com>, otis@my-dejanews.com posted:
>In article <6nufuq$fjc$5@client3.news.psi.net>,
> abigail@fnx.com wrote:
>> otis@my-dejanews.com (otis@my-dejanews.com) wrote on MDCCLXXI September
>> MCMXCIII in <URL: news:6nu75i$fc8$1@nnrp1.dejanews.com>:
>> ++ Hello,
>> ++
>> ++ perl regular expression problem :)
>> ++
>>
>> (Something with HTML)
>>
>> Don't apply regexs on the entire document - that won't work.
>>
>> use HTML::Parser;
>
>unfortunately this is not an option for me in this project.
>while I posted this in a perl newsgroup (because it requires knowledge of
>regular expressions, and a perl newsgroup is most probably the best for that),
>the code is actually java (OROMatcher package).
[boggles...]
the answer still is that regexen aren't not the way to go. but, if
you needed a java solution, you should have said so and posted to
an appropriate group. maybe another java person has already done what
you need to do.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
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 3095
**************************************