[30059] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1302 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 24 03:09:42 2008

Date: Sun, 24 Feb 2008 00:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 24 Feb 2008     Volume: 11 Number: 1302

Today's topics:
    Re: BEGIN not safe after errors--compilation aborted <rkb@i.frys.com>
    Re: Building DBD::Pg on Windows? <ben@morrow.me.uk>
    Re: checking for duplicates in a string <ben@morrow.me.uk>
        CPAN and man page installation <vincent+news@vinc17.org>
    Re: CPAN and man page installation <ben@morrow.me.uk>
        files, xml and xds; examples of for practice mk834tt@yahoo.com
    Re: Get an arbitrary hash key, quickly. <socyl@987jk.com.invalid>
    Re: Get an arbitrary hash key, quickly. xhoster@gmail.com
    Re: I don't understand the Net::Telnet error <cdalten@gmail.com>
        new CPAN modules on Sun Feb 24 2008 (Randal Schwartz)
        new variable stupidity (Time Waster)
    Re: new variable stupidity <tadmc@seesig.invalid>
    Re: Number of days since 1/1/2000 (Doug Miller)
    Re: Number of days since 1/1/2000 (Doug Miller)
    Re: Number of days since 1/1/2000 (Doug Miller)
        PL/Perl: when to set @INC? <socyl@987jk.com.invalid>
    Re: setting %ENV in a module <ben@morrow.me.uk>
        uc() and utf8 <stoupa@practisoft.cz>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 23 Feb 2008 12:46:47 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: BEGIN not safe after errors--compilation aborted
Message-Id: <f4ddb84c-13a7-47a9-9314-5c4f7c834d5d@n58g2000hsf.googlegroups.com>

On Feb 23, 10:17 am, daz9643 <darrenb...@dipinternational.co.uk>
wrote:
> ok ,the actual google code does not include the lines
> use CGI::Carp qw(fatalsToBrowser);
> ul class="simpleblue"
>
> these to lines were just added to help with debugging. Without these 2
> lines i just get the error 500.
> You're right about line 9, there were a few blank lines in the code
> which i've deleted as they weren't necessary. If i remove the
> offending line of code or rem it out the error just points to the next
> line of code and so on.

Well, it's pretty obvious that this line:

> ul class="simpleblue"

will generate an error.

Comment out that line and retest.  If if fails, then post the exact
error message and the EXACT code that you tested, but only upto a
couple lines after the reported line in the error messages.


------------------------------

Date: Sun, 24 Feb 2008 00:12:03 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Building DBD::Pg on Windows?
Message-Id: <jbp695-mc2.ln1@osiris.mauzo.dyndns.org>


Quoth "Bill Cohagan" <bill@teraXNOSPAMXquest.com>:
> Christoph
>   Thanks for this pointer.  Unfortunately this requires PPM which I 
> attempted to obtain. I couldn't install PPM because the install is 
> apparently not intended for cygwin perl environment. I did manage to hack 
> the install script a get it installed, but then ran into (apparently) cygwin 
> related problems in trying to run it. Ultimately I just downloaded the tar 
> file the the DBD ppd file pointed to, but decompressing just gives me a top 
> level directory with a lot of empty subfolders and a few dlls, etc. I have 
> no idea how to incorporate this into the perl environment so that it is 
> useable.
> 
>   If there is a procedure to follow to manually install such a folder 
> structure I'd appreciate a pointer to it.

I seriously doubt a ppm with dlls linked against AS Perl will work with
Cygwin perl. Have you tried installing DBD::Pg from CPAN, with the CPAN
shell? You will need gcc, make, &c., and the Postgres libs, of course,
but I expect the cygwin setup program will install those for you.

Ben



------------------------------

Date: Sun, 24 Feb 2008 00:07:02 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: checking for duplicates in a string
Message-Id: <62p695-mc2.ln1@osiris.mauzo.dyndns.org>


Quoth Gunnar Hjalmarsson <noreply@gunnar.cc>:
> John wrote:
> > Consider a string $packed consisting of "AAXYGHDRJKYYXYZZGH"
> > This represent items of two chars eg AA XY GH etc.
> > I need to remove duplicates.
> > I can do it by 'unpacking' and repacking using two loops such as
> > 
> > for (my $j=0; $j<$total; $j=$j+2) {
> >     my $part1=substr($packed,$j,2);

Hmm... even if you *did* want to unpack, this is a bad way to do it.
Gunnar's /../g is much better, and unpack '(A2)*' better again.

> > etc  etc.
> > 
> > But is there a better, dare I say, elegant, way?
> 
>      my $packed = 'AAXYGHDRJKYYXYZZGH';
>      my %seen;
>      print join(' ', map $seen{$_}++ ? () : $_, $packed =~ /../g), "\n";

That still unpacks and repacks.

    s/(..)/$seen{$1}++ ? '' : $1/ge;

Ben



------------------------------

Date: Sun, 24 Feb 2008 01:28:44 +0000 (UTC)
From: Vincent Lefevre <vincent+news@vinc17.org>
Subject: CPAN and man page installation
Message-Id: <20080224012425$04b6@prunille.vinc17.org>

With the cpan utility, what configuration option need to be modified
to install the man pages of modules at some place?

Installation currently fails with the following error:

mkdir /usr/local/man/man3: Permission denied at /usr/share/perl/5.8/ExtUtils/Install.pm line 112

So, I need to tell cpan to install the man pages in ~/man/man1
and ~/man/man3.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


------------------------------

Date: Sun, 24 Feb 2008 02:37:35 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: CPAN and man page installation
Message-Id: <fs1795-663.ln1@osiris.mauzo.dyndns.org>


Quoth Vincent Lefevre <vincent+news@vinc17.org>:
> With the cpan utility, what configuration option need to be modified
> to install the man pages of modules at some place?
> 
> Installation currently fails with the following error:
> 
> mkdir /usr/local/man/man3: Permission denied at
> /usr/share/perl/5.8/ExtUtils/Install.pm line 112
> 
> So, I need to tell cpan to install the man pages in ~/man/man1
> and ~/man/man3.

export PERL_MM_OPT="INSTALLMAN1DIR=$HOME/man/man1
    INSTALLMAN3DIR=$HOME/man/man3"

See perldoc ExtUtils::MakeMaker for full details. For Module::Build
modules, you need to create a ~/.modulebuildrc file containing

*   bindoc=~/man/man1 libdoc=~/man/man3

Ben



------------------------------

Date: Sat, 23 Feb 2008 15:28:04 -0800 (PST)
From: mk834tt@yahoo.com
Subject: files, xml and xds; examples of for practice
Message-Id: <38746c67-0b40-48fc-94d0-0d8a1141a25d@e6g2000prf.googlegroups.com>

I'm diving into xml with "XML and Perl", a New Riders book published
in 2003(?).  This "old" book has links to obtain sample files for use
in the examples.  Well, the links are gone or useless now.  Where can
I find some good xml and xml schema files for use in these exercises?
Modifying the code is easier than typing in some of these large
files..

Thank you.


------------------------------

Date: Sat, 23 Feb 2008 23:09:29 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: Get an arbitrary hash key, quickly.
Message-Id: <fpq939$k22$1@reader2.panix.com>

Xho, why do you like this

In <20080129120050.119$y5@newsreader.com> xhoster@gmail.com writes:

>while (keys %hash) {
>   foreach my $to_do (keys %hash) {
>      delete $hash{$to_do};
>      ## do stuff with $to_do, which might
>      # make new entries in %hash
>   }
>}

better than your original

>while (%hash) {    # does not reset iterator
>  my $to_do=each %hash;
>  next unless defined $to_do;  # not a real hash key,
>                               # signals end of iterator
>  ## do stuff with $to_do, which might make new entries in %hash
>};

?

kynn

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


------------------------------

Date: 24 Feb 2008 02:06:59 GMT
From: xhoster@gmail.com
Subject: Re: Get an arbitrary hash key, quickly.
Message-Id: <20080223210702.865$Dq@newsreader.com>

kj <socyl@987jk.com.invalid> wrote:
> Xho, why do you like this
>
> In <20080129120050.119$y5@newsreader.com> xhoster@gmail.com writes:
>
> >while (keys %hash) {
> >   foreach my $to_do (keys %hash) {
> >      delete $hash{$to_do};
> >      ## do stuff with $to_do, which might
> >      # make new entries in %hash
> >   }
> >}
>
> better than your original
>
> >while (%hash) {    # does not reset iterator
> >  my $to_do=each %hash;
> >  next unless defined $to_do;  # not a real hash key,
> >                               # signals end of iterator
> >  ## do stuff with $to_do, which might make new entries in %hash
> >};
>
> ?

I'm not keen on using "scalar %hash", as it is more esoteric than
"scalar keys %hash".  And using the next to cause they "each" to reboot
when it delivers an undefined value is more subtle than I care for.

On the other hand, at this long remove, I am kind of looking kindly on my
original code.  It looks abnormal, which advertises the fact that it
is abnormal and should be tinkered with with caution.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


------------------------------

Date: Sat, 23 Feb 2008 15:24:22 -0800 (PST)
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: I don't understand the Net::Telnet error
Message-Id: <b4954821-3b3e-43c1-b808-2d5ede61c593@q78g2000hsh.googlegroups.com>

On Feb 22, 7:28 pm, "comp.llang.perl.moderated" <c...@blv-
sam-01.ca.boeing.com> wrote:
> On Feb 22, 5:12 pm, grocery_stocker <cdal...@gmail.com> wrote:
>
> > On Feb 22, 3:40 pm, "comp.llang.perl.moderated" <c...@blv-
> >....
> > [cdalten@localhost ~]$ ./bot2.pl
> > Uncaught exception from user code:
> >         problem connecting to host: pattern match timed-out at ./
> > bot2.pl line 24.
> >  at ./bot2.pl line 24
>
> > What package does Dump_Log and Input_log belong to?
>
> perldoc Net::Telnet (see METHODS):
>
>  $obj = new Net::Telnet (
>      ...
>      [Dump_Log   => $filename,]
>      ...
>      [Input_log  => $file,]
>


I'm not seeing the possible error here

[cdalten@localhost ~]$ more input.txt
Last login: Sat Feb 23 18:19:13 2008 from 66-81-69-96.bay
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California.  All rights
reserved.

FreeBSD 6.3-PRERELEASE (MNET) #1: Tue Nov  6 16:13:56 EST 2007

Welcome to FreeBSD!
m-net%
[cdalten@localhost ~]$

[cdalten@localhost ~]$ more dump.txt
< 0x00000: 4c 61 73 74  20 6c 6f 67  69 6e 3a 20  53 61 74 20  Last
login: Sat
< 0x00010: 46 65 62 20  32 33 20 31  38 3a 31 39  3a 31 33 20  Feb 23
18:19:13
< 0x00020: 32 30 30 38  20 66 72 6f  6d 20 36 36  2d 38 31 2d  2008
from 66-81-
< 0x00030: 36 39 2d 39  36 2e 62 61  79 0d 0d 0a  43 6f 70 79
69-96.bay...Copy
< 0x00040: 72 69 67 68  74 20 28 63  29 20 31 39  38 30 2c 20  right
(c) 1980.
< 0x00050: 31 39 38 33  2c 20 31 39  38 36 2c 20  31 39 38 38  1983.
1986. 1988
< 0x00060: 2c 20 31 39  39 30 2c 20  31 39 39 31  2c 20 31 39  . 1990.
1991. 19
< 0x00070: 39 33 2c 20  31 39 39 34  0d 0a 09 54  68 65 20 52  93.
1994...The R
< 0x00080: 65 67 65 6e  74 73 20 6f  66 20 74 68  65 20 55 6e  egents
of the Un
< 0x00090: 69 76 65 72  73 69 74 79  20 6f 66 20  43 61 6c 69
iversity of Cali
< 0x000a0: 66 6f 72 6e  69 61 2e 20  20 41 6c 6c  20 72 69 67
fornia.  All rig
< 0x000b0: 68 74 73 20  72 65 73 65  72 76 65 64  2e 0d 0a 0d  hts
reserved....
< 0x000c0: 0a 46 72 65  65 42 53 44  20 36 2e 33  2d 50 52
45  .FreeBSD 6.3-PRE
< 0x000d0: 52 45 4c 45  41 53 45 20  28 4d 4e 45  54 29 20 23  RELEASE
(MNET) #
< 0x000e0: 31 3a 20 54  75 65 20 4e  6f 76 20 20  36 20 31 36  1: Tue
Nov  6 16
< 0x000f0: 3a 31 33 3a  35 36 20 45  53 54 20 32  30 30 37 0d  :13:56
EST 2007.
< 0x00100: 0a 0d 0a 57  65 6c 63 6f  6d 65 20 74  6f 20 46
72  ...Welcome to Fr
< 0x00110: 65 65 42 53  44 21 0d 0a
eeBSD!..

< 0x00000: 1b 5b 31 6d  1b 5b 37 6d  25 1b 5b 32  37 6d 1b 5b  .[1m.[7m
%.[27m.[
< 0x00010: 31 6d 1b 5b  6d 0f 20 20  20 20 20 20  20 20 20 20  1m.
[m.
< 0x00020: 20 20 20 20  20 20 20 20  20 20 20 20  20 20 20
20
< 0x00030: 20 20 20 20  20 20 20 20  20 20 20 20  20 20 20
20
< 0x00040: 20 20 20 20  20 20 20 20  20 20 20 20  20 20 20
20
< 0x00050: 20 20 20 20  20 20 20 20  20 20 20 20  20 20 20
20
< 0x00060: 20 20 20 20  20 0d                                       .

< 0x00000: 0d 1b 5b 6d  0f 1b 5b 32  37 6d 1b 5b  32 34 6d 1b  ..[m..
[27m.[24m.
< 0x00010: 5b 4a 6d 2d  6e 65 74 25  20 1b 5b 4b               [Jm-net
% .[K

[cdalten@localhost ~]$





------------------------------

Date: Sun, 24 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Feb 24 2008
Message-Id: <JwqAIH.1t5H@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.

Apache2-ASP-Model-CDBI-MySQL-0.01
http://search.cpan.org/~johnd/Apache2-ASP-Model-CDBI-MySQL-0.01/
ORM base class for Apache2::ASP web applications 
----
Apache2-ASP-Model-CDBI-SQLite-0.01
http://search.cpan.org/~johnd/Apache2-ASP-Model-CDBI-SQLite-0.01/
ORM base class for Apache2::ASP web applications 
----
Audio-FLAC-Header-2.0
http://search.cpan.org/~daniel/Audio-FLAC-Header-2.0/
interface to FLAC header metadata. 
----
BecomeUser-1.0
http://search.cpan.org/~abcdefgh/BecomeUser-1.0/
Become any user 
----
Blog-Normalize-0.0rc1
http://search.cpan.org/~damog/Blog-Normalize-0.0rc1/
Specification for a sane transition between different blogging systems 
----
Bundle-Thread-1.04
http://search.cpan.org/~jdhedden/Bundle-Thread-1.04/
A bundle of modules for supporting threads in Perl 
----
Class-AutoGenerate-0.02
http://search.cpan.org/~hanenkamp/Class-AutoGenerate-0.02/
Automatically generate code upon require or use 
----
Class-AutoGenerate-0.03
http://search.cpan.org/~hanenkamp/Class-AutoGenerate-0.03/
Automatically generate code upon require or use 
----
Coat-Persistent-0.0_0.4
http://search.cpan.org/~sukria/Coat-Persistent-0.0_0.4/
Simple Object-Relational mapping for Coat objects 
----
Coat-Persistent-0.0_0.5
http://search.cpan.org/~sukria/Coat-Persistent-0.0_0.5/
Simple Object-Relational mapping for Coat objects 
----
Common-CLI-0.03
http://search.cpan.org/~izut/Common-CLI-0.03/
Command line applications made easy. 
----
Crypt-Cracklib-1.2
http://search.cpan.org/~daniel/Crypt-Cracklib-1.2/
Perl interface to Alec Muffett's Cracklib. 
----
Crypt-OpenSSL-X509-0.6
http://search.cpan.org/~daniel/Crypt-OpenSSL-X509-0.6/
Perl extension to OpenSSL's X509 API. 
----
Data-Path-1.3.fix_missing_build_require
http://search.cpan.org/~zaphar/Data-Path-1.3.fix_missing_build_require/
Perl extension for XPath like accessing from complex data structs 
----
File-Remove-1.40
http://search.cpan.org/~adamk/File-Remove-1.40/
Remove files and directories 
----
HTTP-Body-1.00
http://search.cpan.org/~agrundma/HTTP-Body-1.00/
HTTP Body Parser 
----
HTTP-Body-1.01
http://search.cpan.org/~agrundma/HTTP-Body-1.01/
HTTP Body Parser 
----
JavaScript-Bookmarklet-0.01
http://search.cpan.org/~tima/JavaScript-Bookmarklet-0.01/
utility library and command-line script for converting human-readable JavaScript code into bookmarklet form. 
----
Lingua-Translate-InterTran-0.01
http://search.cpan.org/~hinrik/Lingua-Translate-InterTran-0.01/
A Lingua::Translate backend for InterTran. 
----
Lingua-Translate-InterTran-0.02
http://search.cpan.org/~hinrik/Lingua-Translate-InterTran-0.02/
A Lingua::Translate backend for InterTran. 
----
Lingua-Translate-InterTran-0.03
http://search.cpan.org/~hinrik/Lingua-Translate-InterTran-0.03/
A Lingua::Translate backend for InterTran. 
----
Lingua-Translate-InterTran-0.04
http://search.cpan.org/~hinrik/Lingua-Translate-InterTran-0.04/
A Lingua::Translate backend for InterTran. 
----
Math-Prime-XS-0.19
http://search.cpan.org/~schubiger/Math-Prime-XS-0.19/
Calculate/detect prime numbers with deterministic tests 
----
Music-Tag-0.31
http://search.cpan.org/~ealleniii/Music-Tag-0.31/
Module for collecting information about music files. 
----
Music-Tag-0.32
http://search.cpan.org/~ealleniii/Music-Tag-0.32/
Module for collecting information about music files. 
----
Music-Tag-Amazon-0.3
http://search.cpan.org/~ealleniii/Music-Tag-Amazon-0.3/
Plugin module for Music::Tag to get information from Amazon.com 
----
Music-Tag-Lyrics-0.29
http://search.cpan.org/~ealleniii/Music-Tag-Lyrics-0.29/
Screen Scraping plugin for downloading lyrics from the web. 
----
Music-Tag-LyricsFetcher-0.03
http://search.cpan.org/~ealleniii/Music-Tag-LyricsFetcher-0.03/
Music::Tag plugin to use Lyrics::Fetcher 
----
Music-Tag-MusicBrainz-0.3
http://search.cpan.org/~ealleniii/Music-Tag-MusicBrainz-0.3/
Plugin module for Music::Tag to get information from MusicBrainz database. 
----
Music-Tag-OGG-0.33
http://search.cpan.org/~ealleniii/Music-Tag-OGG-0.33/
Plugin module for Music::Tag to get information from ogg-vorbis headers. 
----
Net-Address-Ethernet-1.109
http://search.cpan.org/~mthurn/Net-Address-Ethernet-1.109/
find hardware ethernet address 
----
POD2-Base-0.04
http://search.cpan.org/~ferreira/POD2-Base-0.04/
Base module for translations of Perl documentation 
----
POE-Component-Lingua-Translate-0.01
http://search.cpan.org/~hinrik/POE-Component-Lingua-Translate-0.01/
A non-blocking wrapper around Lingua::Translate. 
----
POE-Component-Lingua-Translate-0.02
http://search.cpan.org/~hinrik/POE-Component-Lingua-Translate-0.02/
A non-blocking wrapper around Lingua::Translate 
----
POE-Component-Lingua-Translate-0.03
http://search.cpan.org/~hinrik/POE-Component-Lingua-Translate-0.03/
A non-blocking wrapper around Lingua::Translate 
----
Params-Util-0.32_01
http://search.cpan.org/~adamk/Params-Util-0.32_01/
Simple, compact and correct param-checking functions 
----
RPSL-Parser-0.19
http://search.cpan.org/~lmc/RPSL-Parser-0.19/
Router Policy Specification Language (RFC2622) Parser 
----
RTx-BecomeUser-1.0
http://search.cpan.org/~abcdefgh/RTx-BecomeUser-1.0/
Become any user 
----
Sys-Virt-0.1.2
http://search.cpan.org/~danberr/Sys-Virt-0.1.2/
Represent and manage a libvirt hypervisor connection 
----
Test-Parser-1.5.1
http://search.cpan.org/~markwkm/Test-Parser-1.5.1/
Base class for parsing log files from test runs, and displays in an XML syntax. 
----
Test-Simple-0.75
http://search.cpan.org/~mschwern/Test-Simple-0.75/
Basic utilities for writing tests. 
----
Text-Smart-1.0.2
http://search.cpan.org/~danberr/Text-Smart-1.0.2/
Processor for 'smart text' markup 
----
WWW-ImagebinCa-Retrieve-0.01
http://search.cpan.org/~zoffix/WWW-ImagebinCa-Retrieve-0.01/
retrieve uploaded images from <http://imagebin.ca> 


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: Sat, 23 Feb 2008 20:46:52 GMT
From: bfc@fenway.UUCP (Time Waster)
Subject: new variable stupidity
Message-Id: <0D%vj.1950$xg6.1790@trnddc07>

OK, i'm being lazy to ask here. :(

I'm always finding myself doing this:
	$newvar = $oldvar;
	$newvar = s/something/else/;
 ..because i want both of them.  Is there a way to do this in 1 statement?


------------------------------

Date: Sat, 23 Feb 2008 14:55:48 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: new variable stupidity
Message-Id: <slrnfs122k.g4l.tadmc@tadmc30.sbcglobal.net>

Time Waster <bfc@fenway.UUCP> wrote:
> OK, i'm being lazy to ask here. :(
>
> I'm always finding myself doing this:
> 	$newvar = $oldvar;
> 	$newvar = s/something/else/;
> ..because i want both of them.  Is there a way to do this in 1 statement?


   (my $newvar = $oldvar) =~ s/something/else/;


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Sat, 23 Feb 2008 23:09:28 GMT
From: spambait@milmac.com (Doug Miller)
Subject: Re: Number of days since 1/1/2000
Message-Id: <II1wj.12294$J41.2044@newssvr14.news.prodigy.net>

In article <6d84ef25-8ae8-42bb-8dfd-0f2b675c8265@u69g2000hse.googlegroups.com>, oprah.chopra@gmail.com wrote:
>J=FCrgen Exner wrote:
>
>> Why not simply get the current time() and 1/1/2000 in seconds since
>the > epoch and divide the difference between them by 60*60*24?
>> This will be ignore leap seconds, but I doubt that makes any
>difference to > whatever you are computing.
>>
>
>How many PhD's did it take to come up with this solution?

Why are you mocking a solution which is clearly vastly superior to the 
one which you devised?

-- 
Regards,
        Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.


------------------------------

Date: Sat, 23 Feb 2008 23:12:10 GMT
From: spambait@milmac.com (Doug Miller)
Subject: Re: Number of days since 1/1/2000
Message-Id: <eL1wj.12295$J41.7351@newssvr14.news.prodigy.net>

In article <je7mr3lb2t4i95h9esljtdmn467j9ai1dt@4ax.com>, mdonn@harbornet.com wrote:

>Not being a high-power programmer like you folks, I did it this way,
>which should work until 2100.
>
>use strict;
>use warnings;
>my ($y, $yd) = (localtime(time))[5,7];
>my $yrs = $y - 101;
>my $ld = int ($yrs+1)/4;
>my $dif = 365 * $yrs + $ld + $yd;
>$dif++ if $y%4 == 0 && $yd > 59;
>print "$dif\n";
>
>KISS!!

Exactly how is this "simple" in comparison with a simple subtraction of two 
times in seconds, divided by the number of seconds in a day?

-- 
Regards,
        Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.


------------------------------

Date: Sat, 23 Feb 2008 23:15:31 GMT
From: spambait@milmac.com (Doug Miller)
Subject: Re: Number of days since 1/1/2000
Message-Id: <nO1wj.12296$J41.1111@newssvr14.news.prodigy.net>

In article <jccmr3pbis8nvhmm5crhpn1l80cr45g6e2@4ax.com>, mdonn@harbornet.com wrote:

>However, my point, which seems to have been missed by you and the other
>folk, is that the original poster stressed that he/she was concerned
>both about speed and memory.  My code, since it has no loops and does
>not depend on any modules, should be both faster and smaller than all
>the other attempts.  

Doubtful.

Why don't you benchmark that, and get back to us. Bet you a beer that when 
you're done, you find that "should be" has turned into "ain't even close".

-- 
Regards,
        Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.


------------------------------

Date: Sat, 23 Feb 2008 22:12:24 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: PL/Perl: when to set @INC?
Message-Id: <fpq5o8$3c7$1@reader2.panix.com>



This is a question about PL/Perl, PostgreSQL's Perl procedural
language.

I have a database where I want to make heavy use of PL/Perl stored
procedures.  Also, I'd like these procedures to be able to load
Perl modules that reside outside the paths in the default @INC, so
I'd like to modify @INC appropriately as soon as possible after
the PostgreSQL server is started.

Does anyone know how to do this?

TIA!

Kynn

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


------------------------------

Date: Sat, 23 Feb 2008 23:58:07 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: setting %ENV in a module
Message-Id: <fho695-mc2.ln1@osiris.mauzo.dyndns.org>


Quoth pgodfrin <pgodfrin@gmail.com>:
> 
> Howdy - good advice all around. Now my code is really efficient, but
> it still doesn't work <grin>
> 
> #!/usr/bin/perl

Where is

    use warnings;
    use strict;

> use Env;

You don't need this.

> open $rvars,"<","/home/pgodfrin/perl/et/etfile" ;

*Always* check if open failed.
I would recommend using UPPERCASE variable names for filehandles.
I would put the filename in a variable, so you can easily find and
change it later.

    my $Etfile = '/home/.../etfile';

    open my $RCVARS, '<', $Etfile
        or die "can't read $Etfile: $!";

> foreach(<$rvars>)
> {
> 	if (/^export\s+(\w+)=(.+)/)
> 	{

I would capture these into variables rather than using $N. Here you also
need to substitute for $vars in the replacement. This is a rather crude
version; it doesn't honour proper shell quoting, though it does allow \$
for a literal $. If you need real shell interpolation, it's probably
easiest to feed it to /bin/sh with 'exec /usr/bin/env' stuck on the end,
and parse the output.

    if (my ($var, $value) = /^ export \s+ (\w+) = (.+)/x) {
        for ($value) {
            s/ (?<! \\ ) \$ (\w+) /$ENV{$1}/gx;
            s/ \\ (.) /$1/gx;
        }

Ben



------------------------------

Date: Sun, 24 Feb 2008 03:02:44 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: uc() and utf8
Message-Id: <fpqjav$14i4$1@ns.felk.cvut.cz>

I have some data in file coded in windows-1250 (cp1250). My script is written 
in utf-8 codepage and run on perl 5.8.x. I need to convert some strings to 
uppercase but uc() fail. What is the right way?

This example illustrate a problem.

#!/usr/bin/perl
use strict;
use utf8;
use Unicode::Lite;

print "Content-Type: text/html\n\n<html><head>\n",
    "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">",
    "</head>\n<body>";

# string in cp1250 codepage
my $wintxt="\xec\x9a\xe8\xf8\x9e\xfd\xe1\xed\xe9";

# convert to utf8
my $utftxt=convert('CP1250','UTF8',$wintxt);

print "<br>Win: $wintxt, ",uc($wintxt),"<br>utf8:$utftxt, ",uc($utftxt),"\n";
print "</body></html>\n";

-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail from 
another non-spammer site please.)

Please reply to <petr AT practisoft DOT cz>



------------------------------

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 1302
***************************************


home help back first fref pref prev next nref lref last post