[6353] in Perl-Users-Digest
Perl-Users Digest, Issue: 975 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 19 16:27:20 1997
Date: Wed, 19 Feb 97 13:00:20 -0800
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, 19 Feb 1997 Volume: 7 Number: 975
Today's topics:
Re: $! Error Handling (Charles DeRykus)
Can I set s/// with different switches determined at ru <cherold@pathfinder.com>
Re: debugging perl & html <Brian.Ewins@gssec.bt.co.uk>
Re: debugging perl & html <larry@ldis.com>
Re: debugging perl & html <sanford@halcyon.com>
Re: Exemples de petits prog. en perl ? <csc80@amdahl.com>
Re: Exemples de petits prog. en perl ? <csc80@amdahl.com>
How to convert tab delimited file to space delimited fi <jlowens@ptconnect.infi.net>
NDBM limitation <dgl@offis.lu>
New WebTechniques and UnixReview columns on-line <merlyn@stonehenge.com>
Newbie ODBC module question <john.oharra@transquest.com>
Re: OK I know that I am a newbie But I need HELP!! (Kevin Buhr)
Re: Passing command line parameters (Dave Thomas)
Re: Perl on Microsoft IIS, NT Server 4.0 (Rasilon)
Re: Perl on Windows 95 <hanklem@ibm.net>
Re: PerlWin32-95:Yes-NT4:No ("John Dallman")
Re: Problems with -l (Peter Scott)
Re: PSCOPE - an CSCOPE for perl source mlehmann@prismnet.com
sleep() problems (Diego Cimaroa)
trouble with 'use strict' and 'require package.pl' (Kenneth W. Lee)
Re: valid URL regexp (Abigail)
Re: Why doesn't gethostbyaddr return a value? <matti-hu@dsv.su.se>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Feb 1997 19:10:37 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: $! Error Handling
Message-Id: <E5v6Lq.9BL@bcstec.ca.boeing.com>
In article <3304EDAD.2C03@Sun.COM>,
Geoff Halliwell <geoffrey.halliwell@Sun.COM> wrote:
>
>How do you capture $! in a numeric context
>when opening a file?
>
> open(LOG, /unknown_dir);
>
>Or is there a better why to manage error
>handling?
Yes, reading $! in a string context is much easier :)
open(LOG, /unknown/dir) or die "open: $!";
One way to get numeric context:
open(LOG, /unknown/dir) or die "failed: ",int $!,"\n";
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: Wed, 19 Feb 1997 13:32:28 +0000
From: Charles Herold <cherold@pathfinder.com>
Subject: Can I set s/// with different switches determined at runtime?
Message-Id: <330B00EF.2990@pathfinder.com>
I have a simple little script that changes one phrase to another in a
file. I'd like to allow the user to use command line switches and then
ad them to the substitution string. What I tried as an experiment,
which didn't work but which shows what I wanted to do, is this:
$switches = "gi";
$text =~ s/$search/$replace/$switches;
I was hoping that would give me s/$search/$replace/gi, but it doesn't,
as I'm sure you all know.
Is there a way to do this?
--
Best regards,
Charles Herold
cherold@pathfinder.com
(212) 522-5190
------------------------------
Date: Wed, 19 Feb 1997 18:11:56 +0000
From: Brian Ewins <Brian.Ewins@gssec.bt.co.uk>
Subject: Re: debugging perl & html
Message-Id: <330B426C.68F3@gssec.bt.co.uk>
Jot Powers wrote:
>
> In article <cuttE5tA4E.5vM@netcom.com>, cutt@netcom.com (Paul S. Cutt) writes:
> >I wonder what people are using to debug perl scripts when called from an
> >html page ? I know about perl debugger but this is run from the
[snip]
>
> (In conjunction with that, we watch the log files of the server and see
> why it is dying).
[snip]
Here, so many people were writing buggy perl CGI that the logfile
filled up and that server crashed :o(...
So I got people to do this:
#!/usr/local/bin/perl
$SIG{__WARN__}=sub { die @_ };
eval <<END_CGI_SCRIPT;
#script goes here
END_CGI_SCRIPT
$@ && print << END_HTML;
Content-type: text/plain
Perl died with errors:
$@
$!
END_HTML
This is especially useful when people don't even bother
to check if the syntax of the perl is ok before trying it
from the page. It would be nice if there was a cgidebug
module which provided a forms based interface to the
cgi script *through the debugger*.
I'm sure someone else has tried this....
Cheers,
Baz
------------------------------
Date: Thu, 20 Feb 1997 14:55:58 -0500
From: Larry Glenn <larry@ldis.com>
Subject: Re: debugging perl & html
Message-Id: <330CAC4E.75D2F3FF@ldis.com>
Here's my approach to the same problem:
packge WebDebug;
# uid that the http server is running as
my $www = 1132;
BEGIN {
if($< == $www) {
$::SIG{'__DIE__'} = sub { print "<H2>FATAL
ERROR:</H2>\n$_[0]\n"; die; };
$::SIG{'__WARN__'} = sub {
push(@WebDebug::ERRORS,$_[0]); };
}
}
END {
$" = "<LI>\n";
@WebDebug::ERRORS && print qq|\n<H2>Non-Fatal
Errors:</H2>\n<OL>\n<LI>@WebDebug::ERRORS\n<\OL>|;
}
1;
I just stuck this in a module, and now all I have to do is say
use WebDebug;
at the beginning of my scripts. If I'm writing something that needs to
have a BEGIN or END routine, I just copy and paste the WebDebug routines
into the script and then edit them. Everything gets spit out nice and
prettily at the bottom of the page. When I'm done debugging, I just
comment out the use line, and any problems that, uh, spontaneously
develop later on go back into the error log.
You do have to make sure that you print a header just about as soon as
the script starts, though.
It seems to work pretty well, but I'd appreciate any comments.
Larry Glenn
Brian Ewins wrote:
>
> Here, so many people were writing buggy perl CGI that the logfile
> filled up and that server crashed :o(...
>
> So I got people to do this:
> #!/usr/local/bin/perl
>
> $SIG{__WARN__}=sub { die @_ };
>
> eval <<END_CGI_SCRIPT;
>
> #script goes here
>
> END_CGI_SCRIPT
>
> $@ && print << END_HTML;
> Content-type: text/plain
>
> Perl died with errors:
> $@
> $!
> END_HTML
>
> This is especially useful when people don't even bother
> to check if the syntax of the perl is ok before trying it
> from the page. It would be nice if there was a cgidebug
> module which provided a forms based interface to the
> cgi script *through the debugger*.
>
> I'm sure someone else has tried this....
>
> Cheers,
> Baz
------------------------------
Date: 19 Feb 1997 13:06:56 -0700
From: Sanford Morton <sanford@halcyon.com>
Subject: Re: debugging perl & html
Message-Id: <m33euso90f.fsf@darkstar.frop.org>
cutt@netcom.com (Paul S. Cutt) writes:
> I wonder what people are using to debug perl scripts when called from an
> html page ? I know about perl debugger but this is run from the command
> line. If my html page calls my perl script how can I get the debugger at
> that point to execute so I can continue debugging ?
If you are running a web server locally (eg, I run a development
server on a Linux machine) it is possible to get the server to launch
an xterm with the perl debugger in it. I haven't tried this with a
remote server. It works with CGI.pm or cgi-lib.pl (using their ability
to read form data on the command line) and with methods GET or
POST. It does not work with multipart form data (eg, file upload).
This really does save a lot of typing time if you've got complicated
forms with lots of data that needs to be tested, or especially
sequential forms that preserve state. I seem to be doing a lot of that
recently.
Now, what I'd really like to do is launch this into Xemacs using
gnuserv. Suggestions very welcome.
Here's how to do it: in your cgi script, you'll have something like
#!/usr/bin/perl -Tw
use strict;
use CGI; # also works with cgi-lib.pl
unless ($ENV{DEBUG} eq 'off') { # add this near the top
&debug_launch; # of your cgi script
} # to launch the debugger early
$q = new CGI;
... etc ...
Then include the following somewhere, perhaps as:
require './cgi-debug.pl';
sub debug_launch {
my ($script);
# For methods POST and GET, read in all the form data.
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
$_ = join ('', <STDIN>);
} elsif ($ENV{'REQUEST_METHOD'} eq 'GET') {
$_ = $ENV{'QUERY_STRING'};
} else {
print "Content-type: text/html\n\nThis debugging
technique only supports POST or GET";
exit;
}
# Turn DEBUG off so debugger won't execute this block of code
# and run another dubugger
$ENV{'DEBUG'}='off';
# Turn REQUEST_METHOD off so cgi-lib.pl will use command line
# debugging mode. Needed for the debugger and also after this block.
# Then separate the form data into distinct arguments
$ENV{'REQUEST_METHOD'}='';
s/&/ /g;
# Get file name without path. Without a path, the pwd of the debugger
# will be the script's directory. This is useful to find relative
# libraries or modules. Also remove query string and path info,
# which will be passed in the environment.
$script = $ENV{'SCRIPT_FILENAME'};
$script =~ s/\?$ENV{'QUERY_STRING'}$// if $ENV{'QUERY_STRING'};
$script =~ s/$ENV{'PATH_INFO'}$// if $ENV{'PATH_INFO'};
$script =~ s#.*/([^/]*)$#$1#;
# Launch an rxvt with perl -d in it on this file.
# Pass space-separated form data as command line arguments.
system "/usr/X11R6/bin/rxvt -e perl -d $script $_";
# When debugger is finished, allow the rest of the script
# to continue. Set the form data in @ARGV so it will think
# it's reading data from the command line.
@ARGV = split (/ /);
}
--------
Sanford Morton, Ph.D. CGI Resources
sanford@halcyon.com http://www.halcyon.com/sanford/cgi/
------------------------------
Date: Wed, 19 Feb 1997 19:06:53 GMT
From: "Carol C. Kankelborg" <csc80@amdahl.com>
Subject: Re: Exemples de petits prog. en perl ?
Message-Id: <330B4F4D.41C67EA6@amdahl.com>
Dominique BAGOT wrote:
>
> Bonjour a tous,
>
> connaissez-vous un (des) sites ayant des programmes
> ecrits en perls a des fins pedagogiques. J'ai fait du perl il y a
> assez longtemps et j'aimerais m'y remettre rapidos a l'aide
> de petits exemples.
>
> Merci, Dom
>
> Dominique.BAGOT@cetp.ipsl.fr
Here is a translation:
Hello to all,
Do you know of one or many sites which have programs written
in Perl for teaching purposes. I used Perl a long time ago and
would love to relearn it quickly with the help of short examples.
Thank you, Dom
--
**********************************************************************
*** Carol C. Kankelborg csc80@amdahl.com ***
*** Amdahl Corporation The above opinions are uniquely mine. ***
**********************************************************************
------------------------------
Date: Wed, 19 Feb 1997 19:37:21 GMT
From: "Carol C. Kankelborg" <csc80@amdahl.com>
To: Dominique BAGOT <Dominique.BAGOT@cetp.ipsl.fr>
Subject: Re: Exemples de petits prog. en perl ?
Message-Id: <330B5671.167EB0E7@amdahl.com>
Dominique BAGOT wrote:
>
> Bonjour a tous,
>
> connaissez-vous un (des) sites ayant des programmes
> ecrits en perls a des fins pedagogiques. J'ai fait du perl il y a
> assez longtemps et j'aimerais m'y remettre rapidos a l'aide
> de petits exemples.
>
> Merci, Dom
>
> Dominique.BAGOT@cetp.ipsl.fr
Je ne sais pas si vous connaissez anglais, donc je raconterai
les postes qui repondent a votre question. Je vous demande pardon
que je ne sais pas comment ajouter des accents francais dans le web.
------------------------------
nvp@shore.net (Nathan V. Patwardhan) repond avec quelques sites
qui puisse vous aidez:
http://www.perl.com/perl -> pursuite des "links" a voir
la documentation.
http://www.yahoo.com -> Pour chercher documentation pour Perl.
http://www.dejanews.com -> Pour cherches dans les vieux articles
de ce "newsgroup".
---------------------
Douglas Seay <seay@absyss.fr> repond:
Le "camel" (Le livre "Programming Perl" ou "Programmation en Perl"
qui a un dessin d'un chameau (c'est "camel" en anglais) sur le
couverture) a beaucoup de bons exemples, avec commentaire.
Il a achete son edition chez Le Monde En Tique, qui est dans le
5eme, en face de l'ile St. Louis. Il y a un Web Page
http://www.lmet.fr/.
[LI] PROGRAMMING PERL 2ED
WALL - O'REILLY - 259 FF - Disponible la librairie
ISBN : 1-56592-149-6
[LI] PROGRAMMATION EN PERL 2ED
WALL - ITPS - 280 FF - Disponible chez l'diteur
ISBN : 2-84177-004-4
---------------------------
Moi, j'ajouterais que la premiere edition du livre "camel" (chameau)
a une section de programmes completes qui n'existe pas dans la
deuxieme edition. Il me semble que le livre "camel" aie ete traduit
en francais parce que Le Monde En Tique liste "Programming Perl" et
"Programmation en Perl."
Malheuresement, la plupart des sites pour Perl sont en anglais.
Je ne sais pas quand vous avez apris Perl autrefois, mais il y a
beaucoup de nouvelles choses dans la langue des Perl 5. (La
premiere edition du livre "camel" c'est seulement pour Perl 4.
J'ai apris Perl pour le livre "camel" il y a quelques mois. C'est
un bon livre et une tres bonne reference pour la langue.
Bonne chance.
-----------------------------
(Voila ma traduction de cette poste:)
And for the franco-phonally challenged:
I translated the gist of Nathan and Douglas' posts. Then I added:
I would add that the first edition of the Camel has a section of
complete programs which isn't in the second edition. I think the
Camel (2nd) edition has been translated into French because the
Monde En Tique site lists both a French and an English title.
Unfortunately, most Perl sites are in English. I do not know when
you first learned Perl, but there are a lot of new things in the
language since Perl 5. (The first edition of the camel only
covers Perl 4.) I learned Perl from the Camel book a few months
ago. It is a good book and a very good language reference.
Good luck.
--
**********************************************************************
*** Carol C. Kankelborg csc80@amdahl.com ***
*** Amdahl Corporation The above opinions are uniquely mine. ***
**********************************************************************
------------------------------
Date: Wed, 19 Feb 1997 10:49:09 -0800
From: "Jack L. Owens" <jlowens@ptconnect.infi.net>
Subject: How to convert tab delimited file to space delimited file
Message-Id: <330B4B25.5236A689@ptconnect.infi.net>
I have several tab delimited ASCII files that I need to convert to fixed
length space delimited fields. Some of the fields consist of multiple
words. Is there an easy way to do this using Perl?
--
Jack L. Owens General Engineering Contractor
4421 Myrtle Avenue Retired
Long Beach, California 90807 K6PWY
(562)989-9413 jowens@csulb.edu
------------------------------
Date: Wed, 19 Feb 1997 18:57:20 -0500
From: David Gallone <dgl@offis.lu>
Subject: NDBM limitation
Message-Id: <330B9360.510C@offis.lu>
Hi,
Here is an extract from NDBM man pages (on SINIX).
> The sum of the sizes of a key/content pair must not exceed the
> internal block size (currently 4096 bytes). Moreover all key/content
> pairs that hash together must fit on a single block. dbm_store will
> return an error in the event that a disk block fills with inseparable
> data.
This seems to be a very hard constraint making NDBM of little use for
real applications.
Is there a work around ?
Thanks,
David GALLONE
+------------------------------------------------------+
| David GALLONE email : dgl@offis.lu |
| |
| OFFIS S.A. tel : (+352) 422790-32 |
| Bld Prince Felix, 63 fax : (+352) 423185 |
| L-1513 Luxembourg |
| LUXEMBOURG http://www.offis.lu/ |
+------------------------------------------------------+
------------------------------
Date: 19 Feb 1997 12:02:09 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: New WebTechniques and UnixReview columns on-line
Message-Id: <8cohdg8vri.fsf@gadget.cscaper.com>
(No, I haven't stopped writing for WebTechniques... I just missed a
deadline in December... :-)
I've placed online columns 12 and 13 in my bi-monthly series appearing
in Unix Review magazine.
Column 12 is about "here documents", and column 13 is the first of
a two-parter on a gentle introduction to objects (written before Tom
wrote perltoot, honest! :-).
I've also placed online columns 10 and 11 in my monthly series
appearing in WebTechniques magazine. (Well, *nearly* monthly. :-)
Column 10 is about parsing the 404-error log, picking up bad links,
and column 11 is a fully-functional web proxy *anonymizer* written in
about 100 lines of Perl.
Many people have asked for the WebTechniques programs to be available
for separate download (because they can't cut-n-paste from their
browser, I guess), so I've also extracted those separately.
These columns are available at:
http://www.stonehenge.com/merlyn/UnixReview/
http://www.stonehenge.com/merlyn/WebTechniques/
Please remember that these items are not mine to give away -- I
republish them in a very limited fashion with the express permission
of the copyright owner, Miller-Freeman, Inc. So, don't mirror them or
steal from them. Thanks. And buy the magazines, or at least write
them a thank-you note.
As always, if you like what you are reading for free, consider buying
Unix Review or WebTechniques or a Llama or Camel book. You could also
make a donation to my legal defense fund (pointers on the webpage).
--
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: Wed, 19 Feb 1997 15:07:22 -0500
From: "OHarra, John" <john.oharra@transquest.com>
Subject: Newbie ODBC module question
Message-Id: <330B5D7A.6608@transquest.com>
I installed the ODBC module per the instructions, downloaded the new
ODBC drivers from Microsoft and the latest version of PERL, and when I
run the TEST.PL script, I get the following error:
Error: Parse exception
Where did I go wrong?
John OHarra
TransQuest, Inc.
mailto:john.oharra@transquest.com
------------------------------
Date: 19 Feb 1997 12:36:59 -0600
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: OK I know that I am a newbie But I need HELP!!
Message-Id: <vbazpx0iqwk.fsf@mozart.stat.wisc.edu>
Randal Schwartz <merlyn@stonehenge.com> writes:
>
> What? Asking me to solve the halting problem now? :-)
Well, if it can be solved, it's bound to be shorter in Perl.
Kevin <buhr@stat.wisc.edu>
------------------------------
Date: 19 Feb 1997 17:49:20 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Passing command line parameters
Message-Id: <slrn5gmf3v.ifh.dave@fast.thomases.com>
On Wed, 19 Feb 1997 12:30:38 -0500, Joe Tseng <jtseng@wauug.erols.com> wrote:
> I checked with my blue camel book but I could not find the answer.
>
> I would like to know if there is any way to pass any parameters to a
> script directly on the command line.
Have a look at ARGV documentation. Then have a look at the various GetOpt::
packages that make it easy to use.
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Wed, 19 Feb 1997 18:59:45 GMT
From: Rasilon (Rasilon)
Subject: Re: Perl on Microsoft IIS, NT Server 4.0
Message-Id: <330b49af.11904094@news.mnsinc.com>
On Mon, 17 Feb 1997 12:45:19 +0100, Steinar Moen <stemo@powersim.no>
wrote:
>Ben Mehling wrote:
>> To invoke the .dll without having the "Save as..." dialog appear you
>> need to help perl out. Make sure to print the appropriate headers:
>>
>> "HTTP/1.0 200 OK\nContent-type: text/html\n\n";
>>
>Thank you, Ben!
>I have tried this, but still I'm getting the "Save as..." dialog.
>The script http://www.powersim.no/cgi-bin/hello.pl has the following
>content:
>
>print "HTTP/1.0 200 OK\nContent-type: text/html\n\n"
>print "<HTML>\n";
>print "<HEAD>\n";
>print "<TITLE>Hello World</TITLE>\n";
>print "</HEAD>\n";
>print "<BODY>\n";
>print "<H4>Hello World</H4>\n";
>print "<P>\n";
>print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
>print "<P>";
>print "<H5>Have a nice day</H5>\n";
>print "</BODY>\n";
>print "</HTML>\n";
>
>Still it doesn't go directly to the browser. Do anybody see any reason
>for this?
>If I accept to download the file, it contains my IP-number, as the
>script should display.
>
>Kind regards, Steinar Moen
I had this exact same problem whenever one of my scripts was being
used by a user with Netscape navigator. Users with Internet Explorer
didnt have a ny problem. I finally figured out that Netscape comes
with a pre-defined helper app setting for anything ending in .pl
I got round the problem by changing so that all my scripts now end in
.cgi
Im sure there is a better solution, but I do recall reading somewhere
that netscape expects scripts to be .cgi
Whenever I try to include the print of the Content-type line, I just
get it output by the browser... not at all what I intended.
------------------------------
Date: Wed, 19 Feb 1997 12:26:54 -0700
From: Hank LeMieux <hanklem@ibm.net>
To: Mark Perry <mdperry@cougar.netutah.net>
Subject: Re: Perl on Windows 95
Message-Id: <330B53FE.872@ibm.net>
Mark,
You wrote,
> I would like to also see how it works by loading the page into Netscape
> locally and then running the script (like it would on a server). Is
> this possible. When I tried clicking on the button that calls the
> script nothing happened.
Well, here are two options:
1)Use Netscape's File|Open command to directly open the script. When
netscape says it doesn't know what to do with the file, tell it to open
it with the script interpreter (ie: if you're using perl, tell it to use
perl.exe as the helper.) All this will do is have Netscape open the perl
command window and run the script every time you open a .pl file. This
won't emulate what the script will do on the server.
2) Install a server on your machine and run it locally. That's how I
test my scripts.
Hank
--
Hank LeMieux
Freelance Web Design/JavaScript/CGI
Santa Fe, NM, USA
(505) 986-8166
http://members.aol.com/HankWeb/
------------------------------
Date: Wed, 19 Feb 1997 19:24:01 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Re: PerlWin32-95:Yes-NT4:No
Message-Id: <E5v781.45n@cix.compulink.co.uk>
Mj Smith <mjsmith@isr.umd.edu> wrote:
> Simply, I want to delete all the files in a particular directory. So, I
> used the glob <*.*> to select all the files. This worked just find
> under Win95. But, as soon as I try it in NT4Wkstn (I logged on as full
> administrator), the same exact set of lines, give me an error as soon as
> I reach the glob. The error states roughly, that "the name specified is
> not recognised as an internal or external program, function...".
Two things to check:
* I think that the ActiveWare Win32 Perl uses a separate program, called
perlglob.exe, or something like it, to expand globs. Check that the
directory with perl.exe is in your PATH, and that perlglob is there.
* I've had trouble with this construct under NT 3.51. It seem to work
better as
@files = <"*.*">;
John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked:
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, BigPerl
for MS-DOS can be found in CPAN via http://www.perl.com, Perl for NT/Win
95 can be found at http://www.activeware.com, with an excellent FAQ file
at http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html and
no, I don't have the slightest idea what's wrong with your CGI script.
------------------------------
Date: 19 Feb 1997 17:34:25 GMT
From: pjscott@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: Problems with -l
Message-Id: <5efdj1$le7@netline-fddi.jpl.nasa.gov>
In article <slrn5gl0r5.fo3.dave@fast.thomases.com>, dave@fast.thomases.com (Dave Thomas) writes:
> On 18 Feb 1997 19:27:37 GMT, Peter Scott <pjscott@euclid.jpl.nasa.gov> wrote:
> > I'm confused. Maybe I don't understand the ramifications of -l.
> > Running the following script:
> >
> > #!/usr/local/bin/perl -wnl
> > if (/,/) {
> > print "foo";
> > } else {
> > print "bar";
> > }
> >
> > produces:
> >
> > euclid% echo "cat,dog" | /tmp/foo
> > bar,bar,euclid%
>
> > Under debugger
> > foo
>
> Any chance the Perl in /usr/local/bin isn't the same as your default Perl? I
> get "foo\n" both times. If nothing else, you should be getting a newline
> after each print statement, which your don't seem to be.
No, but I have discovered something else. If I run it under the
debugger by putting "d" at the end of the #! line and executing the
resulting script with the "echo" pipeline above, then it still prints
out "bar,bar,"; it goes around the loop twice and sees $_ as first "cat,"
then "dog\n,".
If I run it under the debugger by doing
echo "cat,dog" | /usr/local/bin/perl -d /tmp/foo
then it prints out "foo".
If I run it under the debugger by doing
echo "cat,dog" | /usr/local/bin/perl -wnld /tmp/foo
then we're back to "bar,bar,"
Either this is a bug, or I really have no clue what I'm doing.
It looks as though somehow it's getting "," as the record separator...
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (Peter.J.Scott@jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: Wed, 19 Feb 1997 13:01:32 -0600
From: mlehmann@prismnet.com
Subject: Re: PSCOPE - an CSCOPE for perl source
Message-Id: <856378708.26721@dejanews.com>
Tom,
CSCOPE is a code scoping database. It is probably a descendant of grep.
It creates a database of qualities of the code. Specifically it provides
the
following features:
Find a symbol in all of the source files
Finding a definition of a variable, function
Finding functions called by a certain function
Finding functions calling a certain function
Finding assignments to a variable
Global changing a regular expression throughout the code
Finding a regular expression throughout the code
Finding a particular file
Finding files #including a certain file
At first this may seem silly, but it comes in very handy when one
inherits
code. I do most of this now with the egrep command. However it would be
nice to have all of this information compiled into a quickly parsable
database. Also, I find interesting contructs like:
#file: client-file.pl
$BASE='/base'
$NETBASE="$BASE/network"
$NETLIB="$NETBASE/lib"
require("$NETLIB/myinclude");
use "$NETLIB/my-private-module.pm";
It would be nice to know that client-file.pl is including
"/base/network/lib/myinclude" and using
"/base/network/lib/my-private-module.pm". Right now greping through the
code is not very good on these types of files.
CSCOPE is best used on bad code. Good code lends itself to being well
contained with convenient and obvious boundaries. I have yet to inherit
any of that type of code.
>>>>> "TP" == Tom Phoenix <rootbeer@teleport.com> writes:
TP> On 3 Feb 1997, Mark A. Lehmann wrote:
>> Subject: PSCOPE - an CSCOPE for perl source
>> I've requested this many times and no one has offered any solution,
>> code, or really any suggestions for this, so I'm going to write one.
TP> That's the spirit!
TP> What is it?
TP> -- Tom Phoenix http://www.teleport.com/~rootbeer/
TP> rootbeer@teleport.com PGP Skribu al mi per Esperanto!
TP> Randal Schwartz Case: http://www.lightlink.com/fors/
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 20 Feb 1997 05:09:23 GMT
From: cimarosa@mbox.vol.it (Diego Cimaroa)
Subject: sleep() problems
Message-Id: <5efmm4$3a@everest.vol.it>
I wrote a client/server application using perl 4.0 on SCO/Unix 2.0
systems ... old but true !
The problem arise in some of the clients on a WAN (15 nodes at all).
The purpose of the client is to wait some times looking for a file
transmitted via FTP, and, once arrived, update a local DB.
The code is :
#!/usr/local/bin/perl
&SetUp; first time initialization
while(1){
if( -s "/usr/tmp/DBFILE.Z"){
&UncompressFIle;
&DoLocalUpdate;
&SendAck;
}else{
&WriteLog("Waiting for DB file");
sleep(60);
}
}
exit;
....
submited from a 'C' shell using : /usr/diego/dbclient.pl &
The problems arise "randomly" in some of the nodes. Most of time it
works perfectly for days and days but sometimes the process die
without any message ... the last line of the log file is "Waiting for
DB file".
Is possible to trace the exit status of the process ?
Any suggestion ?
I am a novice in this language ... and also on Unix systems ...
I've read a lot of man pages but with no result.
Please, HELP !!
Diego Cimarosa
------------------------------
Date: 19 Feb 1997 13:59:59 -0500
From: kenlee@congo.morgan.com (Kenneth W. Lee)
Subject: trouble with 'use strict' and 'require package.pl'
Message-Id: <kenlee.856378724@congo>
Hi,
I'm trying to pass in two parameters to my foobar.pl from the command line
using 'use strict' and some 'require PACKAGE.pl'. Without going into
the gory details of how PACKAGE.pl works, it simply takes in parameters
like "in=FOO" and "out=BAR" and returns $opt_in and $opt_out containing
the values "FOO" and "BAR", like so:
--- CUT ---
#!/usr/local/bin/perl5
use strict;
require "PACKAGE.pl";
# Main
{
my $rc = &getStuff('in=s','out=s');
my $in = $opt_in;
my $out = $opt_out;
print "in=$in out=$out\n";
}
--- CUT ---
But when I invoke the script I get the following error message:
$ foobar.pl -in FOO -out BAR
Global symbol "opt_in" requires explicit package name at foobar.pl line 10.
Global symbol "opt_out" requires explicit package name at foobar.pl line 11.
Execution of foobar.pl aborted due to compilation errors.
$
The code runs fine without 'use strict' but is there a way
of getting this to work with strict? Perhaps using my() or
(de)referencing?
Thanks in advance,
--
Ken
--
------------------------------
Date: Wed, 19 Feb 1997 18:05:43 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: valid URL regexp
Message-Id: <E5v3LK.FJ6@nonexistent.com>
On Tue, 18 Feb 1997 10:51:26 -0500, brian d foy wrote in comp.lang.perl.misc:
++ In article <330A3C26.5236009A@plains.nodak.edu>, Darin Hawley
++ <dhawley@plains.nodak.edu> wrote:
++
++ > A while back I remember seeing a huge regexp for a valid URL, as well as
++ > a more modularized version for validating a given string as a URL. I've
++ > looked around in libwww.pl for an easy way of doing this without
++ > success. I've been hard pressed to find any examples laying around
++ > either. If anyone has a good answer, please post it. This would also
++ > make a good addition to the FAQ. Thanks...
<URL: http://www.ny.fnx.com/abigail/Perl/url.html>
Abigail
------------------------------
Date: Wed, 19 Feb 1997 19:31:57 +0100
From: Matti Hultstrand <matti-hu@dsv.su.se>
To: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: Why doesn't gethostbyaddr return a value?
Message-Id: <330B471D.1E3D@dsv.su.se>
Russ Allbery wrote:
>
> [ Posted and mailed. ]
>
> Matti Hultstrand <matti-hu@dsv.su.se> writes:
>
> > The problem is that gethostbyaddr doesn't return any value in my script.
> > I use it like this: $hostname = gethostbyaddr($ipaddr, AF_INET); Why
> > doesn't that work?
>
> Are you sure that you can resolve those addresses? Maybe their name
> resolution is broken. Can you get a name back using host or nslookup?
Yes, running "nslookup 199.45.129.30" from the prompt gives me the host
name "perl.com" (also works vice versa).
But the simple script below doesn4t print anything.
#!/usr/local/bin/perl
$hostname = gethostbyaddr("199.45.129.30", AF_INET);
print "$hostname\n";
(I am using perl 5.003 under Digital UNIX V3.2C)
-Matti Hultstrand
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 975
*************************************