[9945] in Perl-Users-Digest
Perl-Users Digest, Issue: 3538 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 25 16:02:59 1998
Date: Tue, 25 Aug 98 13:00:25 -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 Tue, 25 Aug 1998 Volume: 8 Number: 3538
Today's topics:
A free service <interlnk@okeechobee.com>
Re: A real newbie question (Craig Berry)
Re: ado, setup, asp <ehr@listworks.com>
Apache Book briley@manning.com
Re: Are $a and $b some special variables? (Ilya Zakharevich)
Re: command line switches (brian d foy)
Re: Counting files in a directory in WinNT <stepherd@gusun.georgetown.edu>
Re: Counting files in a directory in WinNT (Larry Rosler)
Re: Exporting Methods <JKRY3025@comenius.ms.mff.cuni.cz>
Re: Exporting Methods <p-fein@uchicago.edu>
Re: Hacking Schools Network <stepherd@gusun.georgetown.edu>
help: cpan problems since new perl load <drk@rpisun1.mdacc.tmc.edu>
Re: Ignoring lines in a data file (Tad McClellan)
Re: Inserting into a linked list in a sorted fashion (Abigail)
Re: Inserting into a linked list in a sorted fashion (Larry Rosler)
Re: Looking for Programmer/Job Opp. (Snowhare)
Multiple SIG handles? thumper@webthumper.com
Re: Pattern match for filename extensions (Tad McClellan)
Perl - Internal Server Error in Unix (Mr. Mirthful)
Re: Perl CGI Question (Abigail)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 Aug 1998 15:01:37 -0400
From: "Walter Hargrave" <interlnk@okeechobee.com>
Subject: A free service
Message-Id: <6rv24d$c6n$1@obelisk.okeechobee.com>
Hi,
I just finished a very functional Software Submission
database. It allows people to get to know you, or your services.
Input some information and links into our database and its searchable
to the world, and you get all the credit. Its a automated Submmision
that lets you give the public a taste of your software (sample link),
chose a category and operating system, link to your home page.
Use words in your description that you think people
will search for when looking for your software. Samples you link
to the database will help you sell more of your products,
even if your submittal is free, you may very well benefit
from this service.
Thank you for your time,
Walter Hargrave
WebMaster/Owner
ClubKnowledge
No Adult Content Please
http://clubknowledge.com/
P.S. Just added a new feature interactive software reviews while you browse!
See ya there!
------------------------------
Date: 25 Aug 1998 19:02:24 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: A real newbie question
Message-Id: <6rv1o0$bdj$1@marina.cinenet.net>
Rob (rob3@loxinfo.co.th) wrote:
: I have a form that I want to post to two different CGI scripts
: simultaneously is this possible...
(a) This is an HTML or CGI question; it has nothing to do with Perl.
(Heuristic for determining if this is the case: Would it make any
difference if the CGI scripts were in C++ or Perl? If not, it's
not a Perl question.)
(b) No. But you can have the form's action script call the second one,
either using system/backticks if on the same server, or HTTP ('real'
CGI) no matter where it is.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Tue, 25 Aug 1998 14:38:47 -0400
From: "Eric Raskin" <ehr@listworks.com>
Subject: Re: ado, setup, asp
Message-Id: <umwPPeF09GA.221@uppssnewspub04.moswest.msn.net>
David:
You can check the State property of the Connection object. It will tell
you whether the Connection is opened or closed.
Hope this helps...
Eric Raskin
ehr@listworks.com
David@iqtexas.com wrote in message <6rultn$7lp$1@nnrp1.dejanews.com>...
>I am new to ADO and need some guidance on setting it up.
>I've included my global.asa and my .asp code.
>For those who don't know perlscript, you should be able to get the syntax
if
>you are familiar with ASP.
>
>How do I know if a connection is made?
>
>The dsn is correct. The database has 24 rows and the user has the
>permissions.
>
>Thanks for any help,
>David
>
>.ASP
>-----
><%
>$Rec=$Conn->Execute("select * from users order by name");
>$Rec->MoveLast();
>$Rec->MoveFirst();
>%>[<%=$Rec->BOF()%>]<br><%
>%>[<%=$Rec->EOF()%>]<br><%
>%>[<%=$Rec->RecordCount()%>]<br>
>
>output
>-------
>[0]
>[0]
>[-1]
>
>Note: result is same even if I don't declare the rec object in global.asa.
>
>GLOBAL.ASA
>-----------
><OBJECT RUNAT=Server SCOPE=Session ID=Conn
PROGID="ADODB.Connection"></OBJECT>
><OBJECT RUNAT=Server SCOPE=Session ID=Rec
PROGID="ADODB.Recordset"></OBJECT>
>
><SCRIPT LANGUAGE=PerlScript RUNAT=Server>
> sub Session_onStart{ $Conn->Open("DSN=x;UID=x"); }
> sub Session_onEnd{ $Conn->Close(); }
></SCRIPT>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
------------------------------
Date: Tue, 25 Aug 1998 18:40:41 GMT
From: briley@manning.com
Subject: Apache Book
Message-Id: <6rv0f9$m75$1@nnrp1.dejanews.com>
Manning Publications Co., a publisher of computer books, is currently
considering publishing a book entitled Extending Apache Web Server. If there
is anyone interested in reviewing the partial or complete manuscript before
the book is published you can contact Brian Riley at briley@manning.com. In
your letter please state a little background information about yourself that
will illustrate why you would make a good reviewer for this book. Please
note that we do not pay honorariums for this service but your comments may be
used for the book cover and if so, they will be properly accredited. Also
each reviewer will receive a free copy of the book upon the completion of the
printing process. Thank You
Brian Riley
Publishing Assistant
Manning Publications Co.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 25 Aug 1998 18:00:24 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Are $a and $b some special variables?
Message-Id: <6ruu3o$2sd$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Russ Allbery
<rra@stanford.edu>],
who wrote in article <m3af4t8lpi.fsf@windlord.Stanford.EDU>:
> > ... which is a long-standing bug in the warn()er. I wonder why nobody
> > would fix it...
>
> Because figuring out whether a routine could have been called from a sort
> routine is impossible in the general case and adding more specific special
> cases just makes the whole situation even more confusing.
But why people think you need to figure this out? A presence of sort
is what is important.
> And besides, like Larry said, it's rather rare for people to typo $a and
> $b.
As you know perfectly, at least this is a very frequent reason for
confusion.
And I do not see why misspelling a letter is less probable if it
preceded by $ and followed by a space (or whatever).
Ilya
------------------------------
Date: Tue, 25 Aug 1998 14:28:42 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: command line switches
Message-Id: <comdog-ya02408000R2508981428420001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6ruqk4$egr$1@oak.prod.itd.earthlink.net>, "Jeff Bailey" <jeff777@earthlink.net> posted:
>I've seen a few ways to handle this with perl and could use any of them but
>was wondering what everyone prefers for handling this in perl.
>Unfortunately at the moment the system administrators aren't allowing the
>perl module that handles this. If anyone knows where the most up to date
>version is maybe I can just drop it into my home directory ;-)
does "this" mean "command line switches"? if so, Getopt::* comes
with the standard Perl distribution. you can also install modules
in your own directories (see the FAQ for details).
perhaps there is another problem?
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 needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Tue, 25 Aug 1998 14:50:57 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
Subject: Re: Counting files in a directory in WinNT
Message-Id: <35E30791.E4C16DB@gusun.georgetown.edu>
This will count all files w/ a certain extension ($file_ext).
For all files simply clip that part.
$file_ext = ".txt";
$inputdir = "/docs/act";
opendir(DIR, $inputdir) || die "Cannot open inputdir $inputdir\n";
@allinfiles = grep(/${file_ext}$/, readdir(DIR));
closedir(DIR);
$num = @allinfiles;
print "Number of files in $inputdir is: $num";
npolonsk@hotmail.com wrote:
> I know that there is probably some simple way to do this, but I can't seem to
> find it for some reason:
>
> I want to count the number of files there are in a directory. I know that if
> I were under UNIX I could simply ready the results of "ls | wc -l". However,
> even with the NT ports of LS and WC I'm having problems.
>
> I'm using a foreach loop to go through an array of directory names.
>
> Can anyone help? There's probably some function that does it, but for some
> reason I can't find it in the FAQ's.
>
> --Nathan
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 25 Aug 1998 12:33:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Counting files in a directory in WinNT
Message-Id: <MPG.104cb15ed68440d99897ea@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35E30791.E4C16DB@gusun.georgetown.edu> on Tue, 25 Aug 1998
14:50:57 -0400, Dave Stephens <stepherd@gusun.georgetown.edu> says...
> This will count all files w/ a certain extension ($file_ext).
> For all files simply clip that part.
>
> $file_ext = ".txt";
> $inputdir = "/docs/act";
>
> opendir(DIR, $inputdir) || die "Cannot open inputdir $inputdir\n";
>
> @allinfiles = grep(/${file_ext}$/, readdir(DIR));
Several problems here, in approximate order:
Good to have the 'die', but it should include the reason, in $!.
The regex will also match 'foo.ztxt' and lots of other things, because
the '.' isn't escaped.
There should be an 'o' suffix lest the regex be recompiled for every
array element.
There should be an 'i' suffix, because on Win32 systems suffixes may show
up in either upper or lower case.
The statement generates an array used only for its size. This should be
done directly by executing 'grep' in scalar context.
The statement will also count directories whose names happen to match the
regex, not just files as requested.
'For all files, clip this part.' will also count all directories,
including the pseudo-directories named '.' and '..'.
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 25 Aug 1998 20:03:40 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: Exporting Methods
Message-Id: <35E37B0C.659A@comenius.ms.mff.cuni.cz>
brian d foy wrote:
>
> In article <r790kdjqbg.fsf@rimbey.cs.ualberta.ca>, Wade Holst <wade@cs.ualberta.ca> posted:
>
> >Mark Simonetti <se96ms@english.iielr.dmu.ac.uk> writes:
> >
> >> I'm currently writing a Perl script which uses classes. Reading a book on
> >> Perl tells me I need to export methods to use them.. yet I don't seem
> >> to have to ? Am I missunderstanding something ? It says I need to use
> >> "Exporter" !
> >
> >You need to 'use Exporter;' because all classes need to have
> >Exporter as a superclass.
>
> well, not all classes necessarily need Exporter. a class needs it
> if it intends to export something though. :)
>
> --
> brian d foy <comdog@computerdog.com>
I even wrote modules that exported functions/variables without using
Exporter. Some of them OO, some of them not.
Exporter is a nice tool for most cases, but sometimes you'll find out
that you have to do it "by hand".
BTW: NEVER EVER export the new() function !!!
I did this mistake when I was young (actualy about 1.25 years ago ;-)
in my Mail::Sender and it made for a lot of problems.
Jenda
------------------------------
Date: Tue, 25 Aug 1998 19:52:51 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: Exporting Methods
Message-Id: <opgww7wkfe4.fsf@harper.uchicago.edu>
Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz> writes:
> BTW: NEVER EVER export the new() function !!!
> I did this mistake when I was young (actualy about 1.25 years ago ;-)
> in my Mail::Sender and it made for a lot of problems.
Umm, why? I 've done it with no problems. Not only that, I can't
think of why you wouldn't export it. But that's me. As the Camel
says, new() is a convention to make C++ programmers (including myself)
thing they know what's going on. What difference does it make if it's
called new() or looky_that_its_an_object()?
--
Peter A Fein Summering in SF!
Home: Work: 650-628-2172
p-fein@uchicago.edu pfein@us.checkpoint.com
Gilette's Razor: The best a man can get.
------------------------------
Date: Tue, 25 Aug 1998 14:57:16 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
Subject: Re: Hacking Schools Network
Message-Id: <35E3090C.595DC423@gusun.georgetown.edu>
Just look for the password on the pull-out table near the principle's
office. What,
haven't you seen WarGames?
doomen@my-dejanews.com wrote:
> <>>>>>>)(>Do anyone know how hack my schools network?
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 25 Aug 1998 13:03:11 -0500
From: Darrell Kachilla <drk@rpisun1.mdacc.tmc.edu>
Subject: help: cpan problems since new perl load
Message-Id: <35E2FC5F.87E5B679@rpisun1.mdacc.tmc.edu>
hi
PROBLEM
since loading new perl with a perfectly working cpan:
This is perl, version 5.005_02 built for sun4-solaris
the cpan module has been acting up.
TYPICAL PROBLEM APPEARANCE
sudo perl -MCPAN -e shell
gives:
cpan shell -- CPAN exploration and modules installation (v1.3901)
ReadLine support enabled
Can't ioctl TIOCGETP: Illegal seek
Consider installing Term::ReadKey from CPAN site nearby
cpan> install Term::ReadKey
CPAN: LWP loaded ok
Fetching with LWP:
http://www.perl.com/CPAN-local/authors/01mailrc.txt.gz
Going to read /home/recon/drk/.cpan/sources/authors/01mailrc.txt.gz
Fetching with LWP:
http://www.perl.com/CPAN-local/modules/02packages.details.txt.gz
Going to read
/home/recon/drk/.cpan/sources/modules/02packages.details.txt.gz
Scanning cache /home/recon/drk/.cpan/build for sizes
There's a new CPAN.pm version (v1.40) available!
You might want to try
install Bundle::CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running...
Fetching with LWP:
http://www.perl.com/CPAN-local/modules/03modlist.data.gz
Going to read /home/recon/drk/.cpan/sources/modules/03modlist.data.gz
Term::ReadKey is up to date.
SO LETS OVERRIDE
cpan> force install Term::ReadKey
Running make for KJALB/TermReadKey-2.12.tar.gz
CPAN: MD5 security checks disabled because MD5 not installed.
Please consider installing the MD5 module.
x TermReadKey-2.12, 0 bytes, 0 tape blocks
x TermReadKey-2.12/Makefile.PL, 955 bytes, 2 tape blocks
x TermReadKey-2.12/ReadKey.pm, 14164 bytes, 28 tape blocks
...
...
String found where operator expected at genchars.pl line 255, near
"CheckStructure "sgttyb""
(Do you need to predeclare CheckStructure?)
syntax error at genchars.pl line 255, near "CheckStructure "sgttyb""
String found where operator expected at genchars.pl line 283, near
"CheckStructure "tchars""
(Do you need to predeclare CheckStructure?)
syntax error at genchars.pl line 283, near "CheckStructure "tchars""
String found where operator expected at genchars.pl line 291, near
"CheckStructure "ltchars""
(Do you need to predeclare CheckStructure?)
syntax error at genchars.pl line 291, near "CheckStructure "ltchars""
Execution of genchars.pl aborted due to compilation errors.
*** Error code 2
AND FOLLOWING OTHER SUGGESTIONS
cpan> install Bundle::CPAN
MD5 is up to date.
Running make for PMQS/Compress-Zlib-1.01.tar.gz
Can't locate auto/MD5/new.al in @INC (@INC contains: /usr/local/lib/perl
/opt2/Mdacc/Perl/sun4-solaris /opt2/Mdacc/Perl
/opt/perl_sitelib/5.005/sun4-solaris /opt/perl_sitelib/5.005
/opt/perl_sitelib/5.005/Tk /usr/local/lib/perl5/5.00502/sun4-solaris
/usr/local/lib/perl5/5.00502
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris
/usr/local/lib/perl5/site_perl/5.005 .) at -e line 2748
the "cant locate" statement is true, since file new.al does not exist on
this conputer.
suggestions???
thanx
------------------------------------------------------------------------
Darrell Kachilla - working but not speaking for...
M.D. Anderson Cancer Center, Diagnostic Imaging -57
1515 Holcombe Blvd., Houston, Tx 77030
drk@rpisun1.mdacc.tmc.edu W: 713-745-2361 FAX: 713-745-0581
http://recon.mdacc.tmc.edu
------------------------------
Date: Tue, 25 Aug 1998 14:44:54 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Ignoring lines in a data file
Message-Id: <m74vr6.stj.ln@metronet.com>
[ please fix your word-wrapping to the usual Usenet standard
of 70-72 character maximum
]
Alan Melton (arm@home.net) wrote:
: example of file:
: 18,August,1998,1002,1,28.25,28.25,Accounting:Conc.+Appl.-Std.Gde.1-14
: 5th 96 New
: I only want to use the files where the fourth or fifth field.etc has a
: value,
: otherwise I want the program to continue reading down to the next line
: to see if
: it fulfills the criteria and so on. If it finds another record with
: data,
: that line should be included.
while (<>) {
print if (split /,/, $_)[3] eq '1002'; # print if the 4th field is 1002
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Aug 1998 19:19:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Inserting into a linked list in a sorted fashion
Message-Id: <6rv2oj$agi$2@client3.news.psi.net>
mlehmann@prismnet.com (mlehmann@prismnet.com) wrote on MDCCCXX September
MCMXCIII in <URL: news:6ruqe4$djb$1@nnrp1.dejanews.com>:
++ What is a good why to implement a linked list such that it is always in a
++ sorted order? I have been using an array for the linked list, finding the
++ insertion point by traversing the list, and then using splice to place the
++ item in the list. This is geometrically in-efficient as the list grows.
Yeah, but it's the same order of complexity as finding the spot where
to insert. Worst case insertion using splice is O (N), worst case time
spotting the place in an linked list where to insert is O (N) as well.
Are you really sure you want to use linked lists?
++ What other types of existing solutions are there for doing this in perl?
Hashes? What do you want to do?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Tue, 25 Aug 1998 12:50:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Inserting into a linked list in a sorted fashion
Message-Id: <MPG.104cb547f4807ba29897eb@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <6rus1e$6h5$2@csnews.cs.colorado.edu> on 25 Aug 1998 17:25:02
GMT, Tom Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, mlehmann@prismnet.com writes:
> :What is a good why to implement a linked list such that it is always in a
> :sorted order?
>
> How many elements do you have? How often do you insert them?
> How often must you process them in a sorted fashion?
>
> First time through, you should just do the dumb and easy thing, sorting on
> demand. If that's good enough, great.
>
> Next time through, if there is one, use the DB_File modules B-tree
> ordered hash bindings. If that's good enough, great.
>
> If all else fails, implement an ordered dynamic set such as you
> might find in any compsci book, such as Cormen et al. I would
> avoid this.
>
> --tom
The following is excerpted from a draft of The Perl Cookbook (which sold
out quickly at the Perl Conference, so I haven't yet seen the final
product):
<quote>
Problem
The keys and each functions give you the hash elements in a strange
order, but you want to get them out in the order you put them in.
Solution
Use the Tie::IxHash module.
... (and on for several paragraphs)
</quote>
How's that for quoting Scripture to the author? :-)
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Aug 1998 12:49:17 -0600
From: snowhare@xmission.xmission.com (Snowhare)
Subject: Re: Looking for Programmer/Job Opp.
Message-Id: <6rv0vd$7cp$1@xmission.xmission.com>
Nothing above this line is part of the signed message.
In article <35E1D562.ECD65498@dead.end.com>, <no.uce@dead.mailbox.com> wrote:
>FixingHole wrote:
>you do know the going rate for custom perl stuff is $50 dollars an hour don't
>you ?
And what color is the sky in your universe?
$50/hour is *seriously* low if your custom Perl programmer knows what they
are doing. Try multiplying that number by 2 or 3 depending on skill and
experience (possibly even more if you have additional requirements like
experience with specific heavy duty databases, additional languages, or
multiple years of web experience). The only people I give $50/hour to is a
20 year personal friend and a sister who also works in the field.
Expert consultants are paid at *much* higher rates than staff. You pay a
premium for not having them on staff and for skills beyond the average.
Remember consultants are independant businesses - complete with overheads
like handling all their own office costs, hardware, software, taxes,
insurance, marketing, and bidding.
Benjamin Franz
Version: 2.6.2
iQCVAwUBNeMHJujpikN3V52xAQEOnQQAoJLuruECqtw3R18WKYqQ8T7u46dtDmWo
u3SZMU5vg+Ie15f83SwnDoElqHhoqM/8oD6+0AsiuuLo+2xZIc/ZQ8PYFUpgGurQ
moS8uKGSY/nDtYEwtph6ERScyAFcBZ8Sqmz42ikwDhRKeV+Ez4FzUh82c9n2g4Yc
XsxpRcCxccA=
=nkJt
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 25 Aug 1998 18:16:26 GMT
From: thumper@webthumper.com
Subject: Multiple SIG handles?
Message-Id: <6ruv1q$k20$1@nnrp1.dejanews.com>
I am trying to port a C shell script to perl and I can't figure out how to
get the SIG handlers to work the way I want. Below is a sample of a C shell
script that I want to port to perl:
#!/bin/csh -f
onintr cntl_c
echo "this is a test script"
while( 1 )
echo "waiting..."
sleep 2
end
exit
cntl_c:
onintr cntl_c_again
echo "someone didn't want to wait...too bad..."
while( 1 )
echo "waiting..."
sleep 2
end
exit
cntl_c_again:
onintr
echo "OK, fine then...exiting"
exit
What the above does it reset the SIGINT (cntl-c) to different branches with
the onintr (on interupt). The first onintr says to branch to cntl_c label
when someone does a cntl-c, then resets this with another onintr that says to
branch to cntl_c_again when someone presses cntl-c again.
I have tried to do this in perl, but the second cntl-c does not get caught.
Below is the code that I have been working with:
#!/usr/local/bin/perl
$SIG{INT} = \&cntl_c1 ;
while( 1 ) {
print "waiting...\n" ;
sleep 2 ;
}
exit ;
sub cntl_c1 {
$SIG{INT} = \&cntl_c2 ;
print "caught cntl-c...\n" ;
while( 1 ) {
print "waiting...\n" ;
sleep 2 ;
}
}
sub cntl_c2 {
print "caught cntl-c again...\n" ;
exit ;
}
Does anyone have experience in this area? I have checked the FAQ about
Signals and there are no examples about this kind of interupts. I recently
got the Perl Cookbook from the Perl Conference and it basically has the same
examples.
Thanks for any help.
Please respond to email along with this news group...my news feed is
unreliable and I would hate to miss the answer to this important issue...at
least it is to me and my job! :-)
Scott Dinn
sdinn@interlink.com http://www.interlink.com
thumper@webthumper.com http://www.webthumper.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 25 Aug 1998 14:37:48 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Pattern match for filename extensions
Message-Id: <cq3vr6.usj.ln@metronet.com>
Ryan Cook (rcook@stnc.com) wrote:
: The pattern match will reside inside the
: "wanted{ }" subroutine and needs to be able to simuultaneously match a range
: of filename extensions stored in an array such as:
: @ftypes = (".txt", ".exe", ".doc", ".pl", ".bat");
1) Perl FAQ, part 6:
"How do I efficiently match many regular expressions at once?"
2) perldoc -f quotemeta
3) use $ to match end of string, as described under the heading
"Regular Expressions" in the 'perlre' man page.
or, if you don't care to become a better Perl programmer:
--------------------
#!/usr/bin/perl -w
@ftypes = qw( txt exe doc pl bat);
$extensions = join '|', reverse @ftypes;
while (<DATA>) {
print if /\.(?:$extensions)$/;
}
__DATA__
foo.document
foo.doc
foodoc
foo.doc.nope
bar.txt
bar.pl
bar.play
--------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Aug 1998 18:41:48 GMT
From: NOjcjSPAM@mail.med.upenn.edu (Mr. Mirthful)
Subject: Perl - Internal Server Error in Unix
Message-Id: <35e3020d.103063457@uphs1>
I get the following error when trying to run a perl script (located at
bottom of e-mail) from a Unix server. Other Perl Scripts are running
fine, so the server is configured correctly. The Perl script was
created to run from an NT server (and works fine in that scenario), so
i do not know if any of the commands would not work from Unix.
------------------------------
The error is:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, root@localhost and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.
---------------------------------
The Perl Script:
#!/usr/local/bin/perl
# reads value from button clicked
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# opens file results.txt to store values
open (APPEND, ">>results.txt") || die ("Cannot open file.");
#translates buffer into numerical name of yes or no button (i.e. 1 or
0)
$var = $buffer;
# strips $var to a number
$var =~ tr/0-9//cd;
#adds value to results.txt
if ($var ne "") {
print APPEND ("$var\n");
}
close (APPEND);
#opens results.txt to calculate percentage
open(FILE, "results.txt") || die ("Cannot open file.");
$all=0;
$total=0;
$filetotal = <FILE>;
# prevents division by zero by making $all = 1 when results.txt is
empty.
if ($filetotal eq ""){
$all=1;
}
while ($filetotal ne "") {
$total += $filetotal;
$all++;
$filetotal= <FILE>;
}
$percent = ($total/$all) * 100;
close (FILE);
print "Content-type: text/html\n\n";
# changes directory to the folder with the html files.
$dir ="/cgi-bin/";
chdir ($dir);
# open output file
open(GETPERCENT, "percent.html") || die ("Cannot open file
percent.html");
$line=<GETPERCENT>;
while ($line) {
# Replaces occurrence of ##percent## with the percentage value
$line =~ s/ 0/ $percent/;
print ("$line");
$line=<GETPERCENT>;
}
Thanks for any help.
-Jerrold
jcj@mail.med.upenn.edu
--remove NOSPAM to reply
--
My Father Always Believed That | I want | The Acquisition
Laughter Was The Best Medicine, | to | of Information
I Guess That's Why Several Of | believe. | is an Advantageous
Us Died Of Tuberculosis! :^) | - X-Files | Expedition.
http://mail.med.upenn.edu/~jcj
------------------------------
Date: 25 Aug 1998 18:44:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl CGI Question
Message-Id: <6rv0me$a81$1@client3.news.psi.net>
Sherm Pendley (grinch@whoville.com) wrote on MDCCCXX September MCMXCIII
in <URL: news:35eceae8.22332146@news.shore.net>:
++ On 16 Aug 1998 08:18:00 GMT, abigail@fnx.com (Abigail) wrote:
++
++ >pages are optimized for the Viola browser?
++
++ I remember a browser called Cello, is Viola related?
++
I don't think so. Cello was a line mode browser, IRC. Viola had tables,
style sheets and scripts, back in 1994. Before the first public Netscapes.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3538
**************************************