[22240] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4461 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 24 09:05:49 2003

Date: Fri, 24 Jan 2003 06:05:11 -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           Fri, 24 Jan 2003     Volume: 10 Number: 4461

Today's topics:
    Re: Advice for relative newbie on perl compiler... <tassilo.parseval@post.rwth-aachen.de>
    Re: Converting a string to a valid date.. <krahnj@acm.org>
    Re: Converting a string to a valid date.. (Tad McClellan)
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
    Re: hash of arrays using variable array names <nobull@mail.com>
    Re: hash of arrays using variable array names <nobull@mail.com>
    Re: hash of arrays using variable array names (Tad McClellan)
    Re: How can I compare two dates and find the difference <me@privacy.net>
    Re: Is there a better way to check to see  if a date li <mothra@nowhereatall.com>
    Re: Is there a better way to check to see  if a date li <mothra@nowhereatall.com>
    Re: Is there a better way to check to see  if a date li <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: Is there a better way to check to see  if a date li <mothra@nowhereatall.com>
    Re: Is there a better way to format numbers to use comm brianr@liffe.com
    Re: Pattern Matching <BROWNHIK@Syntegra.Bt.Co.Uk>
    Re: Pattern Matching (Anno Siegel)
    Re: Perl & CGI Security (Tad McClellan)
    Re: Perl on IIS (run in ASP pages?) Andrew Lee
    Re: Reading French-Accented Data <flavell@mail.cern.ch>
    Re: Reading French-Accented Data (Dave Fraleigh)
    Re: unlink() (Anno Siegel)
    Re: unlink() (Helgi Briem)
    Re: unlink() (Helgi Briem)
    Re: unlink() <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: unlink() (Anno Siegel)
    Re: unlink() (Anno Siegel)
        Use and Require - Perl Modules (Richard Byers)
    Re: Use and Require - Perl Modules <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Use and Require - Perl Modules (Tad McClellan)
    Re: What does this header mean? Andrew Lee
        win32 tieregistry html <nac@advancecare.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Jan 2003 11:31:23 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Advice for relative newbie on perl compiler...
Message-Id: <b0r86b$16p$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Helgi Briem:

> On Thu, 23 Jan 2003 16:05:54 +0000, Adam Cheney
><adamcheney@spamtrap.kiwis.co.uk> wrote:

>>  Second, your opinions on what to use (current favourites are PerlApp 
>>from ActiveState or Perl2Exe from IndigoSTAR)? 
> 
> I have used Perl2exe and found it satisfactory.  
> 
> However, and this is a big but, an exe made by perl2exe
> is simply the script + the perl compiler + any modules
> bundled into one file.  It is not a  true .exe. 
> 
> They are large, typically over 1MB.  Perl2exe has the option
> of bundling perl into a .dll, making each program smaller.
> 
>> (Ideally, I'd like to consider freeware products, too)
> 
> I don't know of any useful ones.

I haven't yet tried it but I heard good things about tinyperl as
available from
    
    http://tinyperl.sf.net/

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 24 Jan 2003 12:47:41 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Converting a string to a valid date..
Message-Id: <3E313592.1E222CCE@acm.org>

Bullet wrote:
> 
> Well, actually - in the initial post I did define the Hash within the sub..
> But I conceded that I shouldnt have done that.. it was a simple
> oversight in my original code which was more written as a test
> case than anything else..
> 
> In fact .. when I posted the results of my test I also posted
> the amended code which I used when I ran the test.
> 
> The main thing I was wondering about speedwise was the way
> split was used to break the string and strip the comma in a one shot
> as opposed to mutliple operations - as well as the use of sprintf to
> format the output ..
> 
> Anyhow.. when run with the Hash defined outside of the sub for both
> my benchmark results were as follows. .
> 
> Benchmark: timing 200000 iterations of modified, original...
>   modified: 24 wallclock secs (24.32 usr +  0.00 sys = 24.32 CPU) @
> 8223.68/s (n=200000)
>   original: 17 wallclock secs (16.89 usr +  0.00 sys = 16.89 CPU) @
> 11841.33/s (n=200000)
>             Rate modified original
> modified  8224/s       --     -31%
> original 11841/s      44%       --
> 
> The sub that used the sprintf function and the fancier split ran noticeably
> slower..
> 
> Since I am figuring on using this function on a website thats heavily taxed
> CPU wise already.. any spare cycles I can save cant hurt..

If you want speed, this is a bit faster:

my %shortmonths =
    qw( Jan 01 Feb 02 Mar 03 Apr 04 May 05 Jun 06
        Jul 07 Aug 08 Sep 09 Oct 10 Nov 11 Dec 12 );

sub d_convert{
    my $conv_date = $_[0];
    $conv_date =~ s/,//;
    my @de = split(/\s/,$conv_date);

    if (length($de[2]) == 1) {
        $de[2] = '0'.$de[2];
    }
    return "$de[3]:$shortmonths{$de[1]}:$de[2] $de[0]"
}

sub d_convert2 {
    ( my $conv_date = $_[0] ) =~ tr/,//d;
    my @de = split ' ', $conv_date;
    return sprintf '%04d-%02d-%02d %s', $de[3], $shortmonths{$de[1]}, @de[2,0];
}

use Benchmark 'cmpthese';

cmpthese( 200_000, {
    Bullet => sub { my $date = d_convert( "17:42:50 Jan 30, 2003 PST" ) },
    Krahn  => sub { my $date = d_convert2( "17:42:50 Jan 30, 2003 PST" ) },
    } );

__END__

Benchmark: timing 200000 iterations of Bullet, Krahn...
    Bullet: 35 wallclock secs (35.21 usr +  0.04 sys = 35.25 CPU) @ 5673.76/s (n=200000)
     Krahn: 30 wallclock secs (30.31 usr +  0.00 sys = 30.31 CPU) @ 6598.48/s (n=200000)
         Rate Bullet  Krahn
Bullet 5674/s     --   -14%
Krahn  6598/s    16%     --



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 24 Jan 2003 06:52:03 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Converting a string to a valid date..
Message-Id: <slrnb32dnj.ee1.tadmc@magna.augustmail.com>

Bullet <no_spam@fromyou.thanks-anyways.com> wrote:

> Well, actually - in the initial post I did define the Hash within the sub..


Please quote some context when you refer to something that
was said earlier.


> Since I am figuring on using this function on a website thats heavily taxed
> CPU wise
> already.. any spare cycles I can save cant hurt..


There may be (s/may be/nearly always is/) a better way to get
a speedup than rearranging the details of mere syntax.

A better algorithm for instance.

Or in your specific application, perhaps mod_perl which will speed
up every program on your website in addition to the one you are
working on right now.


> Obviously theres no wrong way to do it however .. and I learned a lot ..
> basically
> I am just always interested in whether a way that seems like it should be
            ^^^^^^
            ^^^^^^ 
> faster
> actually is when it comes time to run the code..
> 


"We should forget about small efficiencies, say about 97% of the time: 
 premature optimization is the root of all evil." -- Donald Knuth 


Knuth says you should be interested 3% of the time, you say you are
interested 100% of the time.

Knuth is an Awfully Smart Guy. 

Perhaps you should reconsider your approach to optimization.  :-)


(note he said "premature". Can't tell if that is applicable to
 your case or not.
)

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 24 Jan 2003 13:57:01 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1043416515@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            XEmacs port is bundled in XEmacs setup.exe available from
            XEmacs site.

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
        http://www.perl.com/CPAN-local/misc/emacs/cperl-mode/
        <ilya@math.ohio-state.edu>    Ilya Zakharevich

        CPerl is major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr@ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End

-- 

- David Alex Lamb, one of the *.answers moderators
news-answers-request@mit.edu



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

Date: 24 Jan 2003 12:46:41 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: hash of arrays using variable array names
Message-Id: <u94r7y3eby.fsf@wcl-l.bham.ac.uk>

Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

> >>>>> "UG" == Uri Guttman <uri@stemsystems.com> writes:
> 
>     UG> so the upshot is that PLAIN DATA STRUCTURES should not be
>     UG> using the symbol table. if you are, then your code is BAD,
>     UG> BROKEN, WILL SHOOT YOU IN THE FOOT, MURDER YOU IN BED and it
>     UG> will GIVE YOU BAD BREATH.
> 
> You have left out --
> 
> sign you up for all sorts of 'opt-in only' mailing lists,
> sleep with your girlfriend/boyfriend/pets,
> drink all your beer, 
> and cause your cell phone to have terrible reception.

For my take on this see message <u9669c3o2w.fsf@wcl-l.bham.ac.uk>

http://groups.google.com/groups?selm=u9669c3o2w.fsf%40wcl-l.bham.ac.uk

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 24 Jan 2003 12:47:04 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: hash of arrays using variable array names
Message-Id: <u91y323ebb.fsf@wcl-l.bham.ac.uk>

fumail@freeuk.com (qanda) writes:

> Brian McCauley <nobull@mail.com> wrote in message news:<u9y95b3fec.fsf@wcl-l.bham.ac.uk>...

> >   while( <DATA> ) {
> > 	chomp;
> > 	my ($fld0) = split /,/;
> > 	push @{$hoa{$fld0}}, $_;

> > __DATA__
> > aa,f2,f3,f4,line1
> > bb,f2,f3,f4,line2
> > cc,f2,f3,f4,line3
> > dd,f2,f3,f4,line4
> > aa,f2,f3,f4,line5
> > bb,f2,f3,f4,line6

> One question though, when I run your script (copy and paste) I get the
> following:
> Use of uninitialized value in hash element at ./pnga line 12, <DATA>
> line 7.

> Is this a problem?

Not really - it means you added a blank line at the end of the data.

If your true input is likely to contain blank lines then insert
something in your while loop to skip them.  E.g.:

 next unless $_;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 24 Jan 2003 06:23:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: hash of arrays using variable array names
Message-Id: <slrnb32c1b.ee1.tadmc@magna.augustmail.com>

qanda <fumail@freeuk.com> wrote:
> Brian McCauley <nobull@mail.com> wrote in message news:<u9y95b3fec.fsf@wcl-l.bham.ac.uk>...


>> __DATA__
>> aa,f2,f3,f4,line1
>> bb,f2,f3,f4,line2
>> cc,f2,f3,f4,line3
>> dd,f2,f3,f4,line4
>> aa,f2,f3,f4,line5
>> bb,f2,f3,f4,line6

> One question though, when I run your script (copy and paste) I get the
> following:
> Use of uninitialized value in hash element at ./pnga line 12, <DATA>
> line 7.
> Use of uninitialized value in hash element at ./pnga line 12, <DATA>
> line 7.
  ^^^^^^
  ^^^^^^
> Is this a problem?


You left a blank line at the end of the DATA (line 7).

You should always arrange to have no warnings.

If you want to have blank lines in your real data, then modify
the code to skip lines that are blank.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Jan 2003 23:04:37 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: How can I compare two dates and find the difference?
Message-Id: <b0ra4l$se3do$1@ID-172104.news.dfncis.de>


"PerlFAQ Server" <comdog@panix.com> wrote in message
news:b0r6dm$ms5$1@reader1.panix.com...
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
>
> --------------------------------------------------------------------
>
> 4.13: How can I compare two dates and find the difference?
>
>
>     If you're storing your dates as epoch seconds then simply subtract one
>     from the other. If you've got a structured date (distinct year, day,
>     month, hour, minute, seconds values), then for reasons of
accessibility,
>     simplicity, and efficiency, merely use either timelocal or timegm
(from
>     the Time::Local module in the standard distribution) to reduce
>     structured dates to epoch seconds. However, if you don't know the
>     precise format of your dates, then you should probably use either of
the
>     Date::Manip and Date::Calc modules from CPAN before you go hacking up
>     your own parsing routine to handle arbitrary date formats.
>
>
>
> --------------------------------------------------------------------

Not a Perl comment, but would it be useful to mention using ISO date format?

Still amazes the number of people using MMDDYY for datestamps.




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

Date: Fri, 24 Jan 2003 05:27:41 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Is there a better way to check to see  if a date lies within a  certain range of dates
Message-Id: <3e313e79$1@usenet.ugs.com>

Hi John,

[snipped]

> I don't know if it's better but:  :-)
>
>
> use strict;
> use warnings;
>
> my $start_date = '20010104';  # jan 04 2001
> my $end_date   = '20010321';  # mar 21 2001
>
> while ( <DATA> ) {
>     my $test_date = join '', ( /\d+/g )[ 2, 0, 1 ];
>     if ( $test_date >= $start_date and $test_date <= $end_date ) {
>         chomp;
>         print "$_ is between!\n"
>     }
> }
Thanks for responding :-)

This looks good!!

However, (as I mentioned in another post) I do not have control
of the date format :-(
What I am actually doing is parsing a file to retrieve the date and
using that.

Thanks

Mothra




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

Date: Fri, 24 Jan 2003 05:18:41 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Is there a better way to check to see  if a date lies within a certain range of dates
Message-Id: <3e313c5d$1@usenet.ugs.com>

Hello Jürgen,

>
> Of course there is.
>
> > my $start_date = 'jan 04 2001';
> > my $end_date   ='mar 21 2001';
>
> Use a more sensible date format like ISO: "2001-03-21".
> Then your problem is reduced to a trivial textual (aka lexicographic)
> comparison.
>
Thanks for responding :-)

The code I provided is only a sample of what I need to do. What I am
actually doing is extracting the date from a file and Unfortunately I do
not have control of the date format.

But anyway I will remember what you have stated for future reference!!

Thanks

Mothra




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

Date: Fri, 24 Jan 2003 14:29:39 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Is there a better way to check to see  if a date lies within a certain range of dates
Message-Id: <newscache$f5089h$2ye$1@news.emea.compuware.com>

Mothra wrote (Friday 24 January 2003 14:18):

> Hello Jürgen,
> 
>>
>> Of course there is.
>>
>> > my $start_date = 'jan 04 2001';
>> > my $end_date   ='mar 21 2001';
>>
>> Use a more sensible date format like ISO: "2001-03-21".
>> Then your problem is reduced to a trivial textual (aka lexicographic)
>> comparison.
>>
> Thanks for responding :-)
> 
> The code I provided is only a sample of what I need to do. What I am
> actually doing is extracting the date from a file and Unfortunately I do
> not have control of the date format.


I missed the start of the thread, so excuse me if this is a bit off bow:
Date::Manip understands many date formats, including "sunday in 2 weeks".
So if you feed your dates to Date::Manip it will return you a simple date 
string:

    bash$ perl
    use Date::Manip;
    print ParseDate("sunday in 2 weeks"),"\n";
    ^D
    
    2003020900:00:00

Now you can apply Jurgen's comparison solution.

HTH
-- 
KP



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

Date: Fri, 24 Jan 2003 06:01:09 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Is there a better way to check to see  if a date lies within a certain range of dates
Message-Id: <3e314651$1@usenet.ugs.com>

Hi Koos Pol,

> I missed the start of the thread, so excuse me if this is a bit off bow:
> Date::Manip understands many date formats, including "sunday in 2 weeks".
> So if you feed your dates to Date::Manip it will return you a simple date
> string:
>
>     bash$ perl
>     use Date::Manip;
>     print ParseDate("sunday in 2 weeks"),"\n";
>     ^D
>
>     2003020900:00:00
>
> Now you can apply Jurgen's comparison solution.

Thanks for responding :-)

I have tried that (before my orginal posted) and it generates warnings :-(
Here is the script that I have tried:

-----------Broken script ----------------
#!/usr/bin/perl
use Date::Manip;
use strict;
use warnings;

my $start_date = 'jan 04 2001';
my $end_date   ='mar 21 2001';

while (<DATA>)   {


my $test_date = ParseDate("$_");



if ( ($test_date >= ParseDate("$start_date"))
 &&
   ($test_date <= ParseDate("$end_date")))
  {
      chop;
      print "$_ is between!\n"
  }

}

__DATA__
04/09/2002
05/10/2001
02/25/2001
02/01/2001
01/02/2001
--------output--------
[ I removed some of the warnings to keep it short ]

F:\scripts>date.pl
Argument "2001022500:00:00" isn't numeric in numeric ge (>=) at
F:\scripts\date.pl line 16, <DATA> line 3.
Argument "2001032100:00:00" isn't numeric in numeric le (<=) at
F:\scripts\date.pl line 16, <DATA> line 3.
02/25/2001 is between!
Argument "2001010400:00:00" isn't numeric in numeric ge (>=) at
F:\scripts\date.pl line 16, <DATA> line 4.
Argument "2001020100:00:00" isn't numeric in numeric ge (>=) at
F:\scripts\date.pl line 16, <DATA> line 4.
Argument "2001032100:00:00" isn't numeric in numeric le (<=) at
F:\scripts\date.pl line 16, <DATA> line 4.
02/01/2001 is between!
Argument "2001010400:00:00" isn't numeric in numeric ge (>=) at
F:\scripts\date.pl line 16, <DATA> line 5.
Argument "2001010200:00:00" isn't numeric in numeric ge (>=) at
F:\scripts\date.pl line 16, <DATA> line 5.

I guess it does work! however, whenever perl generates warnings it usally
tells
me that I am doing something wrong. This is the reason I did not use this
method.

Anyway, Thanks!!

Mothra




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

Date: 24 Jan 2003 12:38:54 +0000
From: brianr@liffe.com
Subject: Re: Is there a better way to format numbers to use commas?
Message-Id: <vtadhqpvs1.fsf@liffe.com>

Marc Bissonnette <dragnet@internalysis.com> writes:

> Hi all;
> 
> I've got some output that a client insists be formatted with commas every 
> three characters. The code below works perfectly, as far as I can tell, 
> but I am wondering if I just went overboard in how I did it - is there a 
> simpler way than the following to turn 1234567890 into 1,234,567,890 ?

I don't recall seeing anyone suggest this yet, but

use Number::Format qw{format_number};
print format_number(1234567890), "\n";

seems to do the job. Available from a CPAN near you.

HTH

-- 
Brian Raven
I think one fallout from the Halloween debacle is that Microsoft is
rather more aware than they were of how much benefit they're getting
from open source software.
             -- Larry Wall in <199901301945.LAA22023@wall.org>


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

Date: Fri, 24 Jan 2003 13:20:43 -0000
From: "Kevin Brownhill" <BROWNHIK@Syntegra.Bt.Co.Uk>
Subject: Re: Pattern Matching
Message-Id: <b0revp$esd$1@pheidippides.axion.bt.co.uk>

<snipped>

> > BRILLANT suggestion. Way out of the box.
>
> Well, it does have a problem.  The number 12 (used in the example code)
> will match while it shouldn't, as will  all numbers that happen to be
> substrings of one of the given numbers.  One solution is to anchor
> the regex left and right:
>
>     if ( $number =~ /^(?:$numbers)$/ ) {



Have you tried it? - I have and 12 doesn't match, nor does any substring.






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

Date: 24 Jan 2003 13:31:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Pattern Matching
Message-Id: <b0rf7s$l0l$2@mamenchi.zrz.TU-Berlin.DE>

Kevin Brownhill <kevinbrownhill@brooknet.co.uk> wrote in comp.lang.perl.misc:
> <snipped>
> 
> > > BRILLANT suggestion. Way out of the box.
> >
> > Well, it does have a problem.  The number 12 (used in the example code)
> > will match while it shouldn't, as will  all numbers that happen to be
> > substrings of one of the given numbers.  One solution is to anchor
> > the regex left and right:
> >
> >     if ( $number =~ /^(?:$numbers)$/ ) {
> 
> 
> 
> Have you tried it? - I have and 12 doesn't match, nor does any substring.

You are right (I was waiting for someone to point out the error).  The
problem is there, and anchoring the regex is necessary, but it doesn't
bite in the case I said it did.  "12" is indeed not matched, but numbers
longer than the ones in the regex could contain substrings that give
spurious matches.

With pattern matching it pays to keep in mind which is the regex and which
is the string you search for matches.  I had them crossed.

Anno


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

Date: Fri, 24 Jan 2003 06:26:52 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl & CGI Security
Message-Id: <slrnb32c8c.ee1.tadmc@magna.augustmail.com>

Alex Banks <alex@alexbanks.com> wrote:

> Would be grateful if someone could recommend an up-to-date security guide
> for CGI Perl.
      ^^^^^^^^
      ^^^^^^^^  eh?


For CGI:

   perldoc -q CGI

      "How do I make sure users can't enter values into a form that 
       cause my CGI script to do bad things?"

For Perl:

   perldoc perlsec


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Jan 2003 07:22:20 -0500
From: Andrew Lee
Subject: Re: Perl on IIS (run in ASP pages?)
Message-Id: <rlb23v8f2psab4cl6nuntetb74ki1cevt8@4ax.com>

On Wed, 22 Jan 2003 23:13:52 GMT, "MG" <me@home.com> wrote:

>I know ActiveState perl installs PERLIS.DLL into the components portion of
>IIS, I also know that with ASP pages you can specify a language at the
>beginning such as <%@ Language="JScript" %>.  Is there a perl equivilant so
>that I can script perl inside of my web pages? This sounds like a good idea
>since I never did like having to code HTML from inside a perl program (I
>still use templates whenever I can).  Thanks.

I'm not very familiar with ASP, however the ActiveState Documentation
has a nice section on ASP and PerlScript.  I can't seem to get to the
documents online at the moment, but
http://www.activestate.com/Products/ActivePerl/ is a good place to
start.

Cheers


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

Date: Fri, 24 Jan 2003 11:47:56 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Reading French-Accented Data
Message-Id: <Pine.LNX.4.53.0301241112240.26506@lxplus070.cern.ch>

On Jan 23, Dave Fraleigh inscribed on the eternal scroll:

> I'm working on a script that will parse a large amount of data, some
> of which MAY include french (or other extended-ascii characters in the
> 128-150 range).

Oh dear.  There's no such code as "extended-ascii" (there are
literally dozens of registered 8-bit character codings which have
ASCII in their first 128 code positions), but from your implication
that code positions 128-150 would represent displayable characters,
you appear to be referring to non-ISO codings.  Could be a DOS coding
or could be a Windows coding for example.  However, your usenet
posting declares itself to be iso-8859-1.

> Unfortunately, when reading a character with an ASCII
> value beyond the lower-ascii set, it seems to translate the read
> character without much rhyme or reason... I'm wondering why.

Unless you want to handle your data as binary, and organise any
interpretation of its coding yourself, you will need to pay attention
to Perl's handling of character coding, which has been developed over
recent versions and so the results will likely depend on the version
of Perl that you use.

> $line = <INFILE>;
> $line =~ s/\Ç/'cedille'/g;
>
> Instead of printing a Ç character, it prints a &#9567; character.

Whatever you're trying to say, seems to have gotten garbled in the
telling, I'm afraid. Your posting declared itself to be
text/plain;charset=iso-8859-1, and as such, the notation &#9567;
(ampersand, hash, 9567, semicolon) has no particular significance.
Please get into the habit of stating in words what you mean, rather
than trying to rely on a character encoding mechanism that you are
demonstrably having problems with - otherwise the question rates to be
even more confused than the problem which it's trying to describe.

I think your first character is an upper-case C-cedilla, which in
iso-8859-1 (as in Windows-1252) would be 199 decimal, xC7.

If your ampersand-notation is interpreted as an HTML character
reference, it would be the Unicode character U+255F "BOX DRAWINGS
VERTICAL DOUBLE AND RIGHT SINGLE".

If we now on a hunch visit the Unicode cross-mapping tables and
consult the DOS US-American code page CP437:

http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT

we find that the CP437 code point xC7 corresponds to the Unicode
character U+255F.  Bingo.  (xC7 in CP850 means something else, by the
way, so this isn't DOS Latin1 that we're dealing with.)

> Does anybody have any suggestions on
> handling alternative language data (which is still in the ISO latin1
> character set) on a Windows machine?

First of all, CP437 is not "ISO latin1", so something has gone very
wrong here.

And I'm going to seem pedantic, but IME it's necessary to keep a very
clear head when dealing with character codings, so I'm going to point
out that the term Latin-1 denotes a _repertoire_ of characters[1],
which may be represented with various different codings - the Latin-1
repertoire can be represented by iso-8859-1, the ISO Latin-1 coding;
by CP-1047 the EBCDIC Latin-1 coding; the repertoire is also a subset
of Windows-1252 (the proprietary Windows coding for the Latin-1
locale, inappropriately named "ANSI" by its progenitor), also of
CP-850 (DOSLatin1, the DOS Multinational coding for the Latin-1
locale); it's a subset of Unicode itself also.

While it's true that people often use the term "ISO Latin-1" to refer
to the iso-8859-1 coding, I'd have to say that when there's a problem,
then it's best to be sure that we're all speaking the same language
before we start to tackle the details.  And as your presented evidence
suggests a confusion between CP-437 (DOS US-American code page) and
ISO codings, I thought it best to mention that.

Hope that helps towards some kind of clarification, even if it doesn't
directly answer your question.

good luck

[1] the term "character set" has been using in a number of
contradictory ways in different contexts, so, when discussing the
details of such issues, it's best to use a more precise term,
depending on which particular usage is needed:
- character repertoire
- character coding
- "document character set" (in the SGML/HTML sense)
etc.


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

Date: 24 Jan 2003 05:36:30 -0800
From: dave@fraleigh.net (Dave Fraleigh)
Subject: Re: Reading French-Accented Data
Message-Id: <22f677f.0301240536.6dff1ca1@posting.google.com>

> Which version of Perl are you using? 5.8 will need a
> binmode FILEHANDLE, ":encoding(iso8859-1)"
> or some such before Perl can correctly convert Latin-1 into Unicode.
> Also, it's a bad idea to put top-bit-set characters directly in the source,
> unless you know what you're doing. In 5.8 you can do it with the encoding
> pragma, in 5.6.1 you can (I think) use latin1 by default or utf8 with the utf8
> pragma.
> 
> Ben

At present, I'm using 5.6.1 - how do you mean use latin1 by default?


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

Date: 24 Jan 2003 11:41:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: unlink()
Message-Id: <b0r8q5$dpn$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Jay Tilton <tiltonj@erols.com> wrote:
> 
> > Try a debug print immediately before those lines, e.g.
> > 
> >     print "Getting ready to unlink.  This time for sure!\n";
> >     # put unlink()s here
> 
> 
> I like warn() better than print() for making debugging output 
> as STDERR is not buffered like STDIN is.

Alternatively make STDOUT auto-flushing.  The second line of all my
scripts reads

    use strict; use warnings; $| = 1;

"$| = 1" only goes away if the script is going to be used as a
filter.

Anno


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

Date: Fri, 24 Jan 2003 12:45:52 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: unlink()
Message-Id: <3e31355b.1763025536@news.cis.dfn.de>

On Fri, 24 Jan 2003 11:12:27 +0100, Bernard El-Hagin
<bernard.el-hagin@DODGE_THISlido-tech.net> wrote:

>>Then you dare call him rude names.
>>
>>*plonk*
>
>How can you plonk a Code Warrior, Helgi!?

Using my very own Plonk::Warrior module.

-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Fri, 24 Jan 2003 12:48:19 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: unlink()
Message-Id: <3e313590.1763078793@news.cis.dfn.de>

On 24 Jan 2003 11:41:57 GMT,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

>Alternatively make STDOUT auto-flushing.  The second line 
>of all my scripts reads
>
>    use strict; use warnings; $| = 1;

I wonder about this.  Randal does the same.  Was all
the effort OS designers expended on buffering output
really that much of a waste?  You would have thought 
they had some reason for doing it.

I never unbuffer output except  in CGI scripts and have 
never had problems as a result.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Fri, 24 Jan 2003 14:14:00 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: unlink()
Message-Id: <newscache$cfz79h$xxe$1@news.emea.compuware.com>

Helgi Briem wrote (Friday 24 January 2003 13:48):

> On 24 Jan 2003 11:41:57 GMT,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> 
>>Alternatively make STDOUT auto-flushing.  The second line
>>of all my scripts reads
>>
>>    use strict; use warnings; $| = 1;
> 
> I wonder about this.  Randal does the same.  Was all
> the effort OS designers expended on buffering output
> really that much of a waste?  You would have thought
> they had some reason for doing it.


Can it have to do with the time that teletypes were used for STDOUT? I can 
imagine it is very expensive to handle teletype characters one at a time.

-- 
KP



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

Date: 24 Jan 2003 13:22:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: unlink()
Message-Id: <b0remo$l0l$1@mamenchi.zrz.TU-Berlin.DE>

Helgi Briem <helgi@decode.is> wrote in comp.lang.perl.misc:
> On 24 Jan 2003 11:41:57 GMT,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> 
> >Alternatively make STDOUT auto-flushing.  The second line 
> >of all my scripts reads
> >
> >    use strict; use warnings; $| = 1;
> 
> I wonder about this.  Randal does the same.  Was all
> the effort OS designers expended on buffering output
> really that much of a waste?  You would have thought 
> they had some reason for doing it.

If STDOUT is actually a terminal (used interactively), the amount
of output is necessarily small enough for buffering not to matter.
I mean, somebody is supposed to read it.  Things may have been
different when Unix was designed.

> I never unbuffer output except  in CGI scripts and have 
> never had problems as a result.

When you autoflush STDOUT, runtime warnings and normal print output
interleave correctly.  I am easily confused, and seeing a warning
that happens between two print()s not appear between the print()ed
lines is confusing.

Come to think of it, "$| = 1 if -t STDOUT" (or even "$| = -t STDOUT")
might describe clearer the actual intention.

The only case where I regularly unbuffer file output is when I want
to follow the file with "tail -f ...".

Anno


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

Date: 24 Jan 2003 13:40:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: unlink()
Message-Id: <b0rfnt$l0l$3@mamenchi.zrz.TU-Berlin.DE>

Koos Pol  <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote in comp.lang.perl.misc:
> Helgi Briem wrote (Friday 24 January 2003 13:48):
> 
> > On 24 Jan 2003 11:41:57 GMT,
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> > 
> >>Alternatively make STDOUT auto-flushing.  The second line
> >>of all my scripts reads
> >>
> >>    use strict; use warnings; $| = 1;
> > 
> > I wonder about this.  Randal does the same.  Was all
> > the effort OS designers expended on buffering output
> > really that much of a waste?  You would have thought
> > they had some reason for doing it.
> 
> 
> Can it have to do with the time that teletypes were used for STDOUT? I can 
> imagine it is very expensive to handle teletype characters one at a time.

Well, autoflushing does a line at a time.

The teletype itself doesn't mind, it just sits there waiting for the
next character.  However, at that time it was customary to combine
a mainframe with a dedicated subsystem (usually on its own machine) to
do terminal IO.  That system was, of course, much happier to do the
necessary routing and terminal-specific adaptions on a whole block
of data, the more, the merrier.

Anno


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

Date: 24 Jan 2003 03:18:22 -0800
From: richardbyers@talk21.com (Richard Byers)
Subject: Use and Require - Perl Modules
Message-Id: <22a01626.0301240318.38febfd3@posting.google.com>

Hi All

I thought that I have had mastered the very basics of perl. I have
built pages on the fly from a database etc and been able to manipulate
my the content without HTML

But, how do I write the code to call up a module using Use or Require?

Where do I get these modules from?

Do I need to upload them to my server?

Bet this is basic stuff to you guys out there, any advise greatly
received

Many thanks
Richard


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

Date: Fri, 24 Jan 2003 12:35:09 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Use and Require - Perl Modules
Message-Id: <33923vo20p05dcgrkn5c38gbf4ujtrs1m9@4ax.com>

On 24 Jan 2003 03:18:22 -0800, richardbyers@talk21.com (Richard Byers)
wrote:

>Hi All
>
>I thought that I have had mastered the very basics of perl. I have
>built pages on the fly from a database etc and been able to manipulate
>my the content without HTML
>
>But, how do I write the code to call up a module using Use or Require?


perldoc -f use
perldoc -f require


>Where do I get these modules from?


Some are shipped with Perl, others you can find on CPAN:


http://www.cpan.org


>Do I need to upload them to my server?


You can upload them to your server or download them to your server.
Whatever works for you.  ;)


>Bet this is basic stuff to you guys out there, any advise greatly
>received


Check out:


  perldoc perlmod



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Fri, 24 Jan 2003 06:36:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Use and Require - Perl Modules
Message-Id: <slrnb32cqj.ee1.tadmc@magna.augustmail.com>

Richard Byers <richardbyers@talk21.com> wrote:

> I thought that I have had mastered the very basics of perl. 


One of the basics you seem to have missed is the availability
of Perl's Frequently Asked Questions and other standard documentation.


> But, how do I write the code to call up a module using Use or Require?


   perldoc -f use

   perldoc -f require


> Where do I get these modules from?


   perldoc -q module

      "What modules and extensions are available for Perl?  
       What is CPAN?  
       What does CPAN/src/... mean?"

   perldoc perlmodlib

      constructing new Perl modules and finding existing ones


> Do I need to upload them to my server?

   perldoc -q module

      "How do I install a module from CPAN?"

      "How do I keep my own module/library directory?"

   perldoc perlmodinstall

      Installing CPAN Modules


> Bet this is basic stuff to you guys out there, 


Yes, you might say that your Questions are Asked Frequently.


> any advise greatly
> received


Check the Perl FAQ *before* posting to the Perl newsgroup.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Jan 2003 06:06:08 -0500
From: Andrew Lee
Subject: Re: What does this header mean?
Message-Id: <al623vclu61e9ccp9bkh3856ojem7adufa@4ax.com>

On Thu, 23 Jan 2003 18:46:14 -0600, "Brett" <bbsouth@bellsouth.net>
wrote:

>I'm running a CGI script that has an .exe extension on Win2k Server.  The
>.exe extension is linked to run Perl.  I get this message when I run the
>script:
>
>CGI Error
>The specified CGI application misbehaved by not returning a complete set of
>HTTP headers. The headers it did return are:
>Can't open perl script "C:\Inetpub\domain.com\cgi-bin\Count.exe": No such
>file or directory
>
>The directory is correct and file does exist.  Is this coming from the
>script or Perl?  What does it mean exactly?

Stop and think about it for a moment ... what component is printing the
error message?  

Could it be the Web server?

The Web server is telling you that instead of printing :
"Content-type: text/html\n\n" 
(or whatever MIME type you want to send to browser), the cgi program is
printing "Can't open perl script ... "  Which means exactly what it
says.  You have a configuration snafu.  Consult your Web server's
documentation and ask around in an appropriate newsgroup about "HTTP
Headers" or "Server Configuration for /Apache|IIS|Other/."



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

Date: Fri, 24 Jan 2003 12:30:55 -0000
From: "Nuno Cancelo" <nac@advancecare.com>
Subject: win32 tieregistry html
Message-Id: <7maY9.1994$ex.834666@newsserver.ip.pt>

hi
i'm making a perl script to  identify the current logged username in the
system.
this is the script
#!c:\perl\bin\perl
use Win32::TieRegistry;
$username=$Registry->{"HKEY_CURRENT_USER\\Software\\Microsoft\\"
 . "Windows\\CurrentVersion\\Explorer\\\\Logon User Name"};



print "Content-type: text/html\n\n";
print "<html>";
print "$username";
print "</html>";


Now the problem.

when i run it on dos prompt window, it gives what i whant, but

when i run it on Internet Explorer, nothing is shown, and i can't figure it
out why.

Can anyone help me?

thanks

Nuno Cancelo







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

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.  

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 V10 Issue 4461
***************************************


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