[18152] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 320 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 20 11:05:43 2001

Date: Tue, 20 Feb 2001 08:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982685110-v10-i320@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 20 Feb 2001     Volume: 10 Number: 320

Today's topics:
    Re: Array length (Gwyn Judd)
    Re: Change unknown filenames <bart.lateur@skynet.be>
    Re: chop and chomp <flavell@mail.cern.ch>
    Re: chop and chomp <jasonahood@netmatters.co.uk>
    Re: chop and chomp <comdog@panix.com>
    Re: dumbo newbie question - -T (Abigail)
    Re: dumbo newbie question - -T <njh%smsltd.demon.co.uk@nospam.demon.co.uk>
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
        Execution external programs <J.banaszak@shu.ac.uk>
    Re: Execution external programs blah@blah.blah.invalid
    Re: FAQ 4.48:   How do I select a random element from a (Gwyn Judd)
        Java servlets and CGI <jsmith@cecioni.com>
    Re: Java servlets and CGI <beable@my-deja.com>
    Re: Java servlets and CGI <jsmith@cecioni.com>
    Re: perl irc channel (Gwyn Judd)
    Re: perl irc channel <comdog@panix.com>
    Re: PROPOSAL: Graphics::ColorNames <sam@illuminated.co.uk>
    Re: PROPOSAL: Graphics::ColorNames (Abigail)
    Re: PROPOSAL: Graphics::ColorNames <sam@illuminated.co.uk>
    Re: PROPOSAL: Graphics::ColorNames <bmb@ginger.libs.uga.edu>
    Re: PROPOSAL: Graphics::ColorNames (Abigail)
    Re: QUE: Constant subroutine ..... undefined at (Anno Siegel)
    Re: Specifying the length of regular expression (Greg Bacon)
        Well, looks like ANOTHER bug in perl-5.6.0 <morozov@novosoft.ru>
    Re: Well, looks like ANOTHER bug in perl-5.6.0 (Steven Smolinski)
        What's wrong with this script? <ge@do.com>
    Re: What's wrong with this script? <josef.moellers@fujitsu-siemens.com>
    Re: What's wrong with this script? <ge@do.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 20 Feb 2001 11:53:06 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Array length
Message-Id: <slrn994ml0.tkb.tjla@thislove.dyndns.org>

I was shocked! How could wavetable <x@x.x>
say such a terrible thing:
>Although this seems like a simple task I couldn't find how to do it in the
>FAQ. Does anyone know how/if it is possible to get the length of an array?

Yeah it's not exactly obvious. To get the length of the array @ary:

$length = @ary; # evaluate in scalar context

$length = scalar @ary; # same, explicitly

$length = $#ary + 1; # $#ary gives the index of the last item in @ary

What you can't use is the 'length' function which does something
different. I've no idea why it isn't overloaded to give the length of
the array if you pass it one.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Down by the old model T,
Where she first showed it to me.
	It was furry and black,
	And she called it a crack,
But it looked like a manhole to me.


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

Date: Tue, 20 Feb 2001 15:19:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Change unknown filenames
Message-Id: <rk259tkaervson4svl76bibe2lm7euhuno@4ax.com>

BUCK NAKED1 wrote:

>I'm trying to change all of the filenames in a directory called $tmpdir
>to .txt if they end in .pl, .cgi, or .exe. I don't know what the
>filenames in the directory are. Why won't this code change all of the
>cgi, .pl, and .exe extensions to .txt, and do it recursively?
>
>while (glob $tmpdir) { 
>-f =~ s/\.cgi|\.pl|\.exe$/\.txt/ig 
>   };

Mainly because you're not actually renaming the files?

That "-f =~ " looks like nonsense, too.

But if you insist on have a function that works recursively, the best
idea is to use File::Find. Try something like this:

	use File::Find;
	find sub {
	    -f or return;
	    (my $new = $_) =~ s/\.(pl|cgi|exe)$/.txt/i and
	        rename $_, $new;
	}, $tempdir;

-- 
	Bart.


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

Date: Tue, 20 Feb 2001 11:49:41 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: chop and chomp
Message-Id: <Pine.LNX.4.30.0102201148400.13555-100000@lxplus003.cern.ch>

On 20 Feb 2001, Another Way wrote:

> hey
> whats the diff. between chop and chomp

What's the difference between reading the freely-available
documentation that's installed with Perl, and posting to the
world-wide usenet community and waiting to be flamed?




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

Date: Tue, 20 Feb 2001 15:07:04 -0000
From: "Jason Hood" <jasonahood@netmatters.co.uk>
Subject: Re: chop and chomp
Message-Id: <3a928809_1@news2.vip.uk.com>

Allright.... you got me on that one.

"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn994fdl.lgi.bernard.el-hagin@gdndev32.lido-tech...
> On Tue, 20 Feb 2001 02:25:27 -0500, Chandramohan Neelakantan
> <ncmncm@MailAndNews.com> wrote:
> >>===== Original Message From anotherway83@aol.com (Another Way) =====
> >>hey
> >>whats the diff. between chop and chomp (please don't say sumthing like
"chomp
> >>has an M, chop doesn't", lol)they seem to work the same way
> >>
> >>thanks
> >>peace
> >
> >
> >chomp removes the newline at the end of the string on which it was
called,if
> >it exists.
>
> That's not entirely accurate. chomp removes whatever $\ is set to,
> whether it's a newline or not.
>
> >chop removes the last character of the string on which it was called
>
> And returns it.
>
> Cheers,
> Bernard
> --
> #requires 5.6.0
> perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$
?] }'




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

Date: Tue, 20 Feb 2001 07:33:10 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: chop and chomp
Message-Id: <comdog-82C6A2.07331020022001@news.panix.com>

In article <slrn994fdl.lgi.bernard.el-hagin@gdndev32.lido-tech>, 
bernard.el-hagin@lido-tech.net wrote:

> That's not entirely accurate. chomp removes whatever $\ is set to,
> whether it's a newline or not.

chomp removes whatever $/ ($INPUT_RECORD_SEPARATOR).  

    http://www.perldoc.com/perl5.6/pod/func/chomp.html

-- 
brian d foy <comdog@panix.com>



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

Date: 20 Feb 2001 13:12:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: dumbo newbie question - -T
Message-Id: <slrn994r9b.ii5.abigail@tsathoggua.rlyeh.net>

Nigel Horne (njh%smsltd.demon.co.uk@nospam.demon.co.uk) wrote on MMDCCXXX
September MCMXCIII in <URL:news:96tq8j$m2r7m$1@ID-61327.news.dfncis.de>:
// I just can't find the answer to this question wherever I look.
// 
// What is the -T runtime argument? It's often coupled with -w (which I do 
// understant).


You didn't look in the right place.

"man perl" will withing the first 40 lines tell you where to look.



Abigail
-- 
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/                xor      !@ _?
       exit print                                                  :
            print and push @_ => shift and goto &{(caller (0)) [3]}}
            split // => "KsvQtbuf fbsodpmu\ni flsI "  xor       & _


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

Date: Tue, 20 Feb 2001 13:13:41 +0000
From: Nigel Horne <njh%smsltd.demon.co.uk@nospam.demon.co.uk>
Subject: Re: dumbo newbie question - -T
Message-Id: <96tqgm$mft7d$1@ID-61327.news.dfncis.de>

Got it under "man perlrun".

-- 
Nigel Horne. Arranger, Composer, Conductor, Typesetter.
Owner of the brass band group of the Internet. ICQ#20252325
njh@bandsman.co.uk http://www.bandsman.co.uk/music.htm



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

Date: 20 Feb 2001 15:48:03 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_982684026@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/Emacs, is available to various platforms:

        o   Unix:
            If you don't have one, bust your sysadm.
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/
            Emacs resources at http://home.eu.org/~jari/emacs-elisp.html

        o   W9x/NT:
            http://www.gnu.org/software/emacs/windows/ntemacs.html

Emacs Perl Modules

    Cperl -- Perl programming mode

        .ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
        .<olson@mcs.anl.gov>           Bob Olson (started 1991)
        .<ilya@math.ohio-state.edu>    Ilya Zakharevich

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

    TinyPerl -- Perl related utilities

        .http://home.eu.org/~jari/tiny-tools-beta.zip
        .http://home.eu.org/~jari/emacs-tiny-tools.html

        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   Load source code into Emacs, like Devel::DProf.pm
        o   Grep through all Perl manpages (.pod)
        o   Follow POD manpage references to next pod page with TinyUrl
        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   TinyUrl is used to jump to URLs (other pod pages, man pages etc)
            mentioned in POD pages. (It's a general URL minor mode)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in the tgz mentioned above]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example in the tgz (ema-tigr.ini) that shows
        how to set up datatbases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to run the find for you, You can adjust
        recursive grep options, ignored case, add user grep options.

        You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
        Check also ftp://ftp.ihs.com/pub/kevinr/

    TinyCompile -- Browsing grep results in Emacs *compile* buffer

        TinyCompile is minor mode for *compile* buffer from where
        you can collapse unwanted lines, shorten the 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



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

Date: Tue, 20 Feb 2001 11:00:36 +0000
From: Kuba Banaszak <J.banaszak@shu.ac.uk>
Subject: Execution external programs
Message-Id: <3A924E54.7DD54EF7@shu.ac.uk>

For example I am trying to start notepad.exe by using perl function
system()

system("notepad.exe myfile.txt");

The notepad is starting and opening myfil.txt but the results are not
visible on the screen (process is starting)

What's wrong?




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

Date: 20 Feb 2001 13:54:17 GMT
From: blah@blah.blah.invalid
Subject: Re: Execution external programs
Message-Id: <96tsu9$4ami$1@newssvr06-en0.news.prodigy.com>

Kuba Banaszak <J.banaszak@shu.ac.uk> wrote:
> For example I am trying to start notepad.exe by using perl function
> system()

> system("notepad.exe myfile.txt");

> The notepad is starting and opening myfil.txt but the results are not
> visible on the screen (process is starting)

> What's wrong?

What are you talking about?  What results?  You do realize that
nothing after the "system" statement in your perl script will be
executed until *after* notepad is closed, right?

 .blah


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

Date: Tue, 20 Feb 2001 11:54:51 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <slrn994mo9.tkb.tjla@thislove.dyndns.org>

I was shocked! How could Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
say such a terrible thing:
>Godzilla! <godzilla@stomp.stomp.tokyo> wrote in comp.lang.perl.misc:

>Fascinating.  Firm self-confidence, justified by absolutely nothing.

Don't worry about it old man, she's quite insane. Come away before you
get some on you.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Of course a platonic relationship is possible -- but only between
husband and wife.


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

Date: Tue, 20 Feb 2001 13:29:44 +0100
From: John Smith <jsmith@cecioni.com>
Subject: Java servlets and CGI
Message-Id: <3A926338.2BFF96DB@cecioni.com>


Hallo, I have a bunch of Kava classes which I use with servlets.

Is there any way that I can wrap those classes in some way that
CGI scripts can access and use them?

thank you

John


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

Date: Tue, 20 Feb 2001 12:52:16 GMT
From: Beable van Polasm <beable@my-deja.com>
Subject: Re: Java servlets and CGI
Message-Id: <m3g0h9le2d.fsf@beable.van.polasm.bigpond.net.au>

John Smith <jsmith@cecioni.com> writes:
> Hallo, I have a bunch of Kava classes which I use with servlets.
> 
> Is there any way that I can wrap those classes in some way that
> CGI scripts can access and use them?

Why not ask in a CGI newsgroup? Or a Java newsgroup? Or a
servlet newsgroup?

cheers
Beable van Polasm
-- 
Juan Antonio Samaranch: Aussie, Aussie, Aussie.
Audience: OI! OI! OI!
Juan Antonio Samaranch: Well done.


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

Date: Tue, 20 Feb 2001 16:24:06 +0100
From: John Smith <jsmith@cecioni.com>
To: Beable van Polasm <beable@my-deja.com>
Subject: Re: Java servlets and CGI
Message-Id: <3A928C16.C30CDF50@cecioni.com>


I couldn't find a Servlet newsgroup. Java newsgroups are too generic
and this question is probably too different from what CGI people normally
do.

On the other hand, CGI is mostly done in Perl, so Perl gurus are
much more likely to have a valid answer to this question, IMO.

Now, can you help or do you prefer to keep silent?

John

Beable van Polasm wrote:
> 
> John Smith <jsmith@cecioni.com> writes:
> > Hallo, I have a bunch of Kava classes which I use with servlets.
> >
> > Is there any way that I can wrap those classes in some way that
> > CGI scripts can access and use them?
> 
> Why not ask in a CGI newsgroup? Or a Java newsgroup? Or a
> servlet newsgroup?
>


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

Date: Tue, 20 Feb 2001 11:46:45 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: perl irc channel
Message-Id: <slrn994m92.tkb.tjla@thislove.dyndns.org>

I was shocked! How could brian d foy <comdog@panix.com>
say such a terrible thing:

>Randal doesn't necessarily work for himself. i think you assume to
>much.

Well I wouldn't want to speak for him. Nevertheless I thought he was
more or less self employed, freelance or something.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Any two philosophers can tell each other all they know in two hours.
		-- Oliver Wendell Holmes, Jr.


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

Date: Tue, 20 Feb 2001 07:30:15 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: perl irc channel
Message-Id: <comdog-136931.07301520022001@news.panix.com>

In article <slrn994m92.tkb.tjla@thislove.dyndns.org>, 
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:

> I was shocked! How could brian d foy <comdog@panix.com>
> say such a terrible thing:
> 
> >Randal doesn't necessarily work for himself. i think you assume to
> >much.

> Well I wouldn't want to speak for him. Nevertheless I thought he was
> more or less self employed, freelance or something.

you thought incorrectly, in this case.  however, i know he is
bound by an NDA not to talk about it because i interviewed with
the same people. ;)

-- 
brian d foy <comdog@panix.com>



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

Date: Tue, 20 Feb 2001 11:18:13 +0000
From: Sam Kington <sam@illuminated.co.uk>
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <3A925274.7BD6C5AE@illuminated.co.uk>

Abigail wrote:
> 
> Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
> in <URL:news:3A91BFA2.47AF8B2E@illuminated.co.uk>:
> !! Yes, dbm files are an obvious Good Idea. But good luck on your
> !! supporting them. (Your ExtUtils::MakeMaker rules, in particular, are
> !! going to be pretty ugly - unless you know something I don't. Mail me for
> !! more details.)
> 
> Why would they need to be pretty ugly? use AnyDBM_File should take care
> of most of the problems, right?

Depends on where you put the DBM files, and how you cope with DBM files
having different suffixes (and being in either one or two files) on
different platforms. If you don't explicitly know, in the module, where
the DBM files are (because, say, you've installed them in the same
directory as the module, which could be any one of the entries in @INC),
you'll have to look for foo.db, foo.dir (or possibly foo.pag) and foo,
just to be sure.

Sam
-- 
Home page: http://www.illuminated.co.uk/
INWO Homebrew: http://www.illuminated.co.uk/inwo/
I spilled spot remover on my dog. He's gone now.


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

Date: 20 Feb 2001 11:52:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <slrn994mjn.ii5.abigail@tsathoggua.rlyeh.net>

Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
in <URL:news:3A925274.7BD6C5AE@illuminated.co.uk>:
~~ Abigail wrote:
~~ > 
~~ > Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
~~ > in <URL:news:3A91BFA2.47AF8B2E@illuminated.co.uk>:
~~ > !! Yes, dbm files are an obvious Good Idea. But good luck on your
~~ > !! supporting them. (Your ExtUtils::MakeMaker rules, in particular, are
~~ > !! going to be pretty ugly - unless you know something I don't. Mail me for
~~ > !! more details.)
~~ > 
~~ > Why would they need to be pretty ugly? use AnyDBM_File should take care
~~ > of most of the problems, right?
~~ 
~~ Depends on where you put the DBM files, and how you cope with DBM files
~~ having different suffixes (and being in either one or two files) on
~~ different platforms. If you don't explicitly know, in the module, where
~~ the DBM files are (because, say, you've installed them in the same
~~ directory as the module, which could be any one of the entries in @INC),
~~ you'll have to look for foo.db, foo.dir (or possibly foo.pag) and foo,
~~ just to be sure.


*boggle*

Why?

The various DBM modules take care of the extension. If your program needs
to manipulate the files directly, your design is severely b0rken.


Abigail
-- 
sub TIESCALAR {bless \$_} sub STORE {local $_ = pop; print} tie $_ => $_;
($_ => $_ => $_ => $_) = split /(?<=\s)/ => "Just another Perl Hacker\n";


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

Date: Tue, 20 Feb 2001 14:08:15 +0000
From: Sam Kington <sam@illuminated.co.uk>
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <3A927A4E.3C33F0FD@illuminated.co.uk>

Abigail wrote:
> 
> Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
> in <URL:news:3A925274.7BD6C5AE@illuminated.co.uk>:
> ~~ Depends on where you put the DBM files, and how you cope with DBM files
> ~~ having different suffixes (and being in either one or two files) on
> ~~ different platforms. If you don't explicitly know, in the module, where
> ~~ the DBM files are (because, say, you've installed them in the same
> ~~ directory as the module, which could be any one of the entries in @INC),
> ~~ you'll have to look for foo.db, foo.dir (or possibly foo.pag) and foo,
> ~~ just to be sure.
> 
> *boggle*
> 
> Why?
> 
> The various DBM modules take care of the extension. If your program needs
> to manipulate the files directly, your design is severely b0rken.

I'm not talking about manipulating the files directly (thank God), I'm
talking about finding out where they are in the first place.

Sam
-- 
Home page: http://www.illuminated.co.uk/
INWO Homebrew: http://www.illuminated.co.uk/inwo/
I spilled spot remover on my dog. He's gone now.


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

Date: Tue, 20 Feb 2001 09:33:11 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <Pine.A41.4.21.0102200922490.9562-100000@ginger.libs.uga.edu>

On Tue, 20 Feb 2001, Sam Kington wrote:

> Abigail wrote:
> > 
> > Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
> > in <URL:news:3A91BFA2.47AF8B2E@illuminated.co.uk>:
> > !! Yes, dbm files are an obvious Good Idea. But good luck on your
> > !! supporting them. (Your ExtUtils::MakeMaker rules, in particular, are
> > !! going to be pretty ugly - unless you know something I don't. Mail me for
> > !! more details.)
> > 
> > Why would they need to be pretty ugly? use AnyDBM_File should take care
> > of most of the problems, right?
> 
> Depends on where you put the DBM files, and how you cope with DBM files
> having different suffixes (and being in either one or two files) on
> different platforms. If you don't explicitly know, in the module, where
> the DBM files are (because, say, you've installed them in the same
> directory as the module, which could be any one of the entries in @INC),
> you'll have to look for foo.db, foo.dir (or possibly foo.pag) and foo,
> just to be sure.


Personally, I'm fond of data files I can edit with vi.  Since the colors
would presumably be read-only, why not a combination of Search::Dict and
Interpolation?  The data file might look like this:

black,000000
blue,0000ff
green,00ff00
red,ff0000
white,ffffff

Am I crazy?

Brad



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

Date: 20 Feb 2001 15:20:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <slrn9952pd.ii5.abigail@tsathoggua.rlyeh.net>

Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
in <URL:news:3A927A4E.3C33F0FD@illuminated.co.uk>:
-- Abigail wrote:
-- > 
-- > Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
-- > in <URL:news:3A925274.7BD6C5AE@illuminated.co.uk>:
-- > ~~ Depends on where you put the DBM files, and how you cope with DBM files
-- > ~~ having different suffixes (and being in either one or two files) on
-- > ~~ different platforms. If you don't explicitly know, in the module, where
-- > ~~ the DBM files are (because, say, you've installed them in the same
-- > ~~ directory as the module, which could be any one of the entries in @INC),
-- > ~~ you'll have to look for foo.db, foo.dir (or possibly foo.pag) and foo,
-- > ~~ just to be sure.
-- > 
-- > *boggle*
-- > 
-- > Why?
-- > 
-- > The various DBM modules take care of the extension. If your program needs
-- > to manipulate the files directly, your design is severely b0rken.
--
-- I'm not talking about manipulating the files directly (thank God), I'm
-- talking about finding out where they are in the first place.


They will be there where "make install" puts them. I will admit that
find an appropriate place might give you some difficulties, but since
the dbm file isn't there yet, it's extension to be will not be a problem.

Not that it would be any problem in creating a dbm file with AnyDBM_File
in ./blib and see what's actually being created.


Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 20 Feb 2001 11:54:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: QUE: Constant subroutine ..... undefined at
Message-Id: <96tlsq$2h5$1@mamenchi.zrz.TU-Berlin.DE>

Mihalis Tsoukalos  <mike@acropolis.net> wrote in comp.lang.perl.misc:
>Hello to every one.

Hey!  What about us twos?

>I get the following when I am trying to run a perl script
>(running as a service):
>
>noemon@eugenia:~/NOEMON/service > ./noemon.pl
>Constant subroutine __stub_lgammal redefined at
>/usr/lib/perl5/site_perl/5.005/i586-linux/gnu/stubs.ph line 58.
>Constant subroutine __stub_lgammal_r redefined at
>/usr/lib/perl5/site_perl/5.005/i586-linux/gnu/stubs.ph line 64.
>Constant subroutine __need___va_list undefined at
>/usr/lib/perl5/site_perl/5.005/i586-linux/stdarg.ph line 9.
>noemon@eugenia:~/NOEMON/service >
>
>Does anyone know what might cause those errors?

You have a bug in line 17.

Seriously, how do you suppose anyone could diagnose your problem
without knowing what your script contains?

>Do I have to worry about them?

Probably not, as far as the function of the rest of the program is
concerned.  These are warnings.  For a more explicit explanation
look them up in perldiag or include "use diagnostics" at the top
of your script.  You may want to get rid of the spurious output
anyhow.

>What can I do to fix them?

Who knows.  Par down your script so that it demonstrates the behavior
in as few lines as possible and post it.

Anno


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

Date: Tue, 20 Feb 2001 15:16:26 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Specifying the length of regular expression
Message-Id: <t952ias50rh9ae@corp.supernews.com>

In article <96saje$sne$1@news.netmar.com>,
     <ianb@ot.com.au> wrote:

: In article <t92nbv22nllh2e@corp.supernews.com>, Greg Bacon
: <gbacon@HiWAAY.net> writes:
:
: >When doesn't one have a choice?
: 
: I provided a justification in my original post, but I'll try
: again. Sometimes you aren't writing the code, and you can only write
: the regex. For example, you are using a third-party module which
: requires you to specify a regex (or a file containing hundreds of regexes)
: for validation purposes, or for matching "interesting" log messages. You
: can't modify the module, so you just write an appropriate regex. These
: cases are rare, but they do happen.

I know you objected to the distinction before, but matching strings of
the form A+B*C+ that are at least ten characters in length is an
academic problem.  Introduce concatenations, character classes,
alternations, lookaheads, and so forth to severely complicate the
problem.

I would argue the a module like the one you've described is
unnecessarily limited.  Giving the user the option of providing a
coderef to check individual strings or filter lists of strings would
yield considerably more flexibility.

: The other variation on this theme is where you have written the code
: yourself, but you need to use many regexes (e.g. in a loop). On the
: odd occasion, you want to do something fancier, but you can't
: just change the logic since the extra code applies to only one case, and
: you don't want the overhead, bug potential or security concerns of
: allowing arbitrary expressions to be evaluated each time.

Maybe I'm just unimaginative, but what's wrong with

    for (@strings) {
        if (/$monster_regular_expression/o) { ... }
        elsif (/^(A+B*C+)$/ && length($1) > 10) { ... }
    }

As for security concerns, there are patterns that can push the regular
expression matcher into exponential time, so, if you're concerned about
denial of service, you shouldn't allow untrusted users to specify
arbitrary regular expressions.

: Trying to improve the clarity of code is something I deal with every
: day. I also think the issue is interesting from an academic point of
: view, but I was posting from a pragmatic point of view. Sometimes you
: don't have much choice, and you have to get your hands dirty to solve
: a problem.

Sure you do.  You can choose to continue working around an incomplete
or awkward interface (with respect to your needs), or you can update
the interface to make your life easier.

Greg
-- 
The magic words are squeamish ossifrage.


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

Date: 20 Feb 2001 15:20:01 GMT
From: Alexey Morozov <morozov@novosoft.ru>
Subject: Well, looks like ANOTHER bug in perl-5.6.0
Message-Id: <96u1v1$uv8$1@news.itfs.nsk.su>

Well, consider the code below

======================================================
#!/usr/bin/perl -w

use strict;
use diagnostics;

sub bad_func
  {
    my ($key) = @_;
    my %hash = (
		'key1' => 'value1',
		'key2' => 'value2',
	       );
    return unless $hash{$key};
    return $hash{$key};
  }

sub value1 { return bad_func('key1'); }
sub value2 { return bad_func('key2'); }
sub value3 { return bad_func('key3'); }
sub value4 { my $r = bad_func('key4'); return $r; }

testfunc('key1',value1(),'key2',value2(),'key3',value3(),'key4',value4());

sub testfunc
  {
    foreach my $elem (@_)
      {
	print "Got ".((defined $elem) ? "'$elem'" : 'undef')."\n";
      }
  }
==================================================================
It produces the following:
Got 'key1'
Got 'value1'
Got 'key2'
Got 'value2'
Got 'key3'
Got 'key4'
Got undef
===================================================================
Just wonder why I got NO VALUE AT ALL even undef for value3() call.
As you probably guessed I passed to the testfunc a hash initially and got
a totally insane result. You'll be probably interested that bad_func
was initially CGI->param() (w/ properly constructed CGI object of course).
So we have a completely unclear behaviour in so simple and clear looking
code. I'm totally disappointed.


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

Date: Tue, 20 Feb 2001 15:54:14 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: Well, looks like ANOTHER bug in perl-5.6.0
Message-Id: <slrn99598m.3ve.sjs@ragnar.stevens.gulch>

Alexey Morozov <morozov@novosoft.ru> wrote:

Subject: Re: Well, looks like ANOTHER bug in perl-5.6.0

I got the same result on 5.005.  And it's documented, I believe.

> ======================================================
> #!/usr/bin/perl -w
> 
> use strict;
> use diagnostics;
> 
> sub bad_func
>   {
>     my ($key) = @_;
>     my %hash = (
> 		'key1' => 'value1',
> 		'key2' => 'value2',
> 	       );
>     return unless $hash{$key};
>     return $hash{$key};
>   }
> 
> sub value1 { return bad_func('key1'); }
> sub value2 { return bad_func('key2'); }
> sub value3 { return bad_func('key3'); }
> sub value4 { my $r = bad_func('key4'); return $r; }
> 
> testfunc('key1',value1(),'key2',value2(),'key3',value3(),'key4',value4());

value3() here is in list context.  Watch it propagate.  value3() returns
the return value from bad_func().  bad_func(), in this case, calls
return without an expression.  My manual page says:

       return EXPR

        [...]If no EXPR is given, returns
        an empty list in list context, the undefined
        value in scalar context, and (of course)
        nothing at all in a void context.

And what happens to a list with empty lists as elements?  They are left
out:

$ perl -e 'my @flat=(1,2,3,(),( (),(),() ),4); print scalar @flat, "\n";'
4
$

[... snip more code ...]

> Just wonder why I got NO VALUE AT ALL even undef for value3() call.
> As you probably guessed I passed to the testfunc a hash initially and got
> a totally insane result. 

This should work.  I thought a hash's keys and values had to be scalar
values, and so couldn't contain an empty list.  So I don't know what
your problem there is.

> You'll be probably interested that bad_func
> was initially CGI->param() (w/ properly constructed CGI object of course).
> So we have a completely unclear behaviour in so simple and clear looking
> code. I'm totally disappointed.

The docs are your friend.  Don't rely on 'clear looking' as a guide to
correctness.

Steve
-- 
Steven Smolinski => http://www.steven.cx/


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

Date: Tue, 20 Feb 2001 13:10:44 +0200
From: "Dan" <ge@do.com>
Subject: What's wrong with this script?
Message-Id: <96tj6f$5bt$1@news.kolumbus.fi>

What's wrong with the following script? It should print out each character
of a line of text (exept the last character in the line) but instead it
prints 2 characters at a time? Thanks for any help...

for($j = 0; $j < length($characters) - 1; $j++)
{
print (",", substr($characters, $j, $j + 1));
}





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

Date: Tue, 20 Feb 2001 12:17:42 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: What's wrong with this script?
Message-Id: <3A925256.5312D827@fujitsu-siemens.com>

Dan wrote:
> =

> What's wrong with the following script? It should print out each charac=
ter
> of a line of text (exept the last character in the line) but instead it=

> prints 2 characters at a time? Thanks for any help...
> =

> for($j =3D 0; $j < length($characters) - 1; $j++)
> {
> print (",", substr($characters, $j, $j + 1));
> }

The problem lies between your ears (SCNR).
The substr function of Perl requires the third argument to be the LENGTH
of the substring, not the END OFFSET + 1.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Tue, 20 Feb 2001 13:31:10 +0200
From: "Dan" <ge@do.com>
Subject: Re: What's wrong with this script?
Message-Id: <96tkcr$5vi$1@news.kolumbus.fi>

Oh I see the substring function doesn't work that way in perl... No problem
the $j + 1 should be 1




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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