[11233] in Perl-Users-Digest
Perl-Users Digest, Issue: 4833 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 5 13:07:24 1999
Date: Fri, 5 Feb 99 10:00:27 -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 Fri, 5 Feb 1999 Volume: 8 Number: 4833
Today's topics:
Backslash Chars Eaten by "print" (Derek Mark Edding)
Re: checking existance of subroutine <jeffp@crusoe.net>
compilation fails on Aix 4.3.2.0 <nlx7043@nl.ibm.com>
database cnsxxx@my-dejanews.com
Re: database <stevenhenderson@prodigy.net>
Re: DBI + ODBC + MS Access <navascues@usa.net>
Help with data structure <berg98@us.ibm.com>
Re: Help with data structure <bmb@ginger.libs.uga.edu>
HELP: Forcing perl to block while reading a pipe (Mark Bainter)
how to query errno.h info <bmb@ginger.libs.uga.edu>
Re: Jesus Rides a HOG(tm) : was :CONCLUSIVE PROOF: The <JACNUNN@infoave.net>
Re: join func. appending delimiiter before 1st field.. <aqumsieh@matrox.com>
Re: log file question <stevenhenderson@prodigy.net>
Re: matts search -- again (sorry!) <ludlow@us.ibm.com>
Passing regex to a subroutine <george@tapestry.net>
Perl 4.0.1.7 Y2K compliancy thedesert1@aol.com
Re: Perl 4.0.1.7 Y2K compliancy (Randal L. Schwartz)
Re: perl path problem vchugh@bloomberg.net
Re: Perl search string problem (Mike Stok)
Re: Perlscript / ASP: Packages ? <RobLemley@nospam.com>
Re: problem with PerlTk (Daniel E. Macks)
Re: Programming with Style (brian d foy)
Re: Programming with Style <bmb@ginger.libs.uga.edu>
Re: Programming with Style <ludlow@us.ibm.com>
Re: Programming with Style <uri@home.sysarch.com>
Re: Python vs. Perl vs. tcl ? (Bart Lateur)
Re: Q: extracting tables from HTML document? dzuy@my-dejanews.com
Re: Question: Arrays of associative arrays <ludlow@us.ibm.com>
Re: reading a file <tbriles@austin.ibm.com>
Re: Sending Perl output to 2 diffent html frames dturley@pobox.com
Re: Sending Perl output to 2 diffent html frames <emschwar@mail.uccs.edu>
Re: Sending Perl output to 2 diffent html frames <emschwar@mail.uccs.edu>
storage/retrieval of text databases <marc@farm.rug.nl>
Syntax checking without "perl -c"? <ljz@asfast.com>
Re: Timer2 (Bbirthisel)
trouble invoking script from shell prompt <ag1@altavista.net>
Trouble invoking script from shell prompt <ag1@altavista.net>
Re: UNIX 'tail' command in Perl?? ()
useless use of scalar ref constructor <marty@catnmoose.com>
Re: useless use of scalar ref constructor (Randal L. Schwartz)
Win32::NetAdmin::UserGetAttributes problem keatlim@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Feb 1999 17:28:18 GMT
From: drek@nina.pagesz.net (Derek Mark Edding)
Subject: Backslash Chars Eaten by "print"
Message-Id: <slrn7bmaim.umi.drek@nina.pagesz.net>
Hi Folks,
I'm trying to substitute a pattern that has a backslash with a
different pattern that has a backslash, and write the result to
a file. The pattern looks like "{\bf " and should be "{\b ".
I tried reading each line from the file, then doing a substi-
tution like
s#\{\\bf #\{\\b #g
but when I look at the file, all that's getting written is
"{b ", the backslash is being eaten. I can substitute any
other special character, but when I try backslash it gets
removed!
I even tried \134 instead of \\ for the replace string, and
that doesn't get written out to the file either.
I have read the FAQ, my Camel (Perl 5), and the Cookbook, and
can't seem to find mention of this. I'm using Solaris 2.6 and
Perl 5.004 if that matters.
PS. It seems to be related to outputting to file -- I've seen
it work properly when sent to the console.
Thanks!
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~ Derek Mark Edding ~~~~~~~~~~~~~~~ drek@pagesz.net ~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~ "An end to BS on Usenet in Our Lifetimes!" ~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Fri, 5 Feb 1999 11:43:55 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: checking existance of subroutine
Message-Id: <Pine.GSO.3.96.990205113415.23564B-100000@crusoe.crusoe.net>
> So, you may want to create a separate package for your subs (and subs only)
> and check if they are defined in the symbol table of that package before eval'ing.
>
> There is most certainly a better way to do this, but I think this should
> work for you.
Oh, indeed there is. :)
And I happen to have it right here.
for (keys %::){
local *ref = $::{$_};
print "&$_ exists\n" if *ref{CODE};
&ref(...) if *ref{CODE}; # calling subroutine
# & needed in this case
}
Try it out. It works quite nicely.
--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
973-882-1022
www.crusoe.net
------------------------------
Date: Fri, 05 Feb 1999 16:48:30 +0100
From: Jaap Voets <nlx7043@nl.ibm.com>
Subject: compilation fails on Aix 4.3.2.0
Message-Id: <36BB12CE.5BB25363@nl.ibm.com>
When trying to build a threaded perl with dynamic loading of modules on
AIX 4.3.2 I experience the following problem:
configure & make work
when doing make test 25 tests fail, all the ones trying to load one of
the .so files
they all have the same behavior, for example:
BEGIN failed--compilation aborted at lib/sdbm.t line 16.
FAILED at test 0
lib/searchdict.....ok
lib/selectsaver....ok
lib/socket.........Can't load '../lib/auto/Socket/Socket.so' for module
Socket:
readExports: bad magic (61554) at ../lib/DynaLoader.pm line 168.
at lib/socket.t line 14
the weird thing is, we compiled perl a few weeks earlier on the same
system, but Runinng AIX 4.3.1 without a flaw, it's probably a linker
thing, but I'm not a C-guru that knows what's going wrong
does anyone have a clue?
jaap voets
the netherlands
------------------------------
Date: Fri, 05 Feb 1999 14:54:45 GMT
From: cnsxxx@my-dejanews.com
Subject: database
Message-Id: <79f0nf$ri1$1@nnrp1.dejanews.com>
Hi,
A year (or so) ago I posted a question asking if I could run a Perl script on
UNIX (Solaris7 now) to connect up to an Oracle8 database on NT4....without
using any 3rd party software.
I have no Oracle s/ware at all on UNIX so that route is closed.
At the time it didn't seem possible....is there a solution now?
Any useful URL's out there?
Chris
-=-=-
please reply to: chrisNOSPAM@mdrive.demon.co.uk
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 5 Feb 1999 08:12:27 -0600
From: "Steven T. Henderson" <stevenhenderson@prodigy.net>
Subject: Re: database
Message-Id: <xLEu2.46194$641.24783@news.san.rr.com>
nope sorry, this still requires either middleware or some custom
programming. you still need to somehow connect the two machines, check out:
www.ensodex.com
www.openlinsw.com
or contact me directly since i have some experience in this.
cnsxxx@my-dejanews.com wrote in message <79f0nf$ri1$1@nnrp1.dejanews.com>...
>Hi,
>
>A year (or so) ago I posted a question asking if I could run a Perl script
on
>UNIX (Solaris7 now) to connect up to an Oracle8 database on NT4....without
>using any 3rd party software.
>
>I have no Oracle s/ware at all on UNIX so that route is closed.
>
>At the time it didn't seem possible....is there a solution now?
>Any useful URL's out there?
>
>Chris
>-=-=-
>
>please reply to: chrisNOSPAM@mdrive.demon.co.uk
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 5 Feb 1999 16:53:25 +0100
From: "Pablo Navascues" <navascues@usa.net>
Subject: Re: DBI + ODBC + MS Access
Message-Id: <79f48t$8qe@wendy.mad.servicom.es>
Uhh, i4m not an expert but the error is asking for a DSN(Data Source Name).
generally you make ODBC connections to DSN not the database file. You have
to set this up in the Operative System In windows its via the ODBC Data
Source Administrator>System DSN>Add. Following steps are trivial.
--
bye,
Pablo
Andrew Fry escribis en mensaje ...
>I am trying to use DBI + ODBC to read a small
>MS Access database (file name: afdb1.mdb).
>The connect statement looks like this:
> $dbh = DBI->connect($dbdatasrc,$dbusername,$dbpassword);
>...where...
> $dbdatasrc = "DBI:ODBC:afdb1.mdb"
> $dbusername = ""
> $dbpassword = ""
>
>However, I am getting the following error:
>
> Error connecting to DBI:ODBC:afdb1.mdb: [911]
> [] "[Microsoft][ODBC Driver Manager] Data source
> name not found and no default driver specified
>
>Any suggestions as to what I might be doing wrong ?
>
>Note:
>1. This is using (ActiveState's) ActivePerl build 509
> + DBI +DBD:ODBC packages.
>2. I tried the full pathname of the file - makes no
> difference.
>
>---
>Andrew Fry
>"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).
------------------------------
Date: Fri, 05 Feb 1999 10:51:26 -0500
From: "Shawn A. Berg" <berg98@us.ibm.com>
Subject: Help with data structure
Message-Id: <36BB137E.6314D08A@us.ibm.com>
I would like to create a hash of file handles. I cannot figure out how
to set up and use this kind of structure.
------------------------------
Date: Fri, 5 Feb 1999 11:30:12 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: "Shawn A. Berg" <berg98@us.ibm.com>
Subject: Re: Help with data structure
Message-Id: <Pine.A41.4.02.9902051127440.56626-100000@ginger.libs.uga.edu>
On Fri, 5 Feb 1999, Shawn A. Berg wrote:
> I would like to create a hash of file handles. I cannot figure out how
> to set up and use this kind of structure.
Hope this helps (don't forget the extra brackets in the 'print'
statement).
-Brad
#!/usr/local/bin/perl -w
use strict;
my %fhhash = (
FH1 => myfh(),
FH2 => myfh(),
FH3 => myfh(),
FH4 => myfh(),
);
foreach ( keys %fhhash ) {
open( $fhhash{ $_ }, ">>$_" ) or die "Can't open $_: $!";
print {$fhhash{ $_ }} "Howdy $_\n";
close $fhhash{ $_ };
}
print `ls -la F*`;
print `cat F*`;
sub myfh {
local *FH;
return *FH;
}
### output:
### -rw-rw-r-- 1 bmb oclc 10 Feb 5 11:26 FH1
### -rw-rw-r-- 1 bmb oclc 10 Feb 5 11:26 FH2
### -rw-rw-r-- 1 bmb oclc 10 Feb 5 11:26 FH3
### -rw-rw-r-- 1 bmb oclc 10 Feb 5 11:26 FH4
### Howdy FH1
### Howdy FH2
### Howdy FH3
### Howdy FH4
------------------------------
Date: 5 Feb 1999 17:19:38 GMT
From: mark@mark.adspp.com (Mark Bainter)
Subject: HELP: Forcing perl to block while reading a pipe
Message-Id: <slrn7bm8tp.59r.mark@mark.adspp.com>
I'm trying to pull in data from a named pipe. I open
the pipe and it blocks fine waiting for data. The first
set of data comes through and I process it.
Then, it goes back to look to the pipe again but this time
it doesn't block when there is no data there. I tried
setting it up to close the pipe and reopen it after each
set of data, but if there was already another set in the
pipe waiting it would get lost.
Please, I could really use some assistance on this one.
Thanks,
Mark
------------------------------
Date: Fri, 5 Feb 1999 12:29:03 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: how to query errno.h info
Message-Id: <Pine.A41.4.02.9902051215080.56626-100000@ginger.libs.uga.edu>
The following code snippet creates empty files named 'x1', 'x2', etc.
#!/usr/local/bin/perl -w
use strict;
use Fcntl;
local *BAK;
for( my $serial = 0;; ) {
last if sysopen( BAK, "x".++$serial, O_WRONLY|O_EXCL|O_CREAT );
#die $! unless $! eq 'File exists'; ### other error
die $! unless $! == 17; ### other error
die "Infinite loop" if $serial > 10; ### last resort
}
My question is this: how can I be sure that '17' is the correct code for
the 'File exists' error? I see the line
#define EEXIST 17 /* File exists */
in my system's errno.h file, but I'm not certain that this will be true
for every perl. Is there a module that sets up these error codes (EEXIST,
etc.) in a way similar to how Fcntl sets up O_WRONLY, etc.? For instance
use Errno; ### imaginary module?
...
die $! unless $! == EEXIST;
On the other hand *can* I be certain about the numerical values? I've
looked in Programming Perl and in CPAN for such a module, but obviously I
could have missed something.
Thanks,
-Brad
------------------------------
Date: Fri, 05 Feb 1999 10:15:31 -0500
From: Green Chicken {Jack} <JACNUNN@infoave.net>
Subject: Re: Jesus Rides a HOG(tm) : was :CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <36BB0B12.4A1A12E3@infoave.net>
No, Jesus would have only ridden a Harley if he wanted to break down half way there.
Ears wrote:
> On Wed, 27 Jan 1999 03:11:43 GMT,
> Spider Fighter <spiderfighter@REMOVETHISTOEMAILMEhotmail.com> wrote:
>
> >Well, _that_ was interesting.
> >Please don't post this thread to the rec.games.video.nintendo newsgroup any more.
>
> OK, consider it done. No longer crossposting there.
>
> BTW, did John Lennon ride a Harley ? Or any other bike, for that matter ?
>
> I'll bet if Harleys were around when Jesus was, he, and all his apostles
> would've ridden. Well, they did say he could see the future....
>
> BTW, this thread is no longer being posted to rec.games.video.nintendo.
> If you don't want this posted to your newsgroup either, reply to us here
> at rec.motorcycles.harley, and we will be glad to take it out of the
> header for you. Unless of course, you're smart enough to do it yourself
> before you repost.
>
> This thread is currently being maintained by bonafide Harley riders now.
>
> --
> *Ears* 98 XL 1200 Custom
> kd4zkw@amsat.org
> http://www.dialisdn.net/user/cdlevin
------------------------------
Date: Fri, 5 Feb 1999 11:17:49 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
To: prasad@chetana.com
Subject: Re: join func. appending delimiiter before 1st field..
Message-Id: <x3yu2x0rfir.fsf@tigre.matrox.com>
prasad@my-dejanews.com writes:
> I want to scan a line with fields delimited by '--' and print it in a file
> as,
>
> field1``field2``field3``field4``x
>
> Instead, it is being written as follows,
>
> ``field1``field2``field3``field4``x
>
> current code->
> ---------------------
> @field_array = split(/--/, $splitlist[$a]);
> chomp @field_array;
>
> print FILE join("``",(@field_array)),'``x',"\n";
> ---------------------
My guess would be that $splitlist[$a] has the form:
'--field1--field2--field3--field4'
So the split returns an array whose first element is the empty
string. Join inserts a `` between the empty string and field1,
resutling in the output you are getting.
Solutions:
1) After the split, check if the first element is an empty string. If
it is, shift() it.
2) Before the split, do a s/^--//;
3) Use a different (probably faster, not sure though) approach. What
you are doing basically boils down to replacing all occurrences of
"--" with "``" (according to the information you gave us)... so you
can do something like:
$splitlist[$a] =~ s/^--//;
$splitlist[$a] =~ s/--/``/g;
print "${splitlist[$a]}``x\n";
HTH,
Ala
------------------------------
Date: Fri, 5 Feb 1999 08:39:15 -0600
From: "Steven T. Henderson" <stevenhenderson@prodigy.net>
Subject: Re: log file question
Message-Id: <F8Fu2.46196$641.24832@news.san.rr.com>
yeah, everytime to you open the file, count the number of lines and insert
breaks where needed.
or even better, abstract your data from html formatting. i would simply
store the names in the file (ie. don't store and HTML info) and write
another program that reads in this file and formats the names as needed.
this way your first program simply needs to append another name to the list
and not worry about the formmating. additionally you can use the names for
other things if they are not hidden in HTML stuff.
i think i understood your question.
myname@mydomain.com wrote in message <79e0sl$b7c$1@news3.Belgium.EU.net>...
>Hello everybody,
>
>I just made a perl script that keeps a log of all visitors.
>Now I've noticed that the html page it generates becomes very long.
>Is there a way to say after x amount of logged entries to start a new page
?
>
>Thank you for your help,
>
>Peter
>
>
------------------------------
Date: Fri, 05 Feb 1999 09:43:45 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: matts search -- again (sorry!)
Message-Id: <36BB11B1.174D21EE@us.ibm.com>
el_pollo_diablo wrote:
> Last time I posted about this I was told that Matts scripts were cack and I
> totally agree, however as you can see I'm totally new to this and I'm just
> trying to use this as a jumping block!
If you really want to learn by example, there are better "jumping
blocks".
Brent Michalski writes a column for WebReview.
http://webreview.com/wr/pub/Perl
Also, Randal Schwartz writes for the paper magazine Web Techniques. His
columns are reprinted on his website.
http://www.stonehenge.com/merlyn/WebTechniques/
These columns won't teach you how to collect credit card info, but for
simple, non-secure, CGI scripts, they're a step in the right direction.
If you've got a little cash to burn, Learning Perl (also by Schwartz)
would be a wise buy.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Wed, 03 Feb 1999 20:58:59 -0600
From: "George H" <george@tapestry.net>
Subject: Passing regex to a subroutine
Message-Id: <01be4fe9$fdd7b8a0$152a5d18@george.austin.rr.com>
Dear Perl Kings and Queens,
I am trying to pass a regex as a variable to a subroutine like the code below. For example, the first thing I am passing below is
a regex that gives the answer I want. If I grep(/$lastmonth_signup\/\d+\/$lastyear/,@log) I get the answers I want. When I try to
pass that regex to a subroutine, I get nothing. No results. I \ all things I need to. When I debugged this, I print out
$search_date in the subrouine and it is the regex I want but it is like the grep is not interpreting it ... just using what is
literally there. Is there any way around this?
get_stats("$lastmonth_signup\/\\d+\/$lastyear",$lastmonth_signup,"Last Month\'s");
$pattern = "\^\\Q$today\\E::"; #this is something else I tried
get_stats($pattern,$today_signup,"Today\'s");
sub get_stats{
($search_date,$signup_date,$string) = @_;
@stat_searches = grep(/$search_date/,@log);
print "$search_date<BR>";
$stat_searches_num = @stat_searches;
@stat_signups = grep(/::\Q$signup_date\E/,@signlog);
$stat_signup_num = @stat_signups;
print "$string Searches: $stat_searches_num $string Signups: $stat_signup_num<BR>";
return;
}
Thanks in advance,
George
georgeh@got.net
------------------------------
Date: Fri, 05 Feb 1999 17:17:07 GMT
From: thedesert1@aol.com
Subject: Perl 4.0.1.7 Y2K compliancy
Message-Id: <79f929$38d$1@nnrp1.dejanews.com>
Hello,
Does anyone know if Perl 4.0.1.7 is Y2K compliant.
Thank You,
Mike
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 05 Feb 1999 09:48:47 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl 4.0.1.7 Y2K compliancy
Message-Id: <m1aeysyc5c.fsf@halfdome.holdit.com>
>>>>> "thedesert1" == thedesert1 <thedesert1@aol.com> writes:
thedesert1> Does anyone know if Perl 4.0.1.7 is Y2K compliant.
At this time, Larry Wall and the Perl developers have made no plans to
make Perl 4.0.1.7 Y2K compliant. You should immediately upgrade all
your applications to the current version of Perl (either 5.004 or
5.005, depending on your risk level). If you do not do so, we cannot
guarantee that your programs will continue to execute past the turn of
the century.
thedesert1> Thank You,
Thanks for asking. You should feel safer now.
--
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@teleport.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: Fri, 05 Feb 1999 17:37:46 GMT
From: vchugh@bloomberg.net
Subject: Re: perl path problem
Message-Id: <79fa99$4iq$1@nnrp1.dejanews.com>
In article <79e3lv$dqb$1@news3.Belgium.EU.net>,
"myname@mydomain.com" <elst.fels@nospam.ping.be> wrote:
> Is there a way to find out where the perl is on a server ?
> I mean #!usr/bin/perl, #!usr/bin/local/perl, ...
>
> Thank you,
>
> Peter
>
>
If you are on a Unix OS machine try
which perl <enter> (! this is about all I know)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 04 Feb 1999 09:21:02 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl search string problem
Message-Id: <OKnk6HFU#GA.166@news2.texas.rr.com>
In article <79brtg$6jj$1@nnrp1.dejanews.com>, <lamj@softhome.net> wrote:
>
>I am trying to find a way to find if there are any non number characters in a
>string. Can anyone tell me the way to do it.
>
>I have tried the following but without success
>
>if ($abc =~ tr/\D//) {}
>
>\D suppose to be same as [^0-9], the above statement would not find any non
>numeric char in $abc.
You might want to say
if ($abc =~ /\D/) {
...
}
tr is documented in the perlop manual page, and is probably not doing what
you think it is, the \D is not the character class you think is is:
DB<1> $abc = 'ABCDEFG'
DB<2> print "done one" if $abc =~ tr/\D/12/
done one
DB<3> X abc
$abc = 'ABC1EFG'
tr is not fed a regex, but a searchlist and replacement list (which might
be expressed in terms of ranges using a -)
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
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Fri, 5 Feb 1999 11:27:18 -0600
From: "Rob Lemley" <RobLemley@nospam.com>
Subject: Re: Perlscript / ASP: Packages ?
Message-Id: <Ai4EhtSU#GA.250@pet.hiwaay.net>
In the other package, you need
$main::Response->Write("Line 2");
Also, for safer code, you might want
to put this at the beginning of your
source files:
use strict;
use vars qw($Response $Request);
Markus Geish|ttner wrote in message <36baea19.186064797@news.strex.allianz>...
...
>It seems like $Response is not known to the package. Is there any way
>to pass $Response to the package ?
...
------------------------------
Date: 5 Feb 1999 17:35:24 GMT
From: dmacks@mail1.sas.upenn.edu (Daniel E. Macks)
Subject: Re: problem with PerlTk
Message-Id: <79fa4s$e0q$1@netnews.upenn.edu>
Stefano Ghirlanda <stefano@rerumnatura.zool.su.se> said:
:
: Since I found it unlikely to be a bug in the Tk module, I ask what I'm
: doing wrong. Perhaps the Tk module is not installed properly?
: Tk application with tcl work. I'm on a linux system (redhat 5.2).
The Tk suite doesn't seem to work with perl 5.004_04 (the version that
comes with RH5.2). Getting a newer perl would be your best bet.
dan
--
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks
------------------------------
Date: Fri, 05 Feb 1999 11:03:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Programming with Style
Message-Id: <comdog-ya02408000R0502991103020001@news.panix.com>
In article <79evh0$qfr$1@nnrp1.dejanews.com>, chad@vcn.net posted:
> In article <slinberg-0502990034460001@cc11620-a.lwmrn1.pa.home.com>,
> slinberg@crocker.com (Steve Linberg) wrote:
> > The Perl Cookbook, by Tom Christiansen and Nathan Torkington, is a great
> > place to start. Lots of nice code samples in there.
>
> I have that one. What I'm looking for is a book on complete program design
> from the ground up. Ya, I have my own style when it comes to designing a
> script, I would just like to see how the perl guru's do it.
that sort of book transcends Perl, so you might look in the general
programming section of whatever venue you are searching.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Fri, 5 Feb 1999 11:00:37 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: chad@vcn.net
Subject: Re: Programming with Style
Message-Id: <Pine.A41.4.02.9902051001450.56626-100000@ginger.libs.uga.edu>
The quality of my programming increased at least tenfold (over what?, you
may ask) after reading _Code Complete : A Practical Handbook of Software
Construction_ by Steven C. McConnell, Microsoft Press, ISBN 1-55615-484-4
It is not programming language specific, but rather addresses the general
issues of designing and writing quality code.
My $.02,
-Brad
On Fri, 5 Feb 1999 chad@vcn.net wrote:
...
> I'm not a complete idiot. So where I want some help
> or advice (from older programmers or maybe new ones too)
> is how to get more efficient on program design. From
> the planning stages of a project to coding, etc. What
> books are there or resources out there, that will help me
> become a better programmer?
------------------------------
Date: Fri, 05 Feb 1999 10:05:00 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Programming with Style
Message-Id: <36BB16AC.6033767B@us.ibm.com>
chad@vcn.net wrote:
>
> In article <slinberg-0502990034460001@cc11620-a.lwmrn1.pa.home.com>,
> slinberg@crocker.com (Steve Linberg) wrote:
> > In article <79dr91$ttv$1@nnrp1.dejanews.com>, chad@vcn.net wrote:
> >
> > > I'm sure I'll get
> > > better with more and more experience and practice, just
> > > wondering if anyone ran across a good book. I heard of one
> > > called "The Pearls of Programming", but have never been able
> > > to find it in a store.
> >
> > The Perl Cookbook, by Tom Christiansen and Nathan Torkington, is a great
> > place to start. Lots of nice code samples in there.
"Code Complete : A Practical Handbook of Software Construction" by Steve
McConnell (Microsoft Press; ISBN: 1556154844).
Don't let the publisher's name fool you, this book is excellent. The
quality of my code, in both C and Perl, has at least doubled since
reading this. I thought I practiced good habits before (good variable
names, modular code, etc...) Wow. I didn't know that there was so much
that I didn't know.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: 05 Feb 1999 12:26:28 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Programming with Style
Message-Id: <x7yamcn4mz.fsf@home.sysarch.com>
>>>>> "JL" == James Ludlow <ludlow@us.ibm.com> writes:
JL> "Code Complete : A Practical Handbook of Software Construction" by
JL> Steve McConnell (Microsoft Press; ISBN: 1556154844).
JL> Don't let the publisher's name fool you, this book is excellent.
JL> The quality of my code, in both C and Perl, has at least doubled
JL> since reading this. I thought I practiced good habits before
JL> (good variable names, modular code, etc...) Wow. I didn't know
JL> that there was so much that I didn't know.
i have it too. too bad redmondware doesn't practice its tenets. he is a
little too anal in places. IIR he loves hungarian names which i
hate. but i wonder how much of it would apply to perl. you can't use the
same style for c and perl.
as a general comment on perl style, there are perl coding issues
(idioms, tricks, techniques, etc.) that the cookbook and effective perl
cover well. naming, formatting, commenting and the like are more
language independent and can lead to religious wars. the major point
there is consistancy. develop a style that looks clean and use it. then
look at other code you admire and take pieces of style form it and
intgrate it into your style. discipline in code style is important. i
adhere to my style very rigorously. my names, formatting, white space
rarely changes across programs and lines of code.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Fri, 05 Feb 1999 15:36:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Python vs. Perl vs. tcl ?
Message-Id: <36bc0f0f.11004388@news.skynet.be>
>:In article <36B5AB97.C2874740@ibm.net>, Jon McLin <jon_mclin@ibm.net> wrote:
>:>The point to this post? I'm specifically looking for references to
>:>concise, perhaps tabular reasonably-objective comparisons between
>:>Python, Perl, and TCL.
(The original post didn't appear on my server.)
Take a look inside the "Advanced Perl Programming" book, AKA the Panther
Book (O'Reilly). Many chapters end with a feature comparison between
(amongst others) Perl, TCL and Python.
Bart.
------------------------------
Date: Fri, 05 Feb 1999 15:03:23 GMT
From: dzuy@my-dejanews.com
Subject: Re: Q: extracting tables from HTML document?
Message-Id: <79f17j$s34$1@nnrp1.dejanews.com>
In article <79aloa$7ci$1@nnrp1.dejanews.com>,
anna@water.ca.gov wrote:
> This is probably easy but my brain is feeling a bit toasty. I'm trying to
> extract anything between <table> ... </table> from an HTML document including
> the table tags and leave any other HTML tags that I might find in the
> document.
>
> Essentially, I'm looking to lift entire tables from an HTML document. Any
> comments on the code below?
>
> For starters, I'd start here:
>
> $summaryIn = "SUMMARY.html";
> open(SUMMARY, "<$summaryIn") || die "\nCan't open file: $!\n";
> while ($html = <SUMMARY>) {
> ($junk, $table, $junk2) = split(/table/,$html);
> }
>
> print "<table${table}>\n";
> close(SUMMARY) || die "\nCan't close file: $!\n";
>
sub chunk {
my ($file, $tag) = @_;
my $flag = 0;
my $chunk = '';
unless (open(FILE, "$file")) {
plerr "Unable to open file $file.\n";
return;
}
while(<FILE>) {
if(m|<$tag.*|i) { # spot the start tag
$flag = 1;
}
if(m|</$tag.*|i) { # spot the end tag
$chunk .= $_;
$flag = 0;
}
if($flag == 1) {
$chunk .= $_;
}
}
close(FILE);
# If you want to trim all before the 1st occurrence of <tag>
$chunk =~ s/.*?(<$tag)/$1/;
# To trim all after the last occurrence of </tag>
$chunk =~ s/<\/$tag>.*$/<\/$tag>/;
return $chunk;
}
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 05 Feb 1999 09:53:53 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Question: Arrays of associative arrays
Message-Id: <36BB1411.45ED9CCD@us.ibm.com>
Steve Linberg wrote:
> I know you know your stuff, Larry, so I'm sure you're correct, but I'm a
> little confused by this. The Camel, 2nd edition, p. 268-270 talks about
> arrays of hashes, and I use an array-of-hash structure right now in some
> code I'm working on. perldsc has samples. They don't seem to be using
> references, unless it's in some implicit way I don't understand. Can you
> shed any light?
>
> --------------------------------------------------------------
> @LoH = (
> {
> Lead => "fred",
> Friend => "barney",
> },
> );
Flip back a few pages in your Camel book (chapter 2, pg 50). There's an
example of initializing an anonymous hash reference. It's form is the
same as that used above.
In other words, when you do this:
$string = { 'key' => 'value' };
you're really just creating a reference to that hash.
Specifically, it's the difference between using () and {}.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Fri, 05 Feb 1999 08:59:12 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: reading a file
Message-Id: <36BB0740.8681BBA0@austin.ibm.com>
There is no newsgroup comp.lang.perl. I removed it.
dan wrote:
> lets say i did this:
>
> #!/usr/bin/perl
ALWAYS use the -w flag, and get used to 'use strict' ASAP.
>
> print "Content-type:text/html\n\n";
> open(TEST, "template.txt");
ALWAYS check the success of 'open', i.e.,
open(TEST, "template.txt") or die "Can't open template.txt: $!";
>
> @test = <TEST>;
> close(TEST);
Good idea to test success here, too.
> print "@test";
>
> how can i have the script read the file until it reaches a certain
> string and then stop? for the sake of argument, lets say $search =
> "12345"
> also, how can i get it to read the file from $search on? thanks for your
> help
Try:
perldoc perlsyn
This covers various looping methodologies, a number of which you could use to
perform your task.
And 'while' you're at it, 'if' you don't understand, 'continue' reading 'until'
you 'do'...'foreach' individual statement.
And if you want to get serious with Perl, buy Learning Perl. Or at least read
all of the documentation and FAQs.
HTH,
Tom
------------------------------
Date: Fri, 05 Feb 1999 16:36:55 GMT
From: dturley@pobox.com
Subject: Re: Sending Perl output to 2 diffent html frames
Message-Id: <79f6n6$12u$1@nnrp1.dejanews.com>
In article <36BAF246.48A7B587@mindspring.com>,
John Safrit <safrit@mindspring.com> wrote:
> Actually, there is a way to do it using Perl. Check out the
> following scripts:
> http://www.terminalp.com/scripts/redirection.shtml
> He uses a "Window-target: target-name" to redirect the output to the
> named window.
This is cool when it works, but it's not supported by all browsers, namely IE
(but who really cares :-)
--
____________________________________
David Turley
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 05 Feb 1999 10:42:33 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Sending Perl output to 2 diffent html frames
Message-Id: <xkfbtj8n3w6.fsf@valdemar.col.hp.com>
John Safrit <safrit@mindspring.com> writes:
> Actually, there is a way to do it using Perl. Check out the
> following scripts:
> http://www.terminalp.com/scripts/redirection.shtml
> He uses a "Window-target: target-name" to redirect the output to the
> named window.
Um, that's not perl, that's HTML. And I'm not even sure about that
much. In any event, that will redirect output of one CGI (which doesn't
need to be written in Perl) to *one* window, but not two different ones
at the same time. You can't get there from here.
-=Eric
------------------------------
Date: 05 Feb 1999 10:40:32 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Sending Perl output to 2 diffent html frames
Message-Id: <xkfemo4n3zj.fsf@valdemar.col.hp.com>
"Bob Van Der Ploeg" <bob@worldparts.com> writes:
> Thanks for all you replies to this issue. Chad's "Perl with a little JAVA"
> did the trick.
That's not Java, it's Javascript. The differences are legion. Do not,
repeat, do NOT conflate the two, or people who aren't as nice as me will
give you far more crap about it than I'm doing.
> I have a script that creates an HTML document with JAVA in the header
> eg:
<snip>
Aside from the "print" statements, this isn't perl. Why are you
discussing this on a perl newsgroup?
-=Eric
------------------------------
Date: 05 Feb 1999 16:32:50 +0100
From: Marc Weeber <marc@farm.rug.nl>
Subject: storage/retrieval of text databases
Message-Id: <8690ecamsd.fsf@pc216.farm.rug.nl>
Hello all,
I am looking for efficient ways of storing and retrieving information
from large text databases. I wonder whether it is best to use (zipped) text
files and for use unzip them and read them into memory. I think that
storage is efficient, but retrieval, and especially memory use may not
be optimal. On the other hand I think of using a kind of DB format and
use the `tie DB_File' method to retrieve and manipulate the
information.
As you read I use a lot of `think', `wonder', and `may'. If one of
you gurus can shed some light or give some references on this subject,
I would be very pleased.
Thanks in advance,
Marc
--
----------------------------------------------------------
Marc Weeber http://www.farm.rug.nl/marc/
_______ phone: +31 50 363 7571
marc@farm.rug.nl | fax: +31 50 363 3311
-----------------------0----------------------------------
------------------------------
Date: 05 Feb 1999 10:35:44 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Syntax checking without "perl -c"?
Message-Id: <ltemo4oobz.fsf@asfast.com>
I'm writing an application in Perl that interprets text that, among
other things, contains embedded Perl (and no, this is *not* dynamic
HTML, XML, or anything like that). Also, for various reasons that I
won't go into here, I don't want to use `eperl'.
Anyway, I can easily parse the text into Perl/non-Perl sections, and
once I have a piece of Perl code, I'd like to do a syntax check to see
if it is valid Perl ... I'd like to do the exact, same checking that
"perl -c" does. Furthermore, I don't want to eval this code at this
time, because it might produce unwanted side-effects. And finally, I
know I could pipe each fragment through "perl -c", but I'm trying to
avoid the extra process invocations that this approach would entail.
So ... I'm wondering: is there any way within Perl that I could check
pieces of Perl code for valid syntax, given the preferences and
requirements I outlined above?
I couldn't find anything about this in the faq's and other doc's.
Thanks in advance.
--
Lloyd Zusman ljz@asfast.com
perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
------------------------------
Date: 5 Feb 1999 15:25:51 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Timer2
Message-Id: <19990205102551.25641.00001077@ng-fs1.aol.com>
Hi Randal:
>dkelly> I am not allowed to run it by use of the CRONTAB or BATCH
>dkelly> facilities on the Unix system (the reason being not because I
>dkelly> don't have access to it but because my lecturer (a very strict
>dkelly> dude) won't let me use it for my project. I need it to run
>dkelly> through the use of Perl code.
>
>use Homework::Cheat qw(No, we shouldn't help you);
A similar, but legitimate, question like this recently appeared on the
Perl-Win32-Users list. I wonder if that means:
use 'very strict dude';
is equivalent to "prepare to code in a world missing essential OS
services."
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Fri, 5 Feb 1999 17:06:58 +0100
From: "Andy Goodman" <ag1@altavista.net>
Subject: trouble invoking script from shell prompt
Message-Id: <79f4sn$7ct$1@pacifica.access.ch>
heres a really stupid newbie question:
I am trying to invoke the following script from the command line of my unix
shell:
#!/usr/bin/perl
# reset tracking file to 0
open(COO,">count.dat");
print COO "0";
close(COO);
exit(0);
the script is called reset.cgi, permissions are set at 755, it is in the
cgi-bin
the script runs fine when called through my browser (ie the counter file is
reset to zero, although I receive a 500 message in my browser window)
however I cant get it to execute in a telnet session (eventually I want to
set this up as a cronjob)
can someone help please
------------------------------
Date: Fri, 5 Feb 1999 17:16:38 +0100
From: "Andy Goodman" <ag1@altavista.net>
Subject: Trouble invoking script from shell prompt
Message-Id: <79f5er$7qj$1@pacifica.access.ch>
heres a really stupid newbie question:
I am trying to invoke the following script from the command line of my unix
shell:
#!/usr/bin/perl
# reset tracking file to 0
open(COO,">count.dat");
print COO "0";
close(COO);
exit(0);
the script is reset.cgi, permissions are set at 755, it is in the cgi-bin
the script runs fine when called through my browser (ie the counter file is
reset to zero, although I receive a 500 message in my browser window)
however I cant get it to execute in a telnet session (eventually I want to
set this up as a cronjob)
can someone please help
------------------------------
Date: 5 Feb 1999 14:57:55 GMT
From: hdiwan@diwanh.stu.rpi.edu ()
Subject: Re: UNIX 'tail' command in Perl??
Message-Id: <slrn7bm1mu.197.hdiwan@diwanh.stu.rpi.edu>
File::Backwards <---coming within a few days to a CPAN near you.
--
Hasan Diwan
------------------------------
Date: Fri, 05 Feb 1999 11:41:49 -0500
From: Marty Landman <marty@catnmoose.com>
Subject: useless use of scalar ref constructor
Message-Id: <36BB1F4C.65105B58@catnmoose.com>
When I coded the following the compiler said "useless use of scalar ref
constructor".
!&Post ? &Prt_Form :
{&Form_ok ? &Prt_Listing : &Prt_Form};
When I changed the curly brackets to parens as below, the message went
away.
!&Post ? &Prt_Form :
(&Form_ok ? &Prt_Listing : &Prt_Form);
I had thought that the curly brackets could be used to group together
stmts so they execute in place of a single stmt, guess I'm wrong again.
I want the outer if-false-expr to execute the parenthesized trinary ?:
expr... hope I'm expressing myself properly here, but you get the idea.
The parenthesis eliminated the compiler warning (I said perl -wc
mypgm.cgi from the cmd line) but am I getting the executable code that I
want? And what's the problem with using {} instead of () in this case?
tia
--
Marty Landman - web programming and design
Cat 'n Moose dot com http://www.catnmoose.com/
------------------------------
Date: 05 Feb 1999 09:21:05 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: useless use of scalar ref constructor
Message-Id: <m1emo4ydfi.fsf@halfdome.holdit.com>
>>>>> "Marty" == Marty Landman <marty@catnmoose.com> writes:
Marty> I had thought that the curly brackets could be used to group together
Marty> stmts so they execute in place of a single stmt, guess I'm wrong again.
{ foo; bar } is a block
do { foo; bar } is an expr
If you try to use a block where an expr is expected, the curlies are
presumed to be a hashref constructor.
$a = { "fred" }; # bad ("odd number of elements in hash" under -w)
$a = do { "fred" }; # ok, but weird :)
{ "barney" } # legal
do { "barney" }; # legal, but weird - and note the need for ";"
print do { "Just another Perl hacker," };
--
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@teleport.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: Fri, 05 Feb 1999 16:57:39 GMT
From: keatlim@my-dejanews.com
Subject: Win32::NetAdmin::UserGetAttributes problem
Message-Id: <79f7tt$2e5$1@nnrp1.dejanews.com>
I have a problem when using the NetAdmin::UserGetAttributes that the $flags
come back as a number. Is there a way to convert the flags in numbers into
readable format??
Thanks!!
Keat
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4833
**************************************