[29444] in Perl-Users-Digest
Perl-Users Digest, Issue: 688 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 27 03:09:40 2007
Date: Fri, 27 Jul 2007 00:09:05 -0700 (PDT)
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, 27 Jul 2007 Volume: 11 Number: 688
Today's topics:
Re: @arts <michaellhartsough@sbcglobal.net>
Re: @arts <michaellhartsough@sbcglobal.net>
Compiling perl on Solaris 10...bread crumb trail anyone <survivalist@gmail.com>
new CPAN modules on Fri Jul 27 2007 (Randal Schwartz)
Perl with DBI <jwcarlton@gmail.com>
Re: Perl with DBI <spamtrap@dot-app.org>
Re: Perl with DBI <jwcarlton@gmail.com>
Re: Perl with DBI <jwcarlton@gmail.com>
Re: Problem installing DBI <tlviewer@yahoo.com>
Re: regexp as function? <admiralcap@gmail.com>
regular expression match on the fly <a@mail.com>
Re: regular expression match on the fly <peter@makholm.net>
Re: standard setup for scripts <tom_spam@removethis-tabsoftwaresystems.com>
Re: standard setup for scripts <stoupa@practisoft.cz>
Re: standard setup for scripts <tom_spam@removethis-tabsoftwaresystems.com>
Re: String::CRC crc function returns incorrect result, <sisyphus1@nomail.afraid.org>
Re: Using backticks in forked child deoquinn@yahoo.com
whether large hash might leak? <chemiestor@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Jul 2007 19:00:44 -0700
From: "Mike Hartsough" <michaellhartsough@sbcglobal.net>
Subject: Re: @arts
Message-Id: <CGdqi.26829$bz7.23083@newssvr22.news.prodigy.net>
Tad McClellan wrote:
> Mike Hartsough <michaellhartsough@sbcglobal.net> wrote:
>
>
> > I saw no proof offered by Michele Dondi nor Tad McClellan, who
> > decided to join in rather than point out the Posting Guidelines,
>
>
> Specifically because the Jsut troll deserves no better.
>
> (ie. this poster has a history here)
So you're saying you have the right to accuse anyone of being this "Jsut
troll" without any evidence to prove it?
Regards
Mike
------------------------------
Date: Thu, 26 Jul 2007 20:32:31 -0700
From: "Mike Hartsough" <michaellhartsough@sbcglobal.net>
Subject: Re: @arts
Message-Id: <oHdqi.26830$bz7.21811@newssvr22.news.prodigy.net>
Wade Ward wrote:
> "Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
> news:cgqha3d2l9mr5hsj2dsnegsq6u9t5aojl3@4ax.com...
>
> > I'm trying one last time: in the posts in which this "issue"
> > started I was merely answering to the author of the parent post. I
> > left in previous quotations to show that he was answering to
> > someone else who was possibly answering someone else again. In case
> > it would have been important to know *the identity*, *name* or
> > *nick* of those other persons, I would have left in the
> > attributions: if they weren't there in the first place I may have
> > gone so far as rebuilding them. If it were even more strictly
> > important, I may have gone as far as adopting an effective quoting
> > style, like
> I think I'm competing for attention of people with perl expertise.
> This attribution-flame stuff would make any reasonable person avoid
> this thread. Take it somewhere else or just drop it.
I very much doubt would of gone so far if both Michele and vronan had
handled this better. I place more blame on Michele Dondi for his lack of
diplomacy and inability to take creative critism like an adult, even
when the Posting Guidelines proved him wrong. Amazing how quickly the
Guidelines get scrubbed off by those who normally advocate it.
Regards
Mike
------------------------------
Date: Thu, 26 Jul 2007 23:32:01 -0700
From: Aftermath Fan <survivalist@gmail.com>
Subject: Compiling perl on Solaris 10...bread crumb trail anyone?
Message-Id: <1185517921.954149.66310@i38g2000prf.googlegroups.com>
I need to compile perl on Solaris 10 (sparc v9 platform). Yes, I know
Solaris comes with a version of perl, but /usr/bin/perl on solaris 10
is (surprisingly) not compiled with full 64-bit flags:
use64bitint=define use64bitall=undef uselongdouble=undef
The specific limitation is that it can't address more than 4GB of
memory, which is symptomatic of a 32-bit binary. I would like to
address more.
Unfortunately, my attempts to compile perl on Solaris 10 (using the
gcc in /usr/sfw/bin) have all been met with:
Use which C compiler? [gcc -B/usr/ccs/bin/]
Assembler messages:
Error: invalid architecture -xarch=generic64
Uh-oh, the C compiler 'gcc -B/usr/ccs/bin/' doesn't seem to be
working.
NOTE: You are using GNU as(1). GNU as(1) might not build Perl. If
you
have trouble, you can use /usr/ccs/bin/as by including -B/usr/ccs/bin/
in your gcc -B/usr/ccs/bin/ command. (Note that the trailing "/" is
required.)
Assembler messages:
Error: invalid architecture -xarch=generic64
Uh-oh, the C compiler 'gcc -B/usr/ccs/bin/' doesn't seem to be
working.
You need to find a working C compiler.
Either (purchase and) install the C compiler supplied by your OS
vendor,
or for a free C compiler try http://gcc.gnu.org/
I cannot continue any further, aborting.
This when using:
sh Configure -de -Duse64bitall \
-Dprefix=/export/home/mylogin \
-Dcc='gcc -B/usr/ccs/bin/'
Same thing without the -B/usr/ccs/bin. Played around with the PATH
order of /usr/ccs/bin, /usr/sfw/bin, etc...to no avail.
I do not have root on this box. And no prospect of getting the Sun-
brand compiler purchased/loaded.
anyone have any bread crumb trail to follow?
Thanks,
-S.
------------------------------
Date: Fri, 27 Jul 2007 04:42:15 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Jul 27 2007
Message-Id: <JLtMEF.1z52@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-Nothing-0.01
http://search.cpan.org/~jjore/Acme-Nothing-0.01/
No more module loading !
----
Apache-Status-DBI-1.011
http://search.cpan.org/~timb/Apache-Status-DBI-1.011/
Show status of all DBI database and statement handles
----
Argv-1.21
http://search.cpan.org/~dsb/Argv-1.21/
Provide an OO interface to an arg vector
----
Asterisk-FastAGI-0.02
http://search.cpan.org/~jaywhy/Asterisk-FastAGI-0.02/
Module for FastAGI handling.
----
Audio-FLAC-Header-1.8
http://search.cpan.org/~daniel/Audio-FLAC-Header-1.8/
interface to FLAC header metadata.
----
CGI-Application-Plugin-ActionDispatch-0.90
http://search.cpan.org/~jaywhy/CGI-Application-Plugin-ActionDispatch-0.90/
Perl extension
----
CPAN-SQLite-0.15
http://search.cpan.org/~rkobes/CPAN-SQLite-0.15/
maintain and search a minimal CPAN database
----
DBI-MySperql-1.00
http://search.cpan.org/~rogerhall/DBI-MySperql-1.00/
Module to simplify DBI MySQL statements
----
DJabberd-Authen-LDAP-0.01
http://search.cpan.org/~urkle/DJabberd-Authen-LDAP-0.01/
An LDAP authentication module for DJabberd
----
DJabberd-Authen-SQLite-0.01
http://search.cpan.org/~piers/DJabberd-Authen-SQLite-0.01/
A SQLite authentication module for DJabberd
----
DJabberd-Delivery-OfflineStorage-0.01
http://search.cpan.org/~piers/DJabberd-Delivery-OfflineStorage-0.01/
Basic OfflineStorage (old style) for DJabberd
----
DateTime-Event-MultiCron-0.01
http://search.cpan.org/~neves/DateTime-Event-MultiCron-0.01/
Perl extension for DateTime::Event::Cron
----
FabForce-DBDesigner4-0.09
http://search.cpan.org/~reneeb/FabForce-DBDesigner4-0.09/
Parse/Analyse XML-Files created by DBDesigner 4 (FabForce)
----
FabForce-DBDesigner4-DBIC-0.03
http://search.cpan.org/~reneeb/FabForce-DBDesigner4-DBIC-0.03/
create DBIC scheme for DBDesigner4 xml file
----
Filter-Comments-C-0.01
http://search.cpan.org/~kosmo/Filter-Comments-C-0.01/
Perl extension to allow programmers to use C-style comments in their Perl code
----
GoferTransport-http-1.011
http://search.cpan.org/~timb/GoferTransport-http-1.011/
----
HoneyClient-Agent-0.98
http://search.cpan.org/~mitrehc/HoneyClient-Agent-0.98/
Perl extension to instantiate a SOAP server that provides a central interface for all agent-based HoneyClient operations.
----
HoneyClient-Manager-0.98
http://search.cpan.org/~mitrehc/HoneyClient-Manager-0.98/
----
HoneyClient-Util-0.98
http://search.cpan.org/~mitrehc/HoneyClient-Util-0.98/
----
JSON-XS-1.43
http://search.cpan.org/~mlehmann/JSON-XS-1.43/
JSON serialising/deserialising, done correctly and fast
----
Lingua-HU-Numbers-0.05
http://search.cpan.org/~szbalint/Lingua-HU-Numbers-0.05/
converts numbers into Hungarian language text form
----
MP3-Info-1.23
http://search.cpan.org/~daniel/MP3-Info-1.23/
Manipulate / fetch info from MP3 audio files
----
Math-Cephes-0.45
http://search.cpan.org/~rkobes/Math-Cephes-0.45/
perl interface to the cephes math library
----
Module-ThirdParty-0.22
http://search.cpan.org/~saper/Module-ThirdParty-0.22/
Provide information for 3rd party modules (outside CPAN)
----
Net-XMPP2-0.04
http://search.cpan.org/~elmex/Net-XMPP2-0.04/
An implementation of the XMPP Protocol
----
Peptide-Pubmed-1.02
http://search.cpan.org/~shtatland/Peptide-Pubmed-1.02/
extract peptide sequences from MEDLINE article abstracts.
----
SMS-Send-IS-Vit-0.01
http://search.cpan.org/~avar/SMS-Send-IS-Vit-0.01/
SMS::Send driver for vit.is
----
SMS-Send-IS-Vodafone-0.01
http://search.cpan.org/~avar/SMS-Send-IS-Vodafone-0.01/
SMS::Send driver for vodafone.is
----
Shell-Perl-0.0014
http://search.cpan.org/~ferreira/Shell-Perl-0.0014/
A read-eval-print loop in Perl
----
Spreadsheet-SimpleExcel-1.9
http://search.cpan.org/~reneeb/Spreadsheet-SimpleExcel-1.9/
Create Excel files with Perl
----
Stack-Presistent-0.01
http://search.cpan.org/~kesteb/Stack-Presistent-0.01/
A persistent stack
----
Task-Digest-0.01
http://search.cpan.org/~ski/Task-Digest-0.01/
install Digest modules and dependencies
----
Test-Smart-0.02
http://search.cpan.org/~trizor/Test-Smart-0.02/
Test things that require Human Intelligence automatically. (By asking someone)
----
WWW-Scraper-ISBN-Amazon_Driver-0.09
http://search.cpan.org/~barbie/WWW-Scraper-ISBN-Amazon_Driver-0.09/
----
WWW-Scraper-ISBN-Pearson_Driver-0.09
http://search.cpan.org/~barbie/WWW-Scraper-ISBN-Pearson_Driver-0.09/
Search driver for Pearson Education's online catalog.
----
WWW-Scraper-ISBN-Yahoo_Driver-0.06
http://search.cpan.org/~barbie/WWW-Scraper-ISBN-Yahoo_Driver-0.06/
Search driver for Yahoo Books online catalog.
----
WWW-Search-2.495
http://search.cpan.org/~mthurn/WWW-Search-2.495/
Virtual base class for WWW searches
----
Weed-0.009_012
http://search.cpan.org/~hooo/Weed-0.009_012/
Don't use it. It's in development. For test purposes only!
----
XML-FeedPP-0.22
http://search.cpan.org/~kawasaki/XML-FeedPP-0.22/
Parse/write/merge/edit RSS/RDF/Atom syndication feeds
----
XML-MyXML-0.098
http://search.cpan.org/~karjala/XML-MyXML-0.098/
A simple-to-use XML module, for parsing and creating XML documents
----
o2sms-3.25
http://search.cpan.org/~mackers/o2sms-3.25/
A module to send SMS messages using the website of O2 Ireland
----
version-Limit-0.0301
http://search.cpan.org/~jpeacock/version-Limit-0.0301/
Perl extension for fine control of permitted versions
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 26 Jul 2007 19:45:00 -0700
From: Jason <jwcarlton@gmail.com>
Subject: Perl with DBI
Message-Id: <1185504300.433865.220540@g4g2000hsf.googlegroups.com>
I'm not 100% sure whether to post this to an MySQL ng or Perl, but I'm
pretty sure that this is a code issue so I think that CLPM is the most
appropriate.
I've never used MySQL before, but I'm trying to convert my message
board to something that's more efficient than text files. I tried
writing a very simple script based on the tutorial found at Perl.com,
but it's not working the way I expected.
Using phpMyAdmin, I created the database, and assigned a user to it:
Database: mydomain_forum
User: mydomain_admin
Password: 123456 (I actually used a random generated alphanumeric
password, but didn't want to give it out)
Through phpMyAdmin, I was able to create a table just fine (named
"Testing"), so I can see that it's working on the server.
Now, using Perl, I wrote this script:
#!/usr/bin/perl
use DBI;
use CGI qw(:param);
# Variables
$DBNAME = "mydomain_forum";
$DBUSER = "mydomain_admin";
$DBPASS = "123456";
my $dbh = DBI->connect("dbi:mysql:$DBNAME", $DBUSER, $DBPASS);
# Print Stuff
print "Content-type: text/html\n\n";
print "Starting...<br><br>";
if (param('create') eq "true") {
# Create the Table
$dbh->do("CREATE TABLE 'Test 3' ('date' VARCHAR(14) NOT NULL,
'username' TINYTEXT NOT NULL, 'email' TINYTEXT NOT NULL, 'comment'
LONGTEXT NOT NULL, 'ipaddress' TINYTEXT NOTNULL) ENGINE = MyISAM");
# I added the NOT NULL based on notes from the MySQL documentation,
but it didn't help
# Insert information into the tables
$dbh->do("INSERT INTO 'Test 3' VALUES ('20070726013856', 'Test
Name', '', 'Testing comment field', '127001')");
# Give success message
print "Added";
exit;
}
else {
# Print everything that's in the table
my $sth = $dbh->prepare("SELECT * FROM 'Testing'");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: date = $ref->{'date'}, username = $ref-
>{'username'}, email = $ref->{'email'}, comment = $ref->{'comment'},
ip = $ref->{'ip_address'}\n";
}
$sth->finish();
}
# Disconnect from database
$dbh->disconnect();
exit;
Now, when I run this script with the param create=true, I get the
expected results:
Starting...
Added.
But when I check in phpMyAdmin, the table "Test 3" has not been
created, after all. Furthermore, when I remove the create=true param,
I do not get the expected printout of the Testing table.
My best guess is that I'm not connecting to the database, but I don't
know why, and I don't know how to test that theory.
Any idea? TIA,
Jason
------------------------------
Date: Thu, 26 Jul 2007 22:50:46 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl with DBI
Message-Id: <m2lkd2h855.fsf@dot-app.org>
Jason <jwcarlton@gmail.com> writes:
> Now, when I run this script with the param create=true, I get the
> expected results:
>
> Starting...
>
> Added.
>
> But when I check in phpMyAdmin, the table "Test 3" has not been
> created, after all.
That's because the expected results above will be printed regardless of
whether the create query succeeds or not; your script has absolutely no
error checking in it.
You should review "perldoc DBI" to find out how to check for errors in
your SQL.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Thu, 26 Jul 2007 21:44:26 -0700
From: Jason <jwcarlton@gmail.com>
Subject: Re: Perl with DBI
Message-Id: <1185511466.399501.246090@b79g2000hse.googlegroups.com>
> That's because the expected results above will be printed regardless of
> whether the create query succeeds or not; your script has absolutely no
> error checking in it.
>
> You should review "perldoc DBI" to find out how to check for errors in
> your SQL.
Excellent point! I modified the script with error check, as such:
# Added to beginning
use CGI::Carp qw(fatalsToBrowser);
# Modified connect command
my $dbh = DBI->connect("dbi:mysql:$DBNAME", $DBUSER, $DBPASS,
{'RaiseError' => 1}) or die "Can't connect to $database" .
$DBI::errstr;
This did help me to narrow down that the error lies on the CREATE
TABLE line, but unfortunately the error was somewhat generic:
Software error:
DBD::mysql::db do failed: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near ''Test 3' ('date' VARCHAR(14), 'username' TINYTEXT,
'email' TINYTEXT, 'comment' ' at line 1 at mysql_test.cgi line 33.
I caught one error in that my last NOT NULL had left out the space,
but this didn't solve the problem. I'm guessing that one of the
variables names that I chose (date, username, etc) are illegal, but
since they worked through phpMyAdmin then I can't be sure.
Does anything jump out at you?
- Jason
------------------------------
Date: Thu, 26 Jul 2007 23:19:00 -0700
From: Jason <jwcarlton@gmail.com>
Subject: Re: Perl with DBI
Message-Id: <1185517140.980277.17000@57g2000hsv.googlegroups.com>
> That's because the expected results above will be printed regardless of
> whether the create query succeeds or not; your script has absolutely no
> error checking in it.
>
> You should review "perldoc DBI" to find out how to check for errors in
> your SQL.
Well, I have an update, although I don't understand it.
The program seems to not like the single-quotes. I created a table
from phpMyAdmin and copied the exact code in to the program, and that
worked fine. But instead of single-quotes, it used back-ticks.
So, instead of:
$dbh->do("CREATE TABLE 'Test 3' ('date' VARCHAR(14)...
Using this worked:
$dbh->do("CREATE TABLE `Test 3`(`date` VARCHAR(14)...
Why? I couldn't tell you. None of the tutorials I read commented on
this.
But this leads me to my next question. I want `Test 3` to be a
variable, but using
$dbh->do("CREATE TABLE param('var') (`date` VARCHAR(14)...
is giving that same generic error as above. I tried it both with and
without the quotes, and tried using a variable instead ($var =
param('var');), but still received the same error.
Ideas?
- Jason
------------------------------
Date: Thu, 26 Jul 2007 22:08:46 -0700
From: Mark Pryor <tlviewer@yahoo.com>
Subject: Re: Problem installing DBI
Message-Id: <pan.2007.07.27.05.08.43.128062@yahoo.com>
On Thu, 26 Jul 2007 18:02:04 +0000, John Oliver wrote:
> On Wed, 25 Jul 2007 17:38:25 -0700, Mark Pryor wrote:
>> On Wed, 25 Jul 2007 23:31:25 +0000, John Oliver wrote:
>>
>>> On a CentOS 5 system:
>>>
>>> [root@rt-2 rt-3.6.4]# perl -MCPAN -e 'install DBI'
>>> CPAN: File::HomeDir loaded ok (v0.65)
>>> Sorry, we have to rerun the configuration dialog for CPAN.pm due to
>>> the following indispensable but missing parameters:
>>
>> Stop there. Why install DBI when this package is already a Core RPM,
>> called perl-DBI? Granted its not the latest, 1.52, but you don't need to
>> install from scratch.
>>
>> #rpm -qa | grep DBI
>>
>> The CentOS 5 has a very complete Perl environment, especially if you have
>> all the LAMP packages. To verify this do
>>
>> #yum groupinfo "MySQL Database"
>> #yum groupinfo "Web Server"
>>
>> Using Perl in CentOS is alot more fun and painless if you treat RPM and
>> YUM as your friends.
>
> Yes, I'm aware of all that.
>
> I'm trying to install RequestTracker. It's a frickin' nightmare. Since
> RT is in the Fedora Extras, I installed a host with FC7 and installed RT
> from yum. I can't get it to work. On the RT mailing list, they keep
> saying "We don't know why the RPM doesn't work, you have to install from
> source". So that's what I'm trying to do... but RT's dependency checker
> wants DBI installed via CPAN. There isn't much point with my arguing
> with why they want to do certain things certain ways... I'm just trying
> to do everything their way so hopefully at some point I can wind up with
> a working RT installation.
C5 is based on FC6 sources. Might this be a better bet?
http://fedora.kanarip.com/fedora/extras/6/i386/rt3-3.6.3-1.fc6.noarch.rpm
--
Mark
------------------------------
Date: Thu, 26 Jul 2007 23:56:37 -0700
From: Matt Madrid <admiralcap@gmail.com>
Subject: Re: regexp as function?
Message-Id: <9-KdnXOC_rSzCjTbnZ2dnUVZ_ualnZ2d@comcast.com>
Petr Vileta wrote:
> I want to know how to write regexp as "function" as this is possible in
> PHP where I can to write
> my $a = '10,12,2007';
> $b = preg_replace( 's/,/./' , $a);
You are not using the regexp as a "function" here, you are using the function
preg_replace() , which takes a regexp as it's first argument, a string as it's
second, and returns a string.
You had the answer in your "way 2"..
($b = $a) =~ s/,/./g;
.. which in my opinion is way cooler. ;-)
If you wanted, you could write your own little function that acts like
preg_replace() as Mirco suggested.
Matt M.
------------------------------
Date: Fri, 27 Jul 2007 06:27:36 GMT
From: "a" <a@mail.com>
Subject: regular expression match on the fly
Message-Id: <sfgqi.7450$_d2.4439@pd7urf3no>
Hi
#The str value is a variable, it is modified by the formula
my $str = a formula;
if ($my_str =~ /$str/) <-------Is it a valid RegEx comparison?
{
------
}
I have checked the documentation and I dont see any description on this?
Thanks
------------------------------
Date: Fri, 27 Jul 2007 06:55:32 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: regular expression match on the fly
Message-Id: <87wswml4ij.fsf@hacking.dk>
"a" <a@mail.com> writes:
> my $str = a formula;
> if ($my_str =~ /$str/) <-------Is it a valid RegEx comparison?
> {
> ------
> }
>
> I have checked the documentation and I dont see any description on this?
Then the next best thing is to try it. It is (kind of) documented in
'perldoc perlop' under the heading 'Quote and Quote-like Operators'
//Makholm
------------------------------
Date: Thu, 26 Jul 2007 21:12:43 -0400
From: Tom Bolick <tom_spam@removethis-tabsoftwaresystems.com>
Subject: Re: standard setup for scripts
Message-Id: <5Ebqi.5680$WN1.2857@bignews2.bellsouth.net>
Gunnar Hjalmarsson wrote:
> Tom Bolick wrote:
>
>> All of my perl scripts have this at the top:
>> -------
>> #!/usr/bin/perl
>>
>> $IS_WEBSITE = (-e "/home/userme/lib/site_perl");
>> if ($IS_WEBSITE){
>> use lib "/home/userme/lib/site_perl";
>
>
> It should be noted that the 'use lib' statement is always executed,
> since it happens at compile time. OTOH, even if that path is added to
> @INC unnecessarily, i.e. also when it does not exist, it won't hurt.
>
>> $ENV{HTML_TEMPLATE_ROOT}='/home/userme/www/project1/online/eng';
>> }
>> else {
>> $ENV{HTML_TEMPLATE_ROOT}='/WWWSites/client1/project1/online/eng';
>> }
>> $ENV{HEAD_BASE}='../project1/online/eng/';
>>
>> use strict;
>> use CGI;
>> use CGI::Carp qw(fatalsToBrowser set_message);
>> -----------
>>
>> Is there a way to put this in a single setup file that all scripts
>> call, like setup.pl?
>
>
> Guess you could put all but the first line in a separate file and call
> it like:
>
> BEGIN { do 'setup.pl' }
>
But will this work with strict? Any variables defined in setup.pl are
not defined in the script that calls it? Or am I wrong?
------------------------------
Date: Fri, 27 Jul 2007 03:54:39 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: standard setup for scripts
Message-Id: <f8bjmj$17qi$1@ns.felk.cvut.cz>
Tom Bolick wrote:
> All of my perl scripts have this at the top:
> -------
> #!/usr/bin/perl
>
> $IS_WEBSITE = (-e "/home/userme/lib/site_perl");
>
> if ($IS_WEBSITE){
> use lib "/home/userme/lib/site_perl";
> $ENV{HTML_TEMPLATE_ROOT}='/home/userme/www/project1/online/eng';
> }
> else {
> $ENV{HTML_TEMPLATE_ROOT}='/WWWSites/client1/project1/online/eng';
> }
> $ENV{HEAD_BASE}='../project1/online/eng/';
>
> use strict;
> use CGI;
> use CGI::Carp qw(fatalsToBrowser set_message);
> -----------
#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser set_message);
require 'setup.pl';
use vars qw($IS_WEBSITE);
...
--- file setup.pl ---
$IS_WEBSITE = (-e "/home/userme/lib/site_perl");
if ($IS_WEBSITE){
use lib "/home/userme/lib/site_perl";
$ENV{HTML_TEMPLATE_ROOT}='/home/userme/www/project1/online/eng';
}
else {
$ENV{HTML_TEMPLATE_ROOT}='/WWWSites/client1/project1/online/eng';
}
$ENV{HEAD_BASE}='../project1/online/eng/';
1;
--- end of file ---
Variables like @ENV, @ARGV, @INC are always global (Perl internal).
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Fri, 27 Jul 2007 00:13:27 -0400
From: Tom Bolick <tom_spam@removethis-tabsoftwaresystems.com>
Subject: Re: standard setup for scripts
Message-Id: <xheqi.5786$WN1.3826@bignews2.bellsouth.net>
Petr Vileta wrote:
> Tom Bolick wrote:
>
>> All of my perl scripts have this at the top:
>> -------
>> #!/usr/bin/perl
>>
>> $IS_WEBSITE = (-e "/home/userme/lib/site_perl");
>>
>> if ($IS_WEBSITE){
>> use lib "/home/userme/lib/site_perl";
>> $ENV{HTML_TEMPLATE_ROOT}='/home/userme/www/project1/online/eng';
>> }
>> else {
>> $ENV{HTML_TEMPLATE_ROOT}='/WWWSites/client1/project1/online/eng';
>> }
>> $ENV{HEAD_BASE}='../project1/online/eng/';
>>
>> use strict;
>> use CGI;
>> use CGI::Carp qw(fatalsToBrowser set_message);
>> -----------
>
>
> #!/usr/bin/perl
>
> use strict;
> use CGI;
> use CGI::Carp qw(fatalsToBrowser set_message);
> require 'setup.pl';
> use vars qw($IS_WEBSITE);
> ...
>
> --- file setup.pl ---
> $IS_WEBSITE = (-e "/home/userme/lib/site_perl");
> if ($IS_WEBSITE){
> use lib "/home/userme/lib/site_perl";
> $ENV{HTML_TEMPLATE_ROOT}='/home/userme/www/project1/online/eng';
> }
> else {
> $ENV{HTML_TEMPLATE_ROOT}='/WWWSites/client1/project1/online/eng';
> }
> $ENV{HEAD_BASE}='../project1/online/eng/';
> 1;
> --- end of file ---
>
> Variables like @ENV, @ARGV, @INC are always global (Perl internal).
>
Sounds perfect. I assume I can't stuff all my 'use' statements into a
script. I have up to 10 sometimes.
I was using require 'config.pl' for config variables, but I'm trying to
convert all my scripts to strict, so I'm using Config::General now. I
guess I could 'use vars' for that, but Config seems cleaner.
Thanks for the help.
------------------------------
Date: Fri, 27 Jul 2007 14:44:35 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: String::CRC crc function returns incorrect result, why?
Message-Id: <46a97830$0$25982$afc38c87@news.optusnet.com.au>
"`Zidane Tribal" <none@none.c0m> wrote in message
news:KR8qi.137295$764.71@newsfe12.ams...
.
.
> for example, this script.....
>
> #!/usr/bin/perl -w
> use strict;
> use String::CRC;
> print "crc: " . crc($ARGV[0]) . " " . length($ARGV[0]) . "\n";
>
> produces this output:
>
> zidane@bluemist:~/ps2/dev/crccheck$ ./crctest.pl 12345
> crc: 3817467633 5
> zidane@bluemist:~/ps2/dev/crccheck$
>
> whereas this command:
>
> zidane@bluemist:~/ps2/dev/crccheck$ echo -n "12345" | cksum
> 3288622155 5
> zidane@bluemist:~/ps2/dev/crccheck$
>
.
.
> can anyone explain what i am doing wrong?
I don't think you're doing anything wrong - they are apparently using
different algorithms.
String::CRC::Cksum ( http://search.cpan.org/~ahamm/String-CRC-Cksum-0.03/ )
claims to be compatible with the POSIX cksum program.
Cheers,
Rob
------------------------------
Date: Thu, 26 Jul 2007 19:32:24 -0700
From: deoquinn@yahoo.com
Subject: Re: Using backticks in forked child
Message-Id: <1185503544.270121.189510@l70g2000hse.googlegroups.com>
Sorry; forgot the following 2 'Use' Stmts for the listed code...
use Errno qw(EAGAIN);
use POSIX ":sys_wait_h";
Also, perhaps a simpler test script would be....
1) Create a file named fork_sleeper.pl with the following code in
it...
use Time::HiRes qw[time];
sleep 3;
print "Time(".time().") Child: Done Sleeping\n";
exit 0;
2) Use the following code in the same dir as the fork_sleeper.pl file
(NOTE: TimeHiRes is not required, but you won't get much
differentiation in your time stamps if you don't use it... See output
below the code....... Uncomment the exec() or the backticks line of
code to test...
use Errno qw(EAGAIN);
use POSIX ":sys_wait_h";
use Time::HiRes qw[time];
$sleeper = (split /(.*)\\.*?$/,$0)[1] . "\\fork_sleep.pl";
my $i;
for ($i = 0; $i<10; $i++ ) {
my $pid;
print "$i Time(".time().") Parent: Forking\n";
FORK: {
if ($pid = fork()) { next; }
elsif ( defined $pid ) {
print "$i Time(".time().") Child: About to sleep...\n";
# `$sleeper`; ##### USE THIS LINE TO TEST WITH
BACKTICKS....
# exec("$sleeper"); ##### USE THIS LINE TO TEST WITH EXEC().....
exit;
}
elsif ( $! == EAGAIN ) {
print "$i Time(".time().") Parent: Recoverable Error '$?'
'$!'\tHarvest orphaned children and retry fork....\n";
sleep 5;
wait();
print "$i Time(".time().") Parent: Redoing Fork\n";
redo FORK;
}
else { die "Time(".time().") Unrecoverable Fork Error: $!" }
}
}
exit 0;
Output with BackTicks....
0 Time(1185503292.10938) Parent: Forking
1 Time(1185503292.14443) Parent: Forking
2 Time(1185503292.17593) Parent: Forking
3 Time(1185503292.21377) Parent: Forking
0 Time(1185503292.2512) Child: About to sleep...
Terminating on signal SIGINT(2)
That was the last line... it never went further so I hit CTRL-C to
kill it....
Output using exec()....
0 Time(1185503510.3125) Parent: Forking
1 Time(1185503510.36191) Parent: Forking
2 Time(1185503510.39841) Parent: Forking
3 Time(1185503510.43181) Parent: Forking
0 Time(1185503510.45847) Child: About to sleep...
1 Time(1185503510.46419) Child: About to sleep...
2 Time(1185503510.46862) Child: About to sleep...
4 Time(1185503510.4979) Parent: Forking
5 Time(1185503510.531) Parent: Forking
6 Time(1185503510.56713) Parent: Forking
5 Time(1185503510.58752) Child: About to sleep...
4 Time(1185503510.59228) Child: About to sleep...
3 Time(1185503510.59585) Child: About to sleep...
7 Time(1185503510.62381) Parent: Forking
8 Time(1185503510.65922) Parent: Forking
9 Time(1185503510.70196) Parent: Forking
6 Time(1185503510.73913) Child: About to sleep...
7 Time(1185503510.74363) Child: About to sleep...
8 Time(1185503510.74823) Child: About to sleep...
9 Time(1185503510.79715) Child: About to sleep...
Time(1185503518.28125) Child: Done Sleeping
Time(1185503518.32813) Child: Done Sleeping
Time(1185503518.375) Child: Done Sleeping
Time(1185503518.42188) Child: Done Sleeping
Time(1185503518.45313) Child: Done Sleeping
Time(1185503518.51563) Child: Done Sleeping
Time(1185503518.54688) Child: Done Sleeping
Time(1185503518.625) Child: Done Sleeping
Time(1185503518.64063) Child: Done Sleeping
Time(1185503518.67188) Child: Done Sleeping
------------------------------
Date: Thu, 26 Jul 2007 19:25:44 -0700
From: Kimia <chemiestor@gmail.com>
Subject: whether large hash might leak?
Message-Id: <1185503144.113785.270280@r34g2000hsd.googlegroups.com>
hi, girls and dudes,
....I doubt whether hash might leak when it comprises of a large
amount of pairs.
Recently I have been asked to do some statitic work over large
files. All I wanted to do is to find the duplicated lines of a file
and I wrote the snippet as below:
code:
mysort.pl
------------------------
#!/usr/bin/perl
use strict;
use warnings;
my %in;
my $cnt = 0;
while(<>){
chomp;
$_ or ++$cnt, next;
++$in{$_};
}
foreach(sort keys %in){
$cnt += $in{$_};
print "$_*$in{$_}\n";
}
------------------------
When input file contains a few lines, it goes perfectly well.
data file:
in1.dat
------------------------
1aa
2bbbbb
3cc
1aa
5dd
------------------------
$ ./mysort.pl in1.dat
then i got:
------------------------
1aa*2
2bbbbb*1
3cc*1
5dd*1
------------------------
However, when I used it for a large file, which contains 10M lines, it
failed.
$ ./mysort <TenLinesInput.dat >out
$ echo $?
0
$ tail out -n 5
------------------------
??????????????*2
????????????????*1
??????????????????*1
?????????????????????????????*2834
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
*1
------------------------
Where '?' is \0xff, when viewed as binary file.
I'm sure that the input contains no char as: \0xff. Most of lines
are tens of char long, few exceeds 100 and none exceeds 1000.
The other output lines, except last 10, all are as expected.
Then I tried it for a input file conprised of one million lines
and it failed with the same error; I tried it for a input file of 100k
lines and it did OK.
I am not sure that it should be a bug. If anyone know the reason,
would you plz tell us?
thank you for your attention.
--
uita uinum est.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V11 Issue 688
**************************************