[7593] in Perl-Users-Digest
Perl-Users Digest, Issue: 1219 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 23 11:17:15 1997
Date: Thu, 23 Oct 97 08:00:26 -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, 23 Oct 1997 Volume: 8 Number: 1219
Today's topics:
BUG? parenthesis problem in regex <lwest@imaginet.fr>
Re: BUG? parenthesis problem in regex (Mike Stok)
Re: Checking for the existence of subroutines (Mike Stok)
Re: Checking for the existence of subroutines (Andrew M. Langmead)
Re: Command Pipes in Perl Win32 (Paul Moore)
Re: Console emulator (Matthew H. Gerlach)
Re: help solving this beginning 'perl' program (Bob Wilkinson)
Re: HELP: strange problems with if () (Mick Farmer)
Re: How to go a particular line in a file? (Fritz Knack)
Re: How to sort a multi-dim array ??? (Andrew M. Langmead)
Re: Installing Perl (Jeremy D. Zawodny)
MAIL TO: Perl Script wizard@junct.com
Re: Move specified number of variables into one array?? (Andrew M. Langmead)
Re: non-locking fileread (Mike Stok)
Open File Question (NATALIA ALTMAN)
Re: Perl for Windows 95 (Paul Moore)
Perl, Gnuplot & Graphics (Mark Schunder)
persistent hash assignment problem <eggbert.pad@sni.de>
Problem with Getopt::std <barnett@houston.Geco-Prakla.slb.com>
Re: Problems locking a file (Kerry Schwab)
Re: Scalar Variable Help (David Alan Black)
Re: Script to save an html browser file into the server (Jeremy D. Zawodny)
Re: Script to save an html browser file into the server (Jeremy D. Zawodny)
skipping lines <jjune@midway.uchicago.edu>
Using ? in URL ECSSPEAR@livjm.ac.uk
Re: Using ? in URL (Toutatis)
Re: using wildcards with unlink command (Steve O'Hara Smith)
Web Based Calendar/ Stuffed with emails? <dphi@ix.netcom.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Oct 1997 15:06:36 +0200
From: Leo West <lwest@imaginet.fr>
Subject: BUG? parenthesis problem in regex
Message-Id: <344F4BDC.965FE7DB@imaginet.fr>
Here is a problem i have with RegExp evaluation :
here is a RegEx model i use:
if( $description =~ /^$var\s*[\.\!\?]?\.?\.?(.*)/ ){
# do something
}
Perl stops with this error msg:
/^TAPIS RECTO VERSO (2 BLANC\s*[\.!\?]?\.?\.?(.*)/: unmatched
() in regexp at in_tshop.pl line 384, <FI> chunk 3002.
$var contains "TAPIS RECTO VERSO (2 ....an more *with no closing
parenthesis*
I guess the bug happens because the $var contains a single open
parenthesis, that Perl *understands as part of the model*.
My question are:
1) is it normal that Perl mixes the parenthesis contained in $var with
the model parenthesis ?
2) how could i avoid this ?
Thanxs
sorry for my english.
------------------------------
Date: 23 Oct 1997 13:39:11 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: BUG? parenthesis problem in regex
Message-Id: <62nk1v$qdb@news-central.tiac.net>
In article <344F4BDC.965FE7DB@imaginet.fr>,
Leo West <lwest@imaginet.fr> wrote:
>Here is a problem i have with RegExp evaluation :
>
>here is a RegEx model i use:
>
> if( $description =~ /^$var\s*[\.\!\?]?\.?\.?(.*)/ ){
> # do something
>}
>
>Perl stops with this error msg:
>/^TAPIS RECTO VERSO (2 BLANC\s*[\.!\?]?\.?\.?(.*)/: unmatched
>() in regexp at in_tshop.pl line 384, <FI> chunk 3002.
>
>$var contains "TAPIS RECTO VERSO (2 ....an more *with no closing
>parenthesis*
>
>I guess the bug happens because the $var contains a single open
>parenthesis, that Perl *understands as part of the model*.
>My question are:
>1) is it normal that Perl mixes the parenthesis contained in $var with
>the model parenthesis ?
Yes, Jeffery Friedl's book Mastering Regular Expressions covers the way a
regex is handled by perl, and $var has been interpolated so the regex
engine sees
/^TAPIS RECTO VERSO (2 BLANC\s*[\.!\?]?\.?\.?(.*)/
as the thing it's working with.
>2) how could i avoid this ?
If you're using perl 5 then you can use \Q and \E to bracket the variable
which will cause any metacharacters to be escaped e.g.
if( $description =~ /^\Q$var\E\s*[\.\!\?]?\.?\.?(.*)/ ){
The perlre man page describes this. In earlier perls you could make a
"regex safe" copy of a variable by saying
($safeVar = $var) =~ s/(\W)/\\$1/g;
and using $safeVar in the regex
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 23 Oct 1997 13:25:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Checking for the existence of subroutines
Message-Id: <62nj8i$pmv@news-central.tiac.net>
In article <344EA28A.CF0C83D6@ctberk.com>,
Arvid Peterson <apeterso@ctberk.com> wrote:
>Is there any way in perl 4 to check for the existence of a certain
>subroutine in a program and call that subroutine only if it exists??
>The reason for this is, I need to call subroutines for specific variable
>values, and want to name the subroutine with the value. Let's say...
>
>$var1= "grub";
><more perl code>
>&$var1;
Perl 4 allows you to call a subroutine whose name is in a scalar like
this:
&$var ('arg');
and you can use defined to see if it exists e.g.
if (defined &$var) {
&$var ();
}
else {
# maybe issue a diagnostic...
}
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Thu, 23 Oct 1997 13:55:17 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Checking for the existence of subroutines
Message-Id: <EIIC05.7Dq@world.std.com>
Arvid Peterson <apeterso@ctberk.com> writes:
>Is there any way in perl 4 to check for the existence of a certain
>subroutine in a program and call that subroutine only if it exists??
>The reason for this is, I need to call subroutines for specific variable
>values, and want to name the subroutine with the value. Let's say...
You can use the defined() operator to test for the existance of a
subroutine. In your old version of perl, defined is discussed in the
one large perl man page. In current versions of perl, it is in the
perlfunc man page.
if(defined &$var1) {
&$var1;
}
else {
warn "subroutine $var1 is not defined\n";
}
--
Andrew Langmead
------------------------------
Date: Thu, 23 Oct 1997 12:23:38 GMT
From: Paul.Moore@uk.origin-it.com (Paul Moore)
Subject: Re: Command Pipes in Perl Win32
Message-Id: <344f3fb5.14345531@news.origin.nl>
On Wed, 22 Oct 1997 13:01:19 GMT, zawodny@hou.moc.com (Jeremy D.
Zawodny) wrote:
>On 21 Oct 1997 22:29:45 GMT, cnastans@mipos2.intel.com (Craig
>Nastanski) wrote:
>>Can
>>I simulate the equivalent Unix behavior using Perl? Perl Win32 doesn't support
>>the fork command (why?)
>
>Because it's not built-in to the OS like it is in Unix. Developing a
>custom fork() implementation for Win32 is something to take lightly. I
>can't imagine any of the Perl Porters jumping to the task.
>
>It's really a failing on the part of Microsoft if you ask me. If they
>wanted to make an 'easy' migration path from Unix to NT, they'd have
>implemented more of the critical system calls (like fork()).
I may be willing to concede on that point. However, it remains a fact
that many uses of system calls like fork() are stylised uses to
implement a common function - the obvious example is a fork/exec
setup.
It would be both relatively straightforward and helpful to implement
functions (possibly not even builtins - it may be simple enough to
make them library functions) to model such common patterns.
Following on from fork/exec, a spawn() function (possibly with some
slightly fancy parameters to handle common uses involving inheriting
file descriptors) would be a good example.
Of course, we have to identify such patterns.
And the BIG problem is convincing the unix people out there that using
these functions to assist portability to other OSes like Win32 is
worth doing. Particularly in stuff in the standard library, and on
CPAN.
My other pet hate on this score is `cmd 2>&1`.
That's pure Unix sh syntax. I believe Windows NT might support it, but
Windows 95 certainly doesn't. There should be a function to do this.
Not hard, start with
sub backtick_with_stderr ($) {
`$_[0] 2>&1`;
}
If the Unix lot would use this, I'd write a version for Win32... But
of course, they won't... :-(
Sorry. I'll get off my soapbox now...
Paul Moore.
------------------------------
Date: Thu, 23 Oct 1997 14:19:59 GMT
From: gerlach@netcom.com (Matthew H. Gerlach)
Subject: Re: Console emulator
Message-Id: <gerlachEIID5B.BCI@netcom.com>
Conceptionally, what you what to do is what is described in Don Libes
book, Expect. However, Expect is an extension to the TCL language. One
can get expect-like functionality from Comm.pl.
Matthew H. Gerlach
In article <62n56l$m6m$1@sunsite.icm.edu.pl> "Robert Nosko" <robertn@dawid.com.pl> writes:
>Hi,
>Some programs on linux require input directly from console.
>I want my script to be able to send input to such programs.
>How can I:
>1. write console emulator in perl?
>2. link this emulator with any program?
>thanks,
>--
------------------------------
Date: Thu, 23 Oct 1997 14:25:58 +0100
From: b.wilkinson@pindar.com (Bob Wilkinson)
Subject: Re: help solving this beginning 'perl' program
Message-Id: <b.wilkinson-2310971425580001@ip57-york.pindar.co.uk>
In article <344D29C9.4F86@dts.harris.com>, Joyce Koontz
<JKOONTZ@dts.harris.com> wrote:
> Here is the question:
>
> Write a "Perl" program that takes as input a momth and day, sucn as
> "Dec 31".
> The program should return what day of the year it is. Thus, "Jan 1"
> should return 1, "Dec 31" should return 365 (you can assume February
> has 28 days).
>
> You may want to allow the use of full month names such as "January 28".
Hello,
I'd start by defining a hash indexed by month, which has as values the
offset in days into the year of the first day of the month -1.
e.g.
my %months = ( "Jan",0,
"Feb",31,
"Mar",59,
"Apr",90,
etc.
)
Then it would be simple to write code to parse out the string "Dec 31". e.g.
if this is contained within $mydate.
my $mydate = "Dec 31";
my ($mon,$num) = $mydate =~ /^([^ ]+) (.+)$/;
Then the solution to your question would be $months{$mon} + $num.
Bob
--
.sig file on holiday
------------------------------
Date: Thu, 23 Oct 1997 14:18:53 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: HELP: strange problems with if ()
Message-Id: <EIID3H.B0y@mail2.ccs.bbk.ac.uk>
Dear bboett,
Your 'boolean' variable contains a string. Therefore, you
should compare it using eq, not ==.
Regards,
Mick
------------------------------
Date: Thu, 23 Oct 1997 12:35:38 GMT
From: fritz.knack@nospam.POPULUS.net (Fritz Knack)
Subject: Re: How to go a particular line in a file?
Message-Id: <344f42e2.2560004@snews.zippo.com>
On 22 Oct 1997 20:47:09 GMT, cberry@cinenet.net (Craig Berry) wrote:
>John Robson (as646@FreeNet.Carleton.CA) wrote:
>:
>: The special variable $. automatically keeps track of the line read and
>: increments itself.
>: But it doesn't allow you to modify it, to assign a value to it (?!).
>:
>: Suppose I open a file and want to jump directly to, for example, line 8, how
>: do I do this ? Doing $. =+ 7 doesn't seem to work.
>
> while (<FILE>) {
> last if $. == 8;
> }
>
> if ($. == 8) {
> # Do the line-8 thing.
> }
> else {
> die "Hey, the input file had only $. lines!";
> }
>
>Hope this helps...
>
If he needed to use the same file again (say, for line 6), would a new
while (<FILE>) automatically reset the $. variable? In ohter words,
would the following hit the "oops" or execute the "line 6 thing"
below?
while (<FILE>) {last if $. == 6}
if ($. == 6) {} #line 6 thing
else {} # Oops.
If it doesn't automatically reset the counter, how do you make it do
so? Close/Reopen?
Lurking to learn.
Fritz
-------------------------
Sorry 'bout the nospam in the From field. You know how those 'bots
are.
------------------------------
Date: Thu, 23 Oct 1997 13:40:30 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How to sort a multi-dim array ???
Message-Id: <EIIBBI.Fvt@world.std.com>
Vincent RABAH <vincent.rabah@hol.fr> writes:
>I need to sort this multi-dimensional array, on the 2nd column+3nd
>column,
Take a look at the FAQ entry "How do I sort an array by (anything)?"
<URL:http://www.perl.com./CPAN/doc/manual/html/pod/perlfaq4/
How_do_I_sort_an_aray_by_anyth.html> and then start applying its
general guidelines to your data.
Each element of @tab is a reference to an array. So if you have an
element, you can dereference it, and compute on the second or third
element (numbered 1 and 2, since arrays are zero based.) You want to
compare the second column, and if they are different, inform perl on
how the two compare, if they second column is equal, then you want to
compare again based on the third column. The comparison operators
("<=>" and "cmp") and the logical or operator go great together here
because if two items are equivilent the operator returns zero, and if
the left side of the logical or operator returns a boolean false value
( 0, "0", '', or undef), the right side is executed.
@sorted = sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] } @tab;
--
Andrew Langmead
------------------------------
Date: Thu, 23 Oct 1997 13:03:10 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Installing Perl
Message-Id: <34504aec.518318242@igate.hst.moc.com>
[cc'd automagically to original author]
On Wed, 22 Oct 1997 16:45:44 -0700, Jason North
<jason@enterpriselink.com> wrote:
>Does anyone know exactly where I can find some docs on installing the
>perl intreptor and getting it fully functional on a web server (Netscape
>Enterprise Server).
Yes. Netscape provides the documentation. Have you checked their FAQ?
Their support site?
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: 23 Oct 97 09:11:31 -0600
From: wizard@junct.com
Subject: MAIL TO: Perl Script
Message-Id: <3828.235T1590T5512566@junct.com>
I'm trying to write a Perl script to take the contents of a form from my
WEB page & Email the results to me. Here is what I have so far. It always
stops & returns the message saying print "Sorry! We are unable to process
your order at this time because we did not receive your name."
My ISP is running Linux 2.0.03. I don't know what version of perl he is
using.
Please respond by email.
-----clip--------
#!/usr/bin/perl
#Includes cgi-lib file; if cgi-lib doesn't exist, returns malformed
#header error
do "cgi-lib.pl" || die "Fatal Error: Can't load cgi library";
#calls the subroutine in the cgi-lib.pl library
#to read in the variables from the form and set them up
#as key=value pairs in the array @in
&ReadParse;
#do a simple check to make sure the necessary fields are
#completed.
$name = $in{'name'};
unless ($name > 0) {
#tells http server incoming data is text html
#sends back NO-GO for order form
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD><TITLE>Can not process order</TITLE>";
print "</HEAD><BODY>";
print "<H1>Sorry\!</H1>";
print "We are unable to process your order at this\n";
print "time because we did not receive your name.\n";
print "<P>";
print "<H2><I>Dave's Guns & Junk</I></H2>";
print "<HR>";
print "<H3>Back to the <A HREF=\"/http://www.junct.com/~wizard/guns.html\">";
print "Front Page</A></H3>";
print "<H3>Back to the <A HREF=\"/http://www.junct.com/~wizard/order.html\">";
print "Order Form</A></H3>";
print "</BODY></HTML>";
#quit the script - not enough information was present to
#place an order.
exit;
}
#assigns process id to $pid
$pid=$$;
#opens up comment file for writing
open(ORDER,">/tmp/order_info.$pid");
#enter the form data into the file to be mailed
print ORDER " FIREARMS ORDER FORM\n";
print ORDER "- - - - - - - - - - - - - - - - - - -\n";
print ORDER " Name: $in{'name'}\n";
print ORDER " Phone: $in{'phone'}\n";
print ORDER "Address: $in{'address1'}\n";
print ORDER " : $in{'address2'}\n";
print ORDER " City: $in{'city'}\n";
print ORDER " State: $in{'state'}\n";
print ORDER " Zip: $in{'zip'}\n";
print ORDER " Email: $in{'email'}\n";
print ORDER "- - - - - - - - - - - - - - - - - - -\n";
print ORDER;
print ORDER " FIREARMS INFORMATION\n";
print ORDER;
print ORDER "Manufacturer: $in{'mfg'}\n";
print ORDER " Model: $in{'model'}\n";
print ORDER " Caliber: $in{'caliber'}\n";
print ORDER " Finish: $in{'finish'}\n";
print ORDER " Length: $in{'length'}\n";
print ORDER;
print ORDER "- - - - - - - - - - - - - - - - - - -\n";
#close out file to be mailed
close COMMENTSFILE;
#sends comment file as mail to user
$command="mail wizard/@junct.com < /tmp/order_info.$pid";
system($command);
#erases temp file
unlink("/tmp/order_info.$pid");
#tells http server incoming data is text html
#acknowledges receipt of information
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD><TITLE>Thank You\!</TITLE>";
print "</HEAD><BODY>";
print "<H2>Thank you\!</H2>";
print "According to our information, you ordered:\n";
print "<PRE>\n";
print "Manufacturer: $in{'mfg'}\n";
print " Model: $in{'model'}\n";
print " Caliber: $in{'caliber'}\n";
print " Finish: $in{'finish'}\n";
print " Length: $in{'length'}\n";
print "</PRE>\n";
print "<P>";
print "We will contact you by phone or Email with\n";
print "pricing and payment instructions\n";
print "<P>";
print "<H2><I>Dave's Guns & Junk</I></H2>";
print "<HR>";
print "<H3>Back to the <A HREF=\"/http://www.junct.com/~wizard/guns.html\">";
print "Front Page</A></H3>";
print "</BODY></HTML>";
--------clip--------
--
Email: wizard@junct.com
WWW: http://www.junct.com/~wizard
Member <TEAM AMIGA>
--
These taglines multipy faster than Tribbles.
------------------------------
Date: Thu, 23 Oct 1997 13:50:26 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Move specified number of variables into one array???
Message-Id: <EIIBs2.36o@world.std.com>
Michael Bach <Michael.Bach@kst.siemens.de> writes:
>Hi there...
>I have the following problem:
>1) I get a certain number of arguments from a HTML-form via CGI.pm
>2) I know the number of arguments
>3) I do a loop to work on each of the arguments using the number of
>arguments
One way to do this is with symbolic references:
while ( $bla != $numberOfArguments) {
no strict 'refs'; # in case we're running under 'use strict'
print ${"argument$bla"};
$bla++;
}
See the perlref man page for details.
--
Andrew Langmead
------------------------------
Date: 23 Oct 1997 13:31:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: non-locking fileread
Message-Id: <62njj0$q0a@news-central.tiac.net>
In article <01bcdf99$553d43c0$c82da8c0@akilles.ittek.org>,
Robert Friberg <robert.friberg@eductus-vast.com> wrote:
>If i'm reading a file like this:
>
> open( FILE, "<$file" ) || die "Can't open $file";
> @slurp = <FILE>;
> close FILE;
>
>and several instances of the script
>can be launched simultaneously, is file locking neccesary?
>Does it matter which OS the script is running under?
If all you're doing is opening the file to read then as many processes as
you like can open it at once (give or take operating system limits) and
you're safe relying on open's return value to tell you whether it worked
or not.
If you are updating the file then locking is important as it's possible
for two updates to conflict with each other, possibly losing data.
That's the simple answer...
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 23 Oct 1997 09:36:48 -0500
From: aya@MCS.COM (NATALIA ALTMAN)
Subject: Open File Question
Message-Id: <62nne0$sus$1@Venus.mcs.net>
I am novice in the Perl's world.
I have a problem with the following program. The program is a copy from the
"Programming Perl" book. After program is run the output file is empty. What
am I possible doing wrong?
Perl, version 5.003 with EMBED
built under hpux at Oct 16 1996 12:41:55
+ suidperl security patch
-----------------------------------
#!/usr/local/bin/perl -w
$InFile="filename";
$OutFile="/tmp/filename.$$";
#
# Using the FileHandle constructor...
use FileHandle;
#
# Sort $InFile file and redirect output to $OutFile...
open (InFile, "|sort >$OutFile") or die "Error: $InFile: $!\n";
while($Line=<InFile>) {
print "$Line";
}
close(InFile);
die "Error: $!\n" if $?;
-----------------------------------
--
Thanks,
Arkady Altman
altman_arkady@cae.cig.mot.com
NOTE: Reply-to is disabled against spam!
------------------------------
Date: Thu, 23 Oct 1997 12:29:04 GMT
From: Paul.Moore@uk.origin-it.com (Paul Moore)
Subject: Re: Perl for Windows 95
Message-Id: <34504232.14982996@news.origin.nl>
On Thu, 23 Oct 1997 02:17:01 GMT, cheerio@flash.net (Cheerio) wrote:
>I am a newbie to Perl and i have been attempting to create small
>programs that may be useful on a shell account, i use windows 95
>as my os and i was wondering if there was a type of perl for win95.
>One that can run commands .etc and i dont mean cgi. Well if there
>is can someone tell me where to get it .etc and if it is different
>from the linux version? well thanks for your time
> -Cheerio
At CPAN, in /ports/win32/Standard/ix86/bindist*04.tar.gz
(the * indicates that I've forgotten the exact name).
There's also a port by Activestate, but I believe it's for a slightly
older version, and it's from hacked sources rather than the standard
distribution. There's a move to merge the two distributions, I
believe.
Also the bindist version comes with loads of modules bundled into the
distribution.
Paul Moore.
------------------------------
Date: Thu, 23 Oct 1997 16:37:05 GMT
From: mschunder@cybernet.com (Mark Schunder)
Subject: Perl, Gnuplot & Graphics
Message-Id: <62nk83$r1a@gateway.cybernet.com>
Hello,
I'm writing a perl script to display a list of x,y coordinates and I
would like to display a background graphic and have gnuplot plot the
points over the graphic. Is this possible?
Thanks again!
Mark Schunder
mschunder@cybernet.com
------------------------------
Date: Thu, 23 Oct 1997 16:00:31 +0200
From: Jochen Luig <eggbert.pad@sni.de>
Subject: persistent hash assignment problem
Message-Id: <344F587E.7CCD54AD@sni.de>
Hi!
I have a problem using persistent hashes. When I run the following
program segment:
dbmopen(%parray,"test",0777);
%parray = ( "key1" => "value1",
"key2" => "value2");
dbmclose(%parray);
I keep gettin the error message:
sdbm store returned -1, errno2, key "key1" at <filename>
whatever mode or assignment I try.
Could someone please tell me the difference between assignment to hashes
and to persistent hashes or point me to an url dealing with persistent
hashes? All the sites
I found stop exactly where it might get interesting for me.
Thanks in advance
Jochen
------------------------------
Date: Thu, 23 Oct 1997 08:00:00 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Problem with Getopt::std
Message-Id: <344F4A50.5AFE@NO_SPAM.houston.Geco-Prakla.slb.com>
I believe I am using Getopt::std correctly, but am getting what I
believe are incorrect results.
I am unable to get a single character option to work properly.
For example:
#!/usr/local/bin/perl -w
#
use strict;
use diagnostics;
use Getopt::std;
getopt('h');
if (defined($::opt_h) {
$::opt_h = "";
USAGE();
}
sub USAGE {
print STDOUT ("usage: $0: [-h] [other options]\n");
print STDOUT (" -h Print this help message.");
exit 1;
}
__END__
When I run the script as 'script.perl -h', the opt_h variable does not
get set. I am attempting to set up a help message for my script that
will print out any time 'script.perl -h' is input.
If I enter 'script.perl -h --', opt_h is assigned "--" as a value, and
so the subroutine that prints the usage information is then called.
What am I missing here? I want to have a unix style usage line, without
having to enter 'script.perl -h --', assuming that the users will not
know to do this. Can it be done using Getopt, or must I manually check
for the '-h' option before this will work?
Any help appreciated.
Dave Barnett
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
------------------------------------------------------------------------
* Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------
------------------------------
Date: 23 Oct 1997 01:53:32 -0600
From: kschwab@nyx.net (Kerry Schwab)
Subject: Re: Problems locking a file
Message-Id: <62mvps$g0b$1@nyx10.nyx.net>
In article <344ED083.AA4A168E@teclata.es>,
Xavier Tarafa Mercader <xavi@teclata.es> wrote:
>I posted a similar question 15 days ago, but I didn't get the answer I
>was looking for.
>
>I've a script which open a file (with exclusive lock) wait for ten
>seconds and then close the file. The script also return to me the value
>returned by flock function.
>
>
>What I do is running the script twince in less than 10 seconds. So it
>was suposed to the second time I run it to get an error value as a
>return of flock function, but it doesn't happen.
flock() without the LOCK_NB flag will block until the lock is
"available". So, the first run of your script gets the lock,
then the second run (assuming it was started while script #1
is in the sleep()) blocks until the lock is released.
Since you said you wanted flock() to return "an error value",
you probably want to use the LOCK_NB flag, like so:
use Fcntl ':flock';
open(FILE,">foo");
$return=flock(FILE,LOCK_EX | LOCK_NB);
print "return is $return\n";
This is all documented pretty well in "perldoc perlfunc".
--
Kerry
>
>Here is the script, if someone can find what i'm doing wrong please
>answer me.
>
>
>#!/usr/bin/perl
>$ENV{PATH} = '/usr/bin:/bin';
>
>$LOCK_EX = 2;
>$LOCK_UN = 8;
>$trouble_email = 'mail@adress;
>
>
>#Open file
>
>if(!(open(TABLE,">./test"))){
> print STDERR "Couldn't open Table: $table_content file.";
> exit(0);
>}
>
>
>
>#lock the file
>
>$valor=flock(TABLE,$LOCK_EX);
>
>
>#Get a mail with flock return value
>
>open(OUT,"|mail $trouble_email");
>print OUT "flock value is $valor";
>close(OUT);
>
>#Abort program if was not flocked
> if($valor == 0){
> print STDERR "Couldn't flock Table: $table_content file";
> exit(0);
> }
>
>sleep(10);
>
>
>#Close table
>if(!close(TABLE)){
> print STDERR "Could not close Table: $table_content file";
> exit(0);
>}
>
>
>
>
>
>
>Xavier Tarafa
>Teclata.
>
>
------------------------------
Date: 23 Oct 1997 13:03:05 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Scalar Variable Help
Message-Id: <62nhu9$3mf@pirate.shu.edu>
Hello -
cvinny@mailexcite.com (Vinny) writes:
>Help:
>I am having trouble finding the syntax for naming a variable using a variable.
>Here is the simple example
>$i = '6'
>$M6 = "Got It"
>Print "$M$i";
>How do you combine $M with $i
I think you really want to combine 'M' with the value of $i - ?
my $i = 6;
local $M6 = "Got it";
print ${"M$i"};
I've localized $M6 to point out the fact that $M6 cannot be a my variable,
because my variables are not in the symbol table and the syntax in the
print statement (a symbolic reference - see Camel) depends on being able
to look up the scalar member of the typeglob identified by "M$i" in the
symbol table.
David Black
dblack@icarus.shu.edu
------------------------------
Date: Thu, 23 Oct 1997 13:02:26 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Script to save an html browser file into the server.
Message-Id: <344f4ab6.518264104@igate.hst.moc.com>
[cc'd automagically to original author]
On Wed, 22 Oct 1997 14:49:49 -0700, Sahar Madani <sahar@home.net>
wrote:
comp.lang.perl does not exist. Don't post to it. Tell your news
administrator to update his/her groups list.
>how is it possible to save (publish) a CGI cookie based HTML file onto
>the server from browser ?
Yes.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 23 Oct 1997 13:41:13 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Script to save an html browser file into the server.
Message-Id: <344f5389.520522762@igate.hst.moc.com>
[cc'd automagically to original author]
On Thu, 23 Oct 1997 13:02:26 GMT, zawodny@hou.moc.com (Jeremy D.
Zawodny) wrote:
>[cc'd automagically to original author]
>
>On Wed, 22 Oct 1997 14:49:49 -0700, Sahar Madani <sahar@home.net>
>wrote:
>
>comp.lang.perl does not exist. Don't post to it. Tell your news
>administrator to update his/her groups list.
>
>>how is it possible to save (publish) a CGI cookie based HTML file onto
>>the server from browser ?
>
>Yes.
Sorry. I hit the 'post' key before I was quite finished with that
(damned distracting phone calls).
Yes.
That's a web server question. Unless you're looking for a Perl
solution, I'd suggest hitting one of the server newsgroups.
If you are looking for a Perl solution, I'd suggest the LWP modules on
CPAN. They should allow you to use the HTTP PUT command to upload
files to a willing web server.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 23 Oct 1997 14:41:05 GMT
From: Joseph June <jjune@midway.uchicago.edu>
Subject: skipping lines
Message-Id: <Pine.GSO.3.95.971023092824.5475B-100000@harper.uchicago.edu>
Hello,
I have been having some trouble with my perl script and wondering if
anyone could offer some help.
I have a static file which the script searches for
:rule_adtr (
:src_adtr (
: Some Network
)
:dst_adtr (
: X-AAAAAAAAA
by series of nested loops... something like
# Skipping other rule_adtr
if ($rulefile_line =~ m/\s+:rule_adtr\s+\(/ && $repeat !=1 )
{ $rulefile_buffer_2 = <RULEFILE>;
if ($rulefile_buffer_2 !=~ m/Z\s+:src_adtr\s+\(/ ) {
if ($rulefile_buffer_2 =~ m/\s+:src_adtr\s+\(/ ) {
$rulefile_buffer_3 = <RULEFILE>
if ($rulefile_buffer_3 =~m/\s+:\s+$current_addtrx/ ) {
$rulefile_buffer_4 = <RULEFILE>;
if ($rulefile_buffer_4 =~ m/\s+\)/) {
$rulefile_buffer_5 = <RULEFILE>;
if ($rulefile_buffer_5 =~ m/\s+:dst_adtr\s+\(/ ) {
$rulefile_buffer_6 = <RULEFILE>;
if ($rulefile_buffer_6 =~ m/\s+:\s+X-AAAAAAAAA/ ) {
print "Reference server found.\n\n";
----snip---
The point of this script is that the static file whole bynch of entries
that starts with
:rule_adtr (
:src_adtr (
: Some Network
)
:dst_adtr (
but only one entry has
: X-AAAAAAAAA
What I am trying to do is let the script read the file... read the
entries... skipping over the ones that does not have
: X-AAAAAAAAA
... but when it does detect the whole chunk... like
:rule_adtr (
:src_adtr (
: Some Network
)
:dst_adtr (
: X-AAAAAAAAA
it runs some other things to generate a new file. What happens now is
that when it reads the file... it deletes
:src_adtr (
: Some Network
)
:dst_adtr (
part when the file is being generate... file is being "generated" by
syswrite. It seems like when the file is being read... it somehow
prevents from being written via syswrite.
I have been fiddling around with this for a while... and was not able to
figure it out. If anyone has any ideas... it will be most appreciated.
Thanks i advance!
------------------------------
Date: Thu, 23 Oct 1997 15:02:01 -0700
From: ECSSPEAR@livjm.ac.uk
Subject: Using ? in URL
Message-Id: <344FC958.7E51@livjm.ac.uk>
I want to access a script but actually sending some info to the script
using the ? in the URL Eg.
/cgi-bin/access.cgi?position=quiz
How do I get the script to pick up the value position?
Any help greatfully received!
Simon Pearce
------------------------------
Date: 23 Oct 1997 14:51:29 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Using ? in URL
Message-Id: <toutatis-ya023180002310971651280001@news.euro.net>
ECSSPEAR@livjm.ac.uk wrote:
> I want to access a script but actually sending some info to the script
> using the ? in the URL Eg.
>
> /cgi-bin/access.cgi?position=quiz
>
> How do I get the script to pick up the value position?
for (split /&/, $ENV{'QUERY_STRING'}){
($k,$v) = split /=/;
$input{$k} = $v;
}
--
Toutatis
Email replies not appreciated
------------------------------
Date: 23 Oct 1997 14:03:04 GMT
From: sohara@mardil.elsevier.nl (Steve O'Hara Smith)
Subject: Re: using wildcards with unlink command
Message-Id: <62nleo$pob$1@ns.elsevier.nl>
Paul B. (reply-by@post.com) wrote:
: Is it possible to use a wildcard with an unlink command? Like:
No but you can use a glob to do the expansion and hand the list to unlink
like this:
unlink </test/web/*.txt>;
or
unlink glob ("/test/web/*.txt");
------------------------------
Date: Thu, 23 Oct 1997 07:04:45 -0700
From: Dale Phillips <dphi@ix.netcom.com>
Subject: Web Based Calendar/ Stuffed with emails?
Message-Id: <344F597D.4E3D@ix.netcom.com>
Hello all,
Has anyone done this? A Formatted email is sent to an alias,
a cronjob checks for incoming, perlizes it into html for
everyones pursal.
I have the first few steps noodled out but "how to display a
calendar from a web has me confused.'
thanks in advance.
--
----------------------
Dale Phillips
dphillip@tabfs.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 1219
**************************************