[22266] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4487 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 30 14:06:48 2003

Date: Thu, 30 Jan 2003 11:05:13 -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           Thu, 30 Jan 2003     Volume: 10 Number: 4487

Today's topics:
    Re: ActiveState's perl compiler errors or warning? (T Conti)
        ANN: module Exporter::VA (John M. Dlugosz)
        ANNOUNCE: Tk-Pod-0.9914 <slaven@rezic.de>
        ANNOUNCE: UML-Sequence-0.01 (Phil Crow)
        Attitude to Perl in academia (Rat Tank)
    Re: Attitude to Perl in academia <ihave@noemail.com>
    Re: Attitude to Perl in academia <abigail@abigail.nl>
    Re: Attitude to Perl in academia <uri@stemsystems.com>
        Checking for a file <ihave@noemail.com>
    Re: Checking for a file <michi@relay3.jackal-net.at>
    Re: Checking for a file <ihave@noemail.com>
        Comparing files with difference percentage (Vinicio Tavares)
    Re: Comparing files with difference percentage <wksmith@optonline.net>
        double pipes || <blnukem@hotmail.com>
    Re: double pipes || <flavell@mail.cern.ch>
        global configuration variable - use strict and require <no_spam@fromyou.thanks-anyways.com>
    Re: global configuration variable - use strict and requ (Anno Siegel)
    Re: global configuration variable - use strict and requ <nobull@mail.com>
    Re: hash ordering. <dha@panix2.panix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 30 Jan 2003 09:09:34 -0800
From: tconti@hotmail.com (T Conti)
Subject: Re: ActiveState's perl compiler errors or warning?
Message-Id: <5e0d3eda.0301300909.7690dab0@posting.google.com>

I ran into the same thing.  I renamed daemon.DLL to Daemon.dll,
Message.DLL to Message.dll, Message.PM to Message.pm and so on...  I
also received a case error on an module that looked like it was in the
right case.  I cut and pasted the module/package name into the
referring script and the error went away.  Also, I have to agree that
this is more of a warning.  I received compile errors on Daemon.DLL
and Daemon.pm but the service still built and started and stopped w/o
issue.

"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in message news:<b02vpd$bts$1@nets3.rz.RWTH-Aachen.DE>...
> Also sprach Mark Seger:
> 
> > I recently downloaded a trial copy of the developers kit to try out the
> > program that turns a perl script into a 'freestanding' program you can
> > run on any system even if it doesn't have perl on it.  The only problem
> > is when I try to build something using a module that I had to load, I
> > get errors about case mismatches.  For example, the following showed up
> > when trying to use Dave Roth's  EventLog::Message module.  The thing to
> > note is the resultant program seemed to run fine making me this this is
> > more of a warning than an error, but in any event I'd sure like to know
> > what is really going on so I could work around it.  I don't feel too
> > comfortable seeing this kind of thing and the documentation wasn't very
> > helpful...
> > 
> > Here's my 2 line script, bug.pl (if I just use EventLog, it doesn't
> > generate any errors):
> > 
> > use Win32::EventLog;
> > use Win32::EventLog::Message;
> > 
> > and here's what happened when I try to compile it:
> > 
> > D:\test>perlapp bug.pl
> > PerlApp 5.0.3 build 503
> > Copyright (C) 1998-2002 ActiveState Corp. All rights reserved.
> > Evaluation license for Mark Seger <mark.seger@hp.com> (Expires:
> > 2003-01-23)
> > 
> > Win32\EventLog\Message.pm:
> >         error: Case mismatch between module and file name
> >         refby: bug.pl
> >         file: C:\Perl\site\lib\Win32\EventLog\Message.PM
> > auto\Win32\EventLog\Message\Message.dll:
> >         error: Case mismatch between module and file name
> >         refby: C:\Perl\site\lib\Win32\EventLog\Message.PM
> >         file: C:\Perl\site\lib\auto\Win32\EventLog\Message\Message.DLL
> 
> Since Win32 filesystems are case insensitive it shouldn't do any harm to
> rename the files mentioned above with an uppercase extension (.PM and
> .DLL). 'C:\Perl\site\lib\Win32\EventLog\Message.PM' becomes
> 'C:\Perl\site\lib\Win32\EventLog\Message.pm' and so on. I suspect that
> perlapp inspects %INC and finds some discrapencies between the files
> listed therein and their actual case on disk.
> 
> Tassilo


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

Date: 27 Jan 2003 19:20:15 -0800
From: pa7kxxk02@sneakemail.com (John M. Dlugosz)
Subject: ANN: module Exporter::VA
Message-Id: <3e395f0b$1_4@news.teranews.com>

== What is it? ==

Exporter::VA.pm is a Perl module that is a replacement for the
traditional Exporter module.

Version 1.3.0.1 is available on CPAN, and the documentation is easily
browsed using <http://search.cpan.org/author/DLUGOSZ/Exporter-VA-1.3.0.1/VA.pm>.

== History ==

I wanted to rewrite a couple simple modules to make them more capable,
and I also wanted to remove the default exports.  After all, the new
way would be object-oriented.  It would still have the function call
for compatibility, but we don't want it as a default.  I figured
playing around with VERSION and Exporter's export_to_level would do
the trick, but it was not simple.  I did in fact redo two modules, but
the compatibility mode stuff stalled me.

Finally, I realized that the remove-default-exports issue should be a
reusable module in itself.  After poking around and finding Exporter
lacking, I decided to write an exporter from scratch.  I called it VA
for "Versioning and Aliasing", the major features that distinguish it
and provide it's reason for being.

I figued I needed a more general-purpose engine that could export
things (not just named things, but generated things) from a module to
a possibly-different name.  Going from a named item to the same name
is simply too restrictive.  Generalize it, and anything is possible. 
That gave the Alias concept.  Then I needed to be able to specify
different definitions for different versions.  I thought about totally
different data structures for each version, but realized that they
would have a lot in common and I really only want to give the changes.
 The interface to this was the hardest part of the process.

The concept is pretty open-ended, and it would not do to have
something unruly.  Limiting it to versioned names and versioned tags
in a single hash prooved to be workable, and the programmatic
interface is still available for "anything else".  It is designed to
be extended, treating the derived class user as another potentional
customer and providing documentation and a proper interface for this
purpose.

I got some valuable feedback and ideas on the Perl Monks site. 
Finally, Exporter::VA was the result.

== Purpose ==

So, what's the point?  Am I promoting its use because I want people to
use my product?  No, it's provided for free and it doesn't matter
whether you download my stuff.  Rather, I want to promote certain
issues, and here is code on a silver platter to accomplish it.

As I said earlier, my main point was to *Get Rid Of Default Exports*
in revised versions of modules, but still retain backward
compatibility.  This will do that easily.  In fact, the short program
Exporter-VA-Convert.perl (included) will convert the relevent
statements in a script to the "new way", and optionally set it up for
removing the default exports based on later version numbers.  See
<http://search.cpan.org/author/DLUGOSZ/Exporter-VA-1.3.0.1/Exporter-VA-Convert.perl>
for documentation.

--John




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

Date: 29 Jan 2003 13:23:31 +0100
From: Slaven Rezic <slaven@rezic.de>
Subject: ANNOUNCE: Tk-Pod-0.9914
Message-Id: <3e395efd$1_7@news.teranews.com>

Tk::Pod is a graphical user interface for viewing and browsing perl's
POD documentation.

Features include:
	o Interface to perlindex full text POD search added
	  (you need to install the perlindex distribution aka
           Text::English on CPAN).
	o Supports single or multiple POD windows.
	o Primitive Tk/More widget with '/', 'n', 'N', 'j', 'k'
	  bindings
	o Tree view of available PODs

The current version uses Pod::Simple as POD parser (thanks to Sean M.
Burke!).

Available at: $CPAN/authors/id/S/SR/SREZIC/Tk-Pod-0.9914.tar.gz

-- 
Slaven Rezic - slaven@rezic.de
  BBBike - route planner for cyclists in Berlin
  WWW version:                           http://www.bbbike.de
  Perl/Tk version for Unix and Windows:  http://bbbike.sourceforge.net




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

Date: 28 Jan 2003 09:03:46 -0800
From: philcrow2000@yahoo.com (Phil Crow)
Subject: ANNOUNCE: UML-Sequence-0.01
Message-Id: <3e395f03$1_5@news.teranews.com>

NAME
    UML::Sequence (and its helpers) run your code and make a UML
    Sequence diagram

SYNOPSIS
        genericseq.pl [-t 'title'] UML::Sequence::SimpleSeq outline >
out.xml
        seq2svg.pl out.xml > out.svg

    OR

        genericseq.pl [-t 'title'] UML::Sequence::PerlSeq methods_list
prog [args...] > prog.xml
        seq2svg.pl prog.xml > prog.svg

DESCRIPTION
    There are two main uses of UML::Sequence and its accompanying
    scripts.

    1. Turning text file outlines into sequence diagrams in svg
       format.

    2. Running perl programs through Devel::DProf and dproffpp -T to
       produce an outline which becomes a diagram in svg format.

    The text outlines have the following form:

        At Home.Wash Car
            Garage.retrieve bucket
            Kitchen.prepare bucket
                Kitchen.pour soap in bucket
                Kitchen.fill bucket
            Garage.get sponge
            Garage.open door
            Driveway.apply soapy water
            Driveway.rinse
            Driveway.empty bucket
            Garage.close door
            Garage.replace sponge
            Garage.replace bucket

    The perl methods file must list all the methods you want to see.
    Here's an example:

        DiePair::new
        Die::new
        DiePair::roll
        Die::roll
        DiePair::total
        DiePair::doubles
        DiePair::to_string

    If you have another type of outline you would like to process,
    you can easily code a three function module with the same API
    as UML::Sequence::SimpleSeq (hint: you can inherit from it).
    The three methods in that module are: 1. an outline generator,
    2. a method list generator, and 3. a function to split method
    names from class names. See the JAVA section below for one
    such module. Once you have your module, simply use its name
    as the first argument to genericseq.pl.

SYNOPSIS2
      use UML::Sequence;

      my $tree = UML::Sequence->new(
         \@methods,
         \@outline,
         \&parse_method
      );
      print $tree->build_xml_sequence('Title');

DESCRIPTION2
    If you want to code your own scripts, you can access
    UML::Sequence as shown. Call its constructor with:

    1.  a reference to a list (or hash) of methods you want
        to see in the diagram
    2.  a reference to a list of outline lines
        (indentation is vital)
    3.  a code reference to a method which takes outline
        lines and returns
            class name in scalar context
            class and method name in list context

    Look at UML::Sequence::SimpleSeq and UML::Sequence::PerlSeq
    for examples of implementing parse_method.

    You can use any technique to generate the list of methods
    (reading a file, gleaning them from the outline, etc.). You
    can also use any technique to generate the outline.
    Devel::DProf and dprofpp -T are good for Perl. For Java I
    had to be more creative. C++ and others will require some
    work. Feel free to send me contributions for other languages.
    I'll be happy to include them with much thanks in future
    releases.

JAVA
    If you have the sdk 1.3 or higher, you might be interested
    in my sequencing tool for Java programs.
    UML::Sequence::JavaSeq works like its cousins described above,
    but it depends on an external Java program Seq.java which
    uses the the Java Platform Debugger Architecture (jpda) source
    code hooks to build an outline of calls in Java programs
    as they run.

    To use this, you must make sure that Seq.class and tools.jar
    (which contains the jpda) are in your classpath. Then do this:

        genericseq [-t 'title'] UML::Sequence::JavaSeq methods_file
Hello > Hello.xml
        seqtosvg Hello.xml > Hello.svg

    The methods file can be as simple as this:

        ALL
        Hello*

    This says, take ALL methods from any class whose name begins
    with Hello. Seq will run slow if you have too many classes in
    this list. In particular, including java.* is A Bad Idea(tm).
    Seq requests message for the named classes. Naming too many
    classes results in poor performance. (But it is interesting
    to see the results once for a simple hello program. Mine made
    over 160 calls to print "Hello".)

AUTHOR
    Phil Crow <philcrow2000@yahoo.com>

COPYRIGHT AND LICENSE
    Copyright 2003, Phil Crow. All rights reserved. This is free
    software. You can redistribute it and/or modify it under the
    same terms as Perl itself.




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

Date: 30 Jan 2003 09:39:03 -0800
From: rat_tank@yahoo.com (Rat Tank)
Subject: Attitude to Perl in academia
Message-Id: <ae14ba57.0301300939.2d47cb01@posting.google.com>

I've programmed for some time in Perl, but at no time has this been
anything to do with the CompSci degree I'm studying; no course even
mentions it. Why is this? Perl doesn't seem to have much respect in
educated programming circles, and I think this is why;
    Its type system is not entirely sound. Inference upon the typing
rules (which aren't formally stated anywhere; I had to derive them
from the sourcecode) can lead to propositional contradictions.
    It is most certainly _not_ Turing complete (trivially provable);
hence not all algorithms can be implemented in it that you could with
a Turing complete language like Java or C(++).
    Perl's reference counting system of garbage collection can
sometimes result in memory leaks, as opposed to the more thorough
graph traversal employed in other languages.
    Despite all this, it's frustrating that I can't get course credit
for the various projects I've done in my own time (that would be
perfectly acceptable as coursework if implemented in other languages).
I know that academia is not quite the 'real world', but I'd have hoped
that could be offset by just how damn useful Perl is (and I've
demonstrated this to my profs on more than one occasion). What do you
think?
 
RT


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

Date: Thu, 30 Jan 2003 17:50:48 GMT
From: "TBN" <ihave@noemail.com>
Subject: Re: Attitude to Perl in academia
Message-Id: <WBd_9.34$28.36774@news.randori.com>

"Rat Tank" <rat_tank@yahoo.com> wrote in message
news:ae14ba57.0301300939.2d47cb01@posting.google.com...
> I've programmed for some time in Perl, but at no time has this been
> anything to do with the CompSci degree I'm studying; no course even
> mentions it. Why is this? Perl doesn't seem to have much respect in
> educated programming circles, and I think this is why;
>     Its type system is not entirely sound. Inference upon the typing
> rules (which aren't formally stated anywhere; I had to derive them
> from the sourcecode) can lead to propositional contradictions.
>     It is most certainly _not_ Turing complete (trivially provable);
> hence not all algorithms can be implemented in it that you could with
> a Turing complete language like Java or C(++).
>     Perl's reference counting system of garbage collection can
> sometimes result in memory leaks, as opposed to the more thorough
> graph traversal employed in other languages.
>     Despite all this, it's frustrating that I can't get course credit
> for the various projects I've done in my own time (that would be
> perfectly acceptable as coursework if implemented in other languages).
> I know that academia is not quite the 'real world', but I'd have hoped
> that could be offset by just how damn useful Perl is (and I've
> demonstrated this to my profs on more than one occasion). What do you
> think?
>
> RT

I'm pretty new at Perl, but I've been programming since '83 and have a minor
in CSC.  I think that Perl's lack of respect stems mostly from the fact that
it is a difficult to teach language.  It's structure and command syntax do
not lend themselves well to teaching students who have little or no
programming background.

Also, I could be wrong, but I've never seen a Perl version on a mainframe,
generally just Unix/Linux and Windows and a lot of universities prefer to
teach languages which are compiled on their VAX or Mainframe machine.  To be
honest, I don't remember any scripting type languages being taught much.




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

Date: 30 Jan 2003 18:01:41 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Attitude to Perl in academia
Message-Id: <slrnb3iq45.olf.abigail@alexandra.abigail.nl>

Rat Tank (rat_tank@yahoo.com) wrote on MMMCDXXXIX September MCMXCIII in
<URL:news:ae14ba57.0301300939.2d47cb01@posting.google.com>:
{}  I've programmed for some time in Perl, but at no time has this been
{}  anything to do with the CompSci degree I'm studying; no course even
{}  mentions it. Why is this? Perl doesn't seem to have much respect in
{}  educated programming circles, and I think this is why;
{}      Its type system is not entirely sound. Inference upon the typing
{}  rules (which aren't formally stated anywhere; I had to derive them
{}  from the sourcecode) can lead to propositional contradictions.
{}      It is most certainly _not_ Turing complete (trivially provable);
{}  hence not all algorithms can be implemented in it that you could with
{}  a Turing complete language like Java or C(++).

How interesting. Could you enlighten us with your trivial proof, as
I always thought it was trivially proven the other way around.

{}      Perl's reference counting system of garbage collection can
{}  sometimes result in memory leaks, as opposed to the more thorough
{}  graph traversal employed in other languages.

You mean, languages like C?

Note that a garbage collection algorithm is more a decision of the
language implementation than of the language itself.

{}      Despite all this, it's frustrating that I can't get course credit
{}  for the various projects I've done in my own time (that would be
{}  perfectly acceptable as coursework if implemented in other languages).
{}  I know that academia is not quite the 'real world', but I'd have hoped
{}  that could be offset by just how damn useful Perl is (and I've
{}  demonstrated this to my profs on more than one occasion). What do you
{}  think?

Having spend more than a decade at CS departments, both as a student
and as a staff member, I'm not at all surprised. But that has more
to do with Perl being a programming language than Perl being a special
programming language. CS isn't about programming, just like astronomy
isn't about building telescopes. 

Perl is useful, but so are a hundred other languages. Imagine *you*
being a teacher, having 50 students, each of them having to do 10
exercises a year. Would you want the students to be free in which
language they do their assignments in? Do you want to learn every
language under the sun?


Abigail
-- 
 :;$:=~s:
-:;another Perl Hacker
 :;chop
$:;$:=~y
 :;::d;print+Just.
$:;


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

Date: Thu, 30 Jan 2003 18:16:37 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Attitude to Perl in academia
Message-Id: <x73cna33lm.fsf@mail.sysarch.com>

>>>>> "RT" == Rat Tank <rat_tank@yahoo.com> writes:

  RT>     Its type system is not entirely sound. Inference upon the typing
  RT> rules (which aren't formally stated anywhere; I had to derive them
  RT> from the sourcecode) can lead to propositional contradictions.

huh? perl has no typing system as do most other languages. so how can
you dreive one?

  RT>     It is most certainly _not_ Turing complete (trivially provable);
  RT> hence not all algorithms can be implemented in it that you could with
  RT> a Turing complete language like Java or C(++).

that is total crap. i don't know where you learned about state and
turing machines but it is hard to find a common programming language
that isn't turing complete. all you need is a single array, a few state
variables and some simple boolean logic.

  RT>     Perl's reference counting system of garbage collection can
  RT> sometimes result in memory leaks, as opposed to the more thorough
  RT> graph traversal employed in other languages.

that is a known thing and can be handled if you know how to deal with
circular refs. and if you emply them, you should know how to destroy them.

  RT>     Despite all this, it's frustrating that I can't get course credit
  RT> for the various projects I've done in my own time (that would be
  RT> perfectly acceptable as coursework if implemented in other languages).
  RT> I know that academia is not quite the 'real world', but I'd have hoped
  RT> that could be offset by just how damn useful Perl is (and I've
  RT> demonstrated this to my profs on more than one occasion). What do you
  RT> think?

change schools. if they taught you wrong stuff about turing
completeness, they don't know much about CS.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Thu, 30 Jan 2003 16:37:29 GMT
From: "TBN" <ihave@noemail.com>
Subject: Checking for a file
Message-Id: <cxc_9.25$28.33657@news.randori.com>

I'm still pretty new to Perl, so bear with me on this probably simple
question.

I know that I can open a file using the following...
open (CODE, $filename) || &OtherStuff;

But I'm not really interested in opening this file.  It's a trigger file
that tells me when it is or isn't ok to perform some action.  So I just want
to check for the existence of the file.  If the file is being written when I
perform the "open", my code can't open it, thus it moves onto the
&OtherStuff when I don't want it to.  The odds of this happening are fairly
slim since the trigger file is small, but it does occasionally happen which
of course causes mass confusion to users.

Thank you in advance for you suggestions.




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

Date: Thu, 30 Jan 2003 16:42:58 +0000 (UTC)
From: Michael Lang <michi@relay3.jackal-net.at>
Subject: Re: Checking for a file
Message-Id: <slrnb3ilgh.t72.michi@nuddelaug.jackal-net.at>

In article <cxc_9.25$28.33657@news.randori.com>, TBN wrote:
> I'm still pretty new to Perl, so bear with me on this probably simple
> question.
> 
> I know that I can open a file using the following...
> open (CODE, $filename) || &OtherStuff;
> 
> But I'm not really interested in opening this file.  It's a trigger file
> that tells me when it is or isn't ok to perform some action.  So I just want

try using, 

	if (-f "$filename")
	 {	do what ever;	}
	
> to check for the existence of the file.  If the file is being written when I
> perform the "open", my code can't open it, thus it moves onto the
> &OtherStuff when I don't want it to.  The odds of this happening are fairly
> slim since the trigger file is small, but it does occasionally happen which
> of course causes mass confusion to users.
> 
> Thank you in advance for you suggestions.
> 

greetz mIke

-- 


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

Date: Thu, 30 Jan 2003 17:04:25 GMT
From: "TBN" <ihave@noemail.com>
Subject: Re: Checking for a file
Message-Id: <sWc_9.27$28.35757@news.randori.com>

"Michael Lang" <michi@relay3.jackal-net.at> wrote in message
news:slrnb3ilgh.t72.michi@nuddelaug.jackal-net.at...
> In article <cxc_9.25$28.33657@news.randori.com>, TBN wrote:
> > I'm still pretty new to Perl, so bear with me on this probably simple
> > question.
> >
> > I know that I can open a file using the following...
> > open (CODE, $filename) || &OtherStuff;
> >
> > But I'm not really interested in opening this file.  It's a trigger file
> > that tells me when it is or isn't ok to perform some action.  So I just
want
>
> try using,
>
> if (-f "$filename")
> { do what ever; }
>

Great Thanks!  Your suggestion lead me to some other commands that I didn't
know.  Correct me if I'm wrong but it looks like the following code is
*exactly* what I need...

if (-e $a) { do stuff; }




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

Date: 30 Jan 2003 08:26:53 -0800
From: vtmcs@terra.com.br (Vinicio Tavares)
Subject: Comparing files with difference percentage
Message-Id: <a165b9fc.0301300826.2d1dda98@posting.google.com>

I have 2 ascii files: text1.txt and text2.txt.

    Text1.txt                 Text2.txt
-----------------       --------------------
a                       a
b                       c
c                       c
d                       d
e                       e

  I want to compare the files returning the difference percentage. How
could I do this?

   In the example above it would return '20%'. As 1 of 5 chars doesn't
match.


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

Date: Thu, 30 Jan 2003 17:01:43 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Comparing files with difference percentage
Message-Id: <XTc_9.454383$FT6.92787621@news4.srv.hcvlny.cv.net>


"Vinicio Tavares" <vtmcs@terra.com.br> wrote in message
news:a165b9fc.0301300826.2d1dda98@posting.google.com...
> I have 2 ascii files: text1.txt and text2.txt.
>
>     Text1.txt                 Text2.txt
> -----------------       --------------------
> a                       a
> b                       c
> c                       c
> d                       d
> e                       e
>
>   I want to compare the files returning the difference percentage. How
> could I do this?
>
>    In the example above it would return '20%'. As 1 of 5 chars doesn't
> match.



Quantifying the difference between files requires much more attention to
requirements than you posting provides.

How do I treat whitespace characters?
What if one file has an extra or a missing character?  Is everything
after that mismatched?
What if one character has been moved?
What if a block of characters has been moved,  possibly with changes
within the moved block?

In your example, you are counting only non-whitespace characters.  You
have only one non-whitespace character per line.  In general, do you
want to compare characters or lines?

Finding unambiguous answers to all these questions is much harder that
it seems.  Hopefully, they do not all arise in your application.

Perl is good choice of language to use for the implementation because it
is so strong in text handling.  I expect to see some interesting
solutions once the requirements are clarified.

Bill




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

Date: Thu, 30 Jan 2003 18:20:26 GMT
From: "Blnukem" <blnukem@hotmail.com>
Subject: double pipes ||
Message-Id: <K1e_9.454741$FT6.92998456@news4.srv.hcvlny.cv.net>

Hi all

Why does this only return true for "bill" and not the others?

$check = "rick";

if ($check eq ("bill"||"john"||"rick"||"robert")) {
print "the value of \$check is: $check";
}else{
print "the value of \$check is not listed";
}




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

Date: Thu, 30 Jan 2003 19:40:59 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: double pipes ||
Message-Id: <Pine.LNX.4.53.0301301933100.15366@lxplus070.cern.ch>

On Jan 30, Blnukem inscribed on the eternal scroll:

> Why does this only return true for "bill" and not the others?

> $check = "rick";
>
> if ($check eq ("bill"||"john"||"rick"||"robert")) {

The answer was posted approximately yesterday, in the still-current
thread rather curiously titled "Next problem", by which the questioner
appeared to mean "problem with next" - but it wasn't a problem with
"next" at all.

Discussion is no fun when the other participants aren't reading the
contributions.  (I once had a colleague like that, who was reputed to
be an "output-only device").

I doubted that this was an FAQ, but it's beginning to seem as if...



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

Date: Thu, 30 Jan 2003 16:26:54 GMT
From: "Bullet" <no_spam@fromyou.thanks-anyways.com>
Subject: global configuration variable - use strict and require
Message-Id: <inc_9.12974$p13.3467345021@newssvr10.news.prodigy.com>

OK.. so I am attempting to write a perl script and keep it
somewhat portable..

I currently have three files.. one file contains the code for
the actual application thats going to run .. for the sake of
simplicity I will refer to that as application.pl

Then in addition to that I have a file full of subs that will be
required by - this file I will refer to as support_functions.lib

And finally I have a third file which I wanted to use to hold
ALL global configuration variables. . this one I will refer to
as config.lib

So basically the pertinent lines are as follow..

In application.pl I have
------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
require 'support_functions.lib';
------------------------------------------------------------

Then in support_function.lib I have
------------------------------------------------------------
require 'config.lib';
------------------------------------------------------------
followed by a bunch of helper subs. .

And in config.lib I have..
------------------------------------------------------------
%configuration{'var1'} = 'test';
%configuration{'var2'} = 'test2';
------------------------------------------------------------

My original assumption.. was that global variables.. which
were declared in required files would be globals in the
main:: package.. ie - I thought I would be able to use
$configuration{'var1'} in both application.pl AND
aupport_functions.lib ..

Based on my current attempts though I am beginning
to get confused.. and am questionning my own
assumptions..

Basically.. I was just wondering is there any easy way to do
this ? Am I close? or totally on the wrong track..

Whats the preferred method for putting all configuration
variables in a seperate file ? Any suggestions?




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

Date: 30 Jan 2003 18:17:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: global configuration variable - use strict and require
Message-Id: <b1bq81$apv$1@mamenchi.zrz.TU-Berlin.DE>

Bullet <no_spam@fromyou.thanks-anyways.com> wrote in comp.lang.perl.misc:
> OK.. so I am attempting to write a perl script and keep it
> somewhat portable..
> 
> I currently have three files.. one file contains the code for
> the actual application thats going to run .. for the sake of
> simplicity I will refer to that as application.pl
> 
> Then in addition to that I have a file full of subs that will be
> required by - this file I will refer to as support_functions.lib
> 
> And finally I have a third file which I wanted to use to hold
> ALL global configuration variables. . this one I will refer to
> as config.lib
> 
> So basically the pertinent lines are as follow..
> 
> In application.pl I have
> ------------------------------------------------------------
> #!/usr/bin/perl -w
> use strict;
> require 'support_functions.lib';
> ------------------------------------------------------------
> 
> Then in support_function.lib I have
> ------------------------------------------------------------

You should also use warnings and strict in a library file.

> require 'config.lib';
> ------------------------------------------------------------
> followed by a bunch of helper subs. .
> 
> And in config.lib I have..
> ------------------------------------------------------------

Same remark as above.  With "strict" you will now have to declare
your variables, so add 

    our %configuration;

> %configuration{'var1'} = 'test';
> %configuration{'var2'} = 'test2';
> ------------------------------------------------------------
> 
> My original assumption.. was that global variables.. which
> were declared in required files would be globals in the
> main:: package.. ie - I thought I would be able to use
> $configuration{'var1'} in both application.pl AND
> aupport_functions.lib ..
> 
> Based on my current attempts though I am beginning
> to get confused.. and am questionning my own
> assumptions..

Unfortunately, you don't say what problems you have.  You don't even
show how you access %configuration from application.pl.  Declare it
again with "our" and your setup should work, unless I'm seriously
overlooking something.

The standard method in Perl would be to make the *.lib files real modules
with their own name space, and use exportation to transfer the goodies.
This would give the design most flexibility, but may be more than you
need at the moment.

Anno


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

Date: 30 Jan 2003 18:23:25 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: global configuration variable - use strict and require
Message-Id: <u9hebq33aa.fsf@wcl-l.bham.ac.uk>

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

> OK.. so I am attempting to write a perl script and keep it
> somewhat portable..
> 
> I currently have three files.. one file contains the code for
> the actual application thats going to run .. for the sake of
> simplicity I will refer to that as application.pl
> 
> Then in addition to that I have a file full of subs that will be
> required by - this file I will refer to as support_functions.lib
> 
> And finally I have a third file which I wanted to use to hold
> ALL global configuration variables. . this one I will refer to
> as config.lib
> 
> So basically the pertinent lines are as follow..
> 
> In application.pl I have
> ------------------------------------------------------------
> #!/usr/bin/perl -w
> use strict;
> require 'support_functions.lib';
> ------------------------------------------------------------
> 
> Then in support_function.lib I have
> ------------------------------------------------------------
> require 'config.lib';
> ------------------------------------------------------------
> followed by a bunch of helper subs. .
> 
> And in config.lib I have..
> ------------------------------------------------------------
> %configuration{'var1'} = 'test';
> %configuration{'var2'} = 'test2';
> ------------------------------------------------------------
> 
> My original assumption.. was that global variables.. which
> were declared in required files would be globals in the
> main:: package.. ie - I thought I would be able to use
> $configuration{'var1'} in both application.pl AND
> support_functions.lib ..

You can.  But it you use strict then the variables must (during
compilation) be declared before they are otherwise mentioned.  Remeber
that require is a run-time command.

The information as to what variables are defined (and implicitly
declared) in config.lib is not known at the time application.pl and
support_functions.lib are compiled.

However I think that you shouldn't be learning to write Perl4-style
libraries such as you 'support_functions.lib' now.  You should skip
direct to Perl5-style ones (i.e. Exporter modules).  Perl4-style
libraries are only really usefull these days for things such as your
'config.lib'.

> Based on my current attempts though I am beginning
> to get confused.. and am questionning my own
> assumptions..


> Basically.. I was just wondering is there any easy way to do
> this ?

Don't use strict. Easy but wrong - you'd be writting pure Perl4!

Alternatively change require() to BEGIN{ require() }.  Also easy but
not really all that good.

Make support_functions into a module.  Make it explicitly declare
(using our()) any package variables that it wants.  If any of these
variables are also needed in application.pl then allow
the support_functions module to export them using the Exporter
module.

> Am I close? or totally on the wrong track..

Both :-)  (Close to Perl4, on the wrong track for Perl5).

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


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

Date: Thu, 30 Jan 2003 18:53:26 +0000 (UTC)
From: "David H. Adler" <dha@panix2.panix.com>
Subject: Re: hash ordering.
Message-Id: <slrnb3it57.r6l.dha@panix2.panix.com>

In article <slrnb3gsbv.d0v.tadmc@magna.augustmail.com>, Tad McClellan wrote:
> David H. Adler <dha@panix2.panix.com> wrote:
>> In article <SuSZ9.68$cu4.38@nwrddc02.gnilink.net>, Jürgen Exner wrote:
>>> Richard S Beckett wrote:
>>>> Is there any way to force a hash to be in the same order as you
>>>> defined it?
>>> 
>>> Hashes are mappings. They do not have an order. Asking for the order of a
>>> hash is like asking for the weight of the color green.
>> 
>> Strictly speaking, they *do* have an order.  It's just not a *useful*
>> order. :-)
> 
> 
> It _is_ a useful order. It is what allows O(1) lookups to happen. :-)
> 
> The order of a hash is useful for a perl programmer, 
> but not for a Perl programmer.

I just *knew* someone was going to call me on that... :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Perhaps *the* Monty Python Scholar in America today"
	-New Yorker magazine 13mar89


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

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


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