[26234] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8419 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 14 18:05:24 2005

Date: Wed, 14 Sep 2005 15:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 14 Sep 2005     Volume: 10 Number: 8419

Today's topics:
    Re: FAQ 9.16 How do I decode a CGI form? <sherm@dot-app.org>
    Re: File::Copy works, File::NCopy doesn't <jgibson@mail.arc.nasa.gov>
    Re: File::Copy works, File::NCopy doesn't <1usa@llenroc.ude.invalid>
        Newbie Q: Is it Possible to ? <hrberg@infinet.com>
    Re: Newbie Q: Is it Possible to ? <jgibson@mail.arc.nasa.gov>
        Odd perlsvc problem <demhackbardt@tampadsl.net>
    Re: Opening many txt files <jgibson@mail.arc.nasa.gov>
    Re: Perl DBI / SQL Question <bill@karwin.com>
    Re: Perl DBI / SQL Question <vma_nntp@vmacs.us>
    Re: Perl DBI / SQL Question <bill@karwin.com>
        Perl portability <hendry.taylor@btinternet.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Sep 2005 14:38:43 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <m24q8n3364.fsf@Sherm-Pendleys-Computer.local>

xhoster@gmail.com writes:

> What if you don't want variable replacement
 ...
> Maybe I do want, in general, variable interpolation
 ...
> Obviously, the same argument works the other way
 ...

Whether the policy should be changed, dropped, amplified, or left alone is
a separate question; I'd simply like to see the FAQs follow the policy
consistently, regardless of what it might be.

Frankly, I consider it a trivial issue and  wouldn't have mentioned it,
except that there was another issue mentioned concerning this entry as
well. If someone's going to be in that neighborhood anyway, it's worth
fixing while you're there - but I wouldn't bother making a special trip
for it.

> "why should I avoid single quotes

Frankly, in the privacy of my own code, I tend to use '"' by default,
and "'" only when there's a special reason for it. After all, who knows
when I'll need to add a \n to a string literal, or interpolate a value
into it?

When posting code here, I try to follow the group norm. I don't really
agree with the folks who get worked up about it, but it's not worth
arguing about it.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 14 Sep 2005 12:20:58 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: File::Copy works, File::NCopy doesn't
Message-Id: <140920051220580568%jgibson@mail.arc.nasa.gov>

In article <Xns96D0E560B25EEasu1cornelledu@127.0.0.1>, A. Sinan Unur
<1usa@llenroc.ude.invalid> wrote:

> Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in news:130920051853345704%
> jgibson@mail.arc.nasa.gov:
> 
> > In article <Xns96D0B67CEB50Dasu1cornelledu@127.0.0.1>, A. Sinan Unur
> > <1usa@llenroc.ude.invalid> wrote:
> > 
> > 
> >> 
> >> On the other hand, I do not find it encouraging that the module author 
> >> uses print for debug messages. He should be using warn.
> > 
> > Why is that? Why do you want to write debugging messages to standard
> > error instead of standard output?
> 
> So that I can actually see the debugging messages even if standard output 
> is redirected. Or, so that I can log debugging messages to a file 
> separately from the normal output of the program.

OK. Thanks for the explanation. I use a different approach. I write
debugging messages to standard output so they are easy to capture in a
file. This lets me see error messages when they occur. I can capture
the error messages as well with the unix c-shell redirection '>&' if I
want to see the error and debug messages together. Most of the programs
I write don't write much to stdout, but to report files instead.

My method works for me and the kind of programs I write and the kind of
debugging I do, and I am sure that your method works for you. However,
this seems more of a personal preference issue, and not something that
you would cause you to denigrate a module. It would seem to me that
debug print statements in a module are mostly for the benefit of the
author and are not cause for criticism. The lack or content of debug
statements would be a concern to me, not where they are directed.

Just curious, as I am currently writing a module I hope to one day
submit to CPAN, and it uses lots of debug print statement to stdout.

Thanks again for your insight. Back to Perl.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Wed, 14 Sep 2005 19:29:06 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: File::Copy works, File::NCopy doesn't
Message-Id: <Xns96D19D8572E72asu1cornelledu@132.236.56.8>

Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in
news:140920051220580568%jgibson@mail.arc.nasa.gov: 

> My method works for me and the kind of programs I write and the kind
> of debugging I do, and I am sure that your method works for you.
> However, this seems more of a personal preference issue, and not
> something that you would cause you to denigrate a module. It would
> seem to me that debug print statements in a module are mostly for the
> benefit of the author and are not cause for criticism. The lack or
> content of debug statements would be a concern to me, not where they
> are directed. 

And, when a module does not do something the user expects it to be able to, 
then the debug statements can help the user of the module as well.

It's fine by me if you want to claim this is a personal preference, but 
common sense tells me, usual output goes to STDOUT, and errors/logging go 
to STDERR.

Sinan


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

Date: Wed, 14 Sep 2005 14:16:24 -0400
From: "Harvey Rothenberg" <hrberg@infinet.com>
Subject: Newbie Q: Is it Possible to ?
Message-Id: <11igq33hjm2kh5b@corp.supernews.com>

To Whom It May Concern :

I am new to Perl.  I am looking for direction as to being able to compile
self running programs regardless of OS with Perl.  I know that it is capable
to compile a Perl program ( which I have not done yet either),  but I
thought the difficulty would be to create one that works in any Intel
hardware based Platform but disregarding the Op Sys ?

I hope someone can provide some reliable information and direction.

Thank You ahead of time for your time.

Harvey Rothenberg
Micro Unix's and Security Specialist




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

Date: Wed, 14 Sep 2005 12:59:18 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Newbie Q: Is it Possible to ?
Message-Id: <140920051259188578%jgibson@mail.arc.nasa.gov>

In article <11igq33hjm2kh5b@corp.supernews.com>, Harvey Rothenberg
<hrberg@infinet.com> wrote:

> To Whom It May Concern :
> 
> I am new to Perl.  I am looking for direction as to being able to compile
> self running programs regardless of OS with Perl.  I know that it is capable
> to compile a Perl program ( which I have not done yet either),  but I
> thought the difficulty would be to create one that works in any Intel
> hardware based Platform but disregarding the Op Sys ?
> 
> I hope someone can provide some reliable information and direction.

Perl programs are run by a compiler/interpreter and don't need a
separate compilation step. Provided you don't use any platform or
operating system specific features, Perl programs can on many different
platforms without modification.

See www.perl.org for more information.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Wed, 14 Sep 2005 14:49:02 -0400
From: "news" <demhackbardt@tampadsl.net>
Subject: Odd perlsvc problem
Message-Id: <E_CdnVx5qevP7bXeRVn-iw@tampabaydsl.com>


All,

I've got an odd issue (and I'm not sure it's even perl related - probably 
not), but I'm hoping maybe someone will have an idea as I've exhausted my 
resources in finding the issue.

I've got this perlsvc (activetstate pdk) script (below) that just needs to 
run a single command (ex.bat).  My real app does a lot more, but this 
illustrates the problem.  Anyways, the service installs fine, starts fine, 
but the es.bat never runs on a couple Windows 2003 system.   I can't figure 
out why :(    Some systems this runs fine on.

Any ideas?

Thanks,
Derek!

package PerlSvc;
our %Config;

sub Remove {
      $Config{ServiceName} = 'etest';
      $Config{DisplayName} = 'Test Agent';
}

sub Install {
      $Config{ServiceName} = 'etest';
      $Config{StartType} = "auto";
      $Config{DisplayName} = 'Test Agent';
}

sub Startup {
      our $dproc;

      while (ContinueRun(1)) {
            main::ProcRun();
      }
      return 0;
}

package main;

sub ProcRun {
      system('c:\ex.bat');
      sleep 1;
}





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

Date: Wed, 14 Sep 2005 12:45:08 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Opening many txt files
Message-Id: <140920051245087601%jgibson@mail.arc.nasa.gov>

In article <2005091416432016807%tony@heagrencom>, Tony Heagren
<tony@heagren.com> wrote:

> Maybe it's the newsreader when I checked back
> for responses my post had vanished.
> So I posted it again from a different source.
> Got a problem with that ?
> 
> This is not a chat room - neither is it your place to give lessons in 
> etiquette.

Actually, if you read this newsgroup for any amount of time you will
find out that it is in fact frequently a place to give Usenet etiquette
lessons! :)

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Wed, 14 Sep 2005 11:44:25 -0700
From: Bill Karwin <bill@karwin.com>
Subject: Re: Perl DBI / SQL Question
Message-Id: <dg9r0o01dqv@enews3.newsguy.com>

Vance M. Allen wrote:
> I need to know how to retrieve through Perl DBI a listing of possible ENUM 
> elements from a field for processing under a CGI script.  

It's for this reason that I avoid using ENUM datatypes.
It's much easier to get the list of values if you define the set of 
values in a lookup table, and just reference the lookup table in your 
field definition.

CREATE TABLE foo_lookup (
  foo VARCHAR(32) PRIMARY KEY
) TYPE=InnoDB;
CREATE TABLE t (
  foo VARCHAR(32) REFERENCES foo_lookup
) TYPE=InnoDB;

Then you can get the list of values simply: "SELECT foo FROM 
foo_lookup".  Note that you must use InnoDB tables if you want these 
references to be enforced by the DBMS.

This method makes it easier to change the set of values, too.
Otherwise you have to change the field definition when you change the 
values in the ENUM.

I find ENUM is best used for cases when you know the set of values will 
be unchanging.  Like True/False (if your DBMS doesn't support a boolean 
type), or Male/Female, or Approved/Denied, etc.

Regards,
Bill K.


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

Date: Wed, 14 Sep 2005 13:07:27 -0600
From: "Vance M. Allen" <vma_nntp@vmacs.us>
Subject: Re: Perl DBI / SQL Question
Message-Id: <3y_Ve.15$4V2.2408@news.uswest.net>

Good point.  My situation is this..  I basically have a Security table, and 
currently the ENUM is listing the different actions that are available, and 
the table has a simple Y/N for whether each of the access groups is 
permitted for the action.  If you have any good suggestions or examples for 
how to handle this, it would be greatly appreciated.

Thanks,

Vance


"Bill Karwin" <bill@karwin.com> wrote in message 
news:dg9r0o01dqv@enews3.newsguy.com...
Vance M. Allen wrote:
> I need to know how to retrieve through Perl DBI a listing of possible ENUM
> elements from a field for processing under a CGI script.

It's for this reason that I avoid using ENUM datatypes.
It's much easier to get the list of values if you define the set of
values in a lookup table, and just reference the lookup table in your
field definition.

CREATE TABLE foo_lookup (
  foo VARCHAR(32) PRIMARY KEY
) TYPE=InnoDB;
CREATE TABLE t (
  foo VARCHAR(32) REFERENCES foo_lookup
) TYPE=InnoDB;

Then you can get the list of values simply: "SELECT foo FROM
foo_lookup".  Note that you must use InnoDB tables if you want these
references to be enforced by the DBMS.

This method makes it easier to change the set of values, too.
Otherwise you have to change the field definition when you change the
values in the ENUM.

I find ENUM is best used for cases when you know the set of values will
be unchanging.  Like True/False (if your DBMS doesn't support a boolean
type), or Male/Female, or Approved/Denied, etc.

Regards,
Bill K. 




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

Date: Wed, 14 Sep 2005 12:46:12 -0700
From: Bill Karwin <bill@karwin.com>
Subject: Re: Perl DBI / SQL Question
Message-Id: <dg9ukj0101u@enews2.newsguy.com>

Vance M. Allen wrote:
> Good point.  My situation is this..  I basically have a Security table, and 
> currently the ENUM is listing the different actions that are available, and 
> the table has a simple Y/N for whether each of the access groups is 
> permitted for the action.  If you have any good suggestions or examples for 
> how to handle this, it would be greatly appreciated.

You need another table:

CREATE TABLE privilege (
  access_group_id INTEGER NOT NULL
    REFERENCES access_group(access_group_id),
  priv_type_id INTEGER NOT NULL
    REFERENCES privelege_type(priv_type_id),
  permitted BOOLEAN NOT NULL DEFAULT 0,
  PRIMARY KEY (access_group_id, priv_type_id)
);

CREATE TABLE privilege_type (
  priv_type_id INTEGER NOT NULL PRIMARY KEY,
  priv_type_name VARCHAR(64)
);

Now you take all the priveleges info out of your access_group table, and 
rely on the rows in the privelege table.

This allows you to add new types of privileges without changing your 
schema, and also allows you to look up the list of currently valid 
privilege types by "SELECT * FROM privelege_type".

Absence of a row in the privilege table for a given priv type could be 
equivalent to not having that privilege.  Or if you want to get fancy, 
you can make certain privileges have different defaults.  Add a 
"default_permitted BOOLEAN" to the privilege_type table, and use a query 
like the following to get all privileges for all access groups:

SELECT g.id, pt.priv_type_id,
  COALESCE(p.permitted, pt.default_permitted) AS permitted
FROM access_group AS g
  INNER JOIN privilege_type AS pt
  LEFT OUTER JOIN privilege AS p ON pt.priv_type_id = p.priv_type_id;

(note the rare appropriate use of a Cartesian product!)

Regards,
Bill K.


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

Date: Wed, 14 Sep 2005 20:45:27 +0000 (UTC)
From: Hendry Taylor <hendry.taylor@btinternet.com>
Subject: Perl portability
Message-Id: <dga257$503$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>

I wrote a perl script and tested it on windows and it works fine. I then
moved it onto a solaris machine and now it says that there is a syntax
error with the following line of code:

$user1 = "User name: ".$rec1[0];

the line of code just before that is:

@rec1 = split(/@/, $autotrack[$records]);


any ideas?
I can't see that there is anything uniquely windows about that. There is
a difference in the version of perl in that on the windows box I have
active state v5.8.6 and the solaris box has solaris perl 5.00.3 or
something like that.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8419
***************************************


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