[23748] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5952 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 18 14:05:47 2003

Date: Thu, 18 Dec 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, 18 Dec 2003     Volume: 10 Number: 5952

Today's topics:
    Re: $dbh->tables() returns nothing <jwillmore@remove.adelphia.net>
    Re: $dbh->tables() returns nothing (Jim Keenan)
    Re: A way to grab string from another program in perl? <jeffrey@cunningham.net>
    Re: A way to grab string from another program in perl? <abuse@apathetic.org.uk>
    Re: A way to grab string from another program in perl? <dwall@fastmail.fm>
    Re: Announcing File::Finder 0.01 <abigail@abigail.nl>
    Re: Announcing File::Finder 0.01 <bart.lateur@pandora.be>
    Re: Asynchronous Objects (Bryan Castillo)
    Re: building a crm solution using Perl <jim.mozley@exponential-e.com>
    Re: Can you undo a read from a file <raisin@delete-this-trash.mts.net>
    Re: Can you undo a read from a file <1usa@llenroc.ude>
    Re: Can you undo a read from a file (Tim Greenwood)
        Can't call method "blah" on unblessed reference at <clint@0lsen.net>
    Re: Can't call method "blah" on unblessed reference at <uri@stemsystems.com>
    Re: Can't call method "blah" on unblessed reference at <nobull@mail.com>
    Re: Can't call method "blah" on unblessed reference at (Malcolm Dew-Jones)
    Re: Creating a list of HASHes (Tad McClellan)
    Re: Creating a list of HASHes (Patrick Paquet)
    Re: Determine DaysInMonth($month) (Tad McClellan)
    Re: Determine DaysInMonth($month) <Eric@nowhere.com>
    Re: Determine DaysInMonth($month) <jurgenex@hotmail.com>
    Re: Determine DaysInMonth($month) <ubl@schaffhausen.de>
    Re: Determine DaysInMonth($month) (Tad McClellan)
    Re: Determine DaysInMonth($month) (Anno Siegel)
    Re: Determine DaysInMonth($month) <Eric@nowhere.com>
    Re: html-->text, keep line breaks, best strategy is? <dwall@fastmail.fm>
        logonserver value <chris.arnottHATESSPAM@uk.lionbioscience.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Dec 2003 16:36:28 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: $dbh->tables() returns nothing
Message-Id: <20031218113627.440500d0.jwillmore@remove.adelphia.net>

On Wed, 17 Dec 2003 11:58:55 -0000
"Julia deSilva" <jds@nospantrumpetweb.co.uk> wrote:
> Unix Perl MYSQL
> 
> Has anyone experienced on some servers ...
> 
> my @tables = $dbh->tables() returning nothing Nil Nada zilch  when
> you are 100% sure you have oodles of tables ?
> 
> Is this a known problem, is there a fix, workaround ?

Have you done an 'execute' or 'do' before doing a 'tables' call?  
Some calls to 'tables', 'rows', etc. do not return a value unless
there's an 'execute' performed first.  Try something like this
(untested)

 ...connect as usual ...
$dbh->prepare('select * from test');
$dbh->execute;

my @tables = $dbh->tables();
 ... continue with your code ...

You may want to check over the DBD::mysql and DBI documents to
(dis)prove what I've said.  It ('tables') varies from vendor to vendor
and may not even be available for MySQL.  So, you may have to fall
back to using an SQL statement instead.

In any event - double check the docs :-)

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Without ice cream life and fame are meaningless. 



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

Date: 18 Dec 2003 08:57:52 -0800
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: $dbh->tables() returns nothing
Message-Id: <196cb7af.0312180857.5e72c804@posting.google.com>

"Julia deSilva" <jds@nospantrumpetweb.co.uk> wrote in message news:<3xXDb.22875$5F2.897@news-binary.blueyonder.co.uk>...
> Hi there all,
> 
> Unix Perl MYSQL
> 
> Has anyone experienced on some servers ...
> 
> my @tables = $dbh->tables() returning nothing Nil Nada zilch  when you are
> 100% sure you have oodles of tables ?
> 
> Is this a known problem, is there a fix, workaround ?
> 
FWIW, in most recent version of DBI, this method is deprecated.  See:
http://search.cpan.org/~timb/DBI-1.39/DBI.pm#tables

jimk


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

Date: Thu, 18 Dec 2003 16:49:29 GMT
From: "Jeff" <jeffrey@cunningham.net>
Subject: Re: A way to grab string from another program in perl?
Message-Id: <pan.2003.12.18.16.49.29.567540@cunningham.net>

On Fri, 12 Dec 2003 18:44:28 +0000, Jeff wrote:

> I'm looking for a way to run another program from a system call and get
> the output produced into a perl variable without going through a file
> intermediary. 
> 
> system('program'); 
> 
> produces a string on STDOUT. I want to grab this in a variable but can't
> figure out how to do it. Any ideas?
> 
> -Jeff

What a pack of asses you are. When someone asks a serious question,
you are silent as snow for days, but someone asks a very simple one and
you bray like donkeys with glee at your great opportunity to be abusive. 

In any event, the reference you gave didn't even answer the question, so
you are fools as well. The correct answer would have been:

$string = `someprogram @args`;

If YOU all had read your own reference closely, you would have noticed
that the system function returns the error code, not what goes to STDOUT. 

Regards,
-Jeff


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

Date: 18 Dec 2003 17:27:00 GMT
From: Malcolm Ray <abuse@apathetic.org.uk>
Subject: Re: A way to grab string from another program in perl?
Message-Id: <slrnbu3or4.40q.abuse@carlova.ulcc.ac.uk>

In article <pan.2003.12.18.16.49.29.567540@cunningham.net>, Jeff wrote:
> On Fri, 12 Dec 2003 18:44:28 +0000, Jeff wrote:
> 
>> I'm looking for a way to run another program from a system call and get
>> the output produced into a perl variable without going through a file
>> intermediary. 
>> 
>> system('program'); 
>> 
>> produces a string on STDOUT. I want to grab this in a variable but can't
>> figure out how to do it. Any ideas?
>> 
>> -Jeff
> 
> What a pack of asses you are. When someone asks a serious question,
> you are silent as snow for days, but someone asks a very simple one and
> you bray like donkeys with glee at your great opportunity to be abusive. 
> 
> In any event, the reference you gave didn't even answer the question, so
> you are fools as well. The correct answer would have been:
> 
> $string = `someprogram @args`;
> 
> If YOU all had read your own reference closely, you would have noticed
> that the system function returns the error code, not what goes to STDOUT. 
> 
> Regards,
> -Jeff

Because this is a common confusion, 'perldoc -f system' *does* have
the answer:

               The return value is the exit status of the program
               as returned by the "wait" call.  To get the actual
               exit value shift right by eight (see below).  See
               also "exec".  This is _not_ what you want to use to
               capture the output from a command, for that you
               should use merely backticks or "qx//", as
               described in "`STRING`" in perlop.  Return value
               of -1 indicates a failure to start the program
               (inspect $! for the reason).

See the mention of backticks and perlop?


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

Date: Thu, 18 Dec 2003 17:49:50 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: A way to grab string from another program in perl?
Message-Id: <Xns94558283AEAD2dkwwashere@216.168.3.30>

Jeff <jeffrey@cunningham.net> wrote:

> On Fri, 12 Dec 2003 18:44:28 +0000, Jeff wrote:
> 
>> I'm looking for a way to run another program from a system call
>> and get the output produced into a perl variable without going
>> through a file intermediary. 
>> 
>> system('program'); 
>> 
>> produces a string on STDOUT. I want to grab this in a variable
>> but can't figure out how to do it. Any ideas?
>> 
 
> What a pack of asses you are. When someone asks a serious
> question, you are silent as snow for days, but someone asks a very
> simple one and you bray like donkeys with glee at your great
> opportunity to be abusive. 
> 
> In any event, the reference you gave didn't even answer the
> question, so you are fools as well. The correct answer would have
> been: 
> 
> $string = `someprogram @args`;
> 
> If YOU all had read your own reference closely, you would have
> noticed that the system function returns the error code, not what
> goes to STDOUT. 

Actually they did give you the correct answer, and what is better, a 
technique you can use to find information for yourself (i.e.; read 
the docs).  They told you to read the docs for system(), which you 
were already using.  The third paragraph in the documentation for 
system() says:

  [system()] is *not* what you want
  to use to capture the output from a command, for that you should
  use merely backticks or "qx//", as described in "`STRING`" in
  perlop.

Jürgen Exner explicitly pointed to this paragraph.

Not understanding the documentation and asking for clarification is 
understandable.  So is asking for a pointer to the proper place in 
the admittedly voluminous Perl docs.  Telling people they are 
"fools" and "asses" for pointing you to the answer to your question 
is completely different.

-- 
David Wall


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

Date: 18 Dec 2003 17:17:58 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Announcing File::Finder 0.01
Message-Id: <slrnbu3oa6.les.abigail@alexandra.abigail.nl>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMMDCCLX September
MCMXCIII in <URL:news:867k0vjter.fsf@blue.stonehenge.com>:
??  *** post for FREE via your newsreader at post.newsfeed.com ***

Do we care?

??  Now coming to a CPAN near you, File::Finder, a nice wrapper around
??  File::Find, with a much more find(1)-like syntax than File::Find::Rule,
??  which can be both a blessing and a curse. :)

Oh, please. I don't think the quality of this group goes up by posting
uploads to CPAN to it. If everyone starts doing that, half of this group
will be filled with it. And then, you have crossposted it, without
setting a Followup-To header. And the group you crossposted it to is
moderated as well.


Please clean up your act.



Abigail
-- 
perl -Mstrict -we '$_ = "goto E.print chop;\n=rekcaH lreP rehtona tsuJ";E1:eval'


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

Date: Thu, 18 Dec 2003 18:41:16 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Announcing File::Finder 0.01
Message-Id: <q5t3uv8fhr222ghh5hclbndu21fe19fnrl@4ax.com>

Abigail wrote:

>Oh, please. I don't think the quality of this group goes up by posting
>uploads to CPAN to it. If everyone starts doing that, half of this group
>will be filled with it.

Well, this is a new module, not just a new version. There's a
difference.

-- 
	Bart.


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

Date: 18 Dec 2003 09:56:13 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Asynchronous Objects
Message-Id: <1bff1830.0312180956.445bb8d4@posting.google.com>

<snip>

> > let me know if you have any questions or need help with this project. i
> > can get you a prerelease version of .11 with the stem flow support.
> > 
> > uri
> 
> Thanks, 
> 
> I downloaded .10, I think I would like to look at .11.  I've been
> looking to write something that works both on windows and unix.  Will
> .11 be available soon?  You don't have to send it to me directly, my
> application is just for fun and the love of perl.
> 
> 
> (I'm generally trying to figure out how to perform
> multithreaded/multiprocess operations in perl.  This is something I've
> done before using fork/exec/etc.... and I've used the threads in 5.8,
> it just seems like it is alot harder than it should be.  What i've
> read, discourages use of DBI with threads, which keeps you from
> performing multiple queries/operations at once.  Someone else,
> suggested looking at POE, which I will.  Although I doubt it returns
> control to your perl script while a query is still executing.
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  (I was wrong to say this before checking out POE
   it does have some modules to run database queries in a new
   process, where the original script will receive control
   again during a long query. It was stupid of me to say something
   about a technology I knew nothing about.)

>                                                              In the
> end I was hoping to come up with a module that allows various types of
> asynchronous operations on objects, where the execution context,
> carrying out the operations, is completly managed by the initial
> execution context.)


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

Date: Thu, 18 Dec 2003 14:22:41 +0000
From: Jim Mozley <jim.mozley@exponential-e.com>
Subject: Re: building a crm solution using Perl
Message-Id: <3FE1B831.2020202@exponential-e.com>

Julie Smith wrote:

> Hi,
> I wanted to implement a crm(customer relationship management) solution
> using perl.
> It will have to easily integrate and migrate all the existing systems
> used by my companies sales,marketing,accounting departments and give a
> customer centric view of the whole company.
> what architecture should I use.
> I have evaluated the exisintg popular out of the box solutions like
> accpacc,update.com,upshot.com but they cost money.!!!
> company size is under 200 persons.
> 
> any help will be appreciated!
> thanks in advance,
> Julie

Nothing to do with perl but got this in a SourceForge update

4. Compiere ERP + CRM Business Solution
https://sourceforge.net/projects/compiere
Smart ERP+CRM solution for Small-Medium Enterprises in the global
marketplace covering all areas from customer management, supply chain
and accounting. For $2-200M revenue companies looking for "brick and
click" first tier functionality.


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

Date: Thu, 18 Dec 2003 08:06:28 -0600
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: Can you undo a read from a file
Message-Id: <MPG.1a4b705bb29ea41c989719@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <412175bb.0312171524.18422667@posting.google.com>, 
timothy@greenwood.name says...
> Is it possible (and preferably simple) to undo a line input from STDIN
> or any file handle? I want to do something like
> 
> 
> $line = <STDIN>;
> if ($line =~ $my_pattern) {
>    # process it all
> } else {
>   # push the line back to be read by some other part of the program
> }
> 

You can use the "seek" function to "reposition" a file's "current I/O 
location". See "perldoc -f seek" for further details.


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

Date: 18 Dec 2003 15:10:12 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Can you undo a read from a file
Message-Id: <Xns9455677481D8Basu1cornelledu@132.236.56.8>

Web Surfer <raisin@delete-this-trash.mts.net> wrote in 
news:MPG.1a4b705bb29ea41c989719@news.mts.net:

> [This followup was posted to comp.lang.perl.misc]

Hmmmm ... I am reading this in comp.lang.perl.misc. Why do I need to be 
told that it was posted here?

> In article <412175bb.0312171524.18422667@posting.google.com>, 
> timothy@greenwood.name says...
>> Is it possible (and preferably simple) to undo a line input from STDIN
>> or any file handle? I want to do something like
>> 
>> 
>> $line = <STDIN>;
>> if ($line =~ $my_pattern) {
>>    # process it all
>> } else {
>>   # push the line back to be read by some other part of the program
>> }
>> 
> You can use the "seek" function to "reposition" a file's "current I/O 
> location". See "perldoc -f seek" for further details.

I would like to see how you that with STDIN. 

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: 18 Dec 2003 07:26:16 -0800
From: timothy@greenwood.name (Tim Greenwood)
Subject: Re: Can you undo a read from a file
Message-Id: <412175bb.0312180726.4e0550e4@posting.google.com>

Thanks for the suggestions. I am a complete beginner with perl. Since
I do not have a lot of data my best bet is perhaps to just read it all
into an array. (Which I thought of just after pressing send on the
original submission!).

TIm


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

Date: Thu, 18 Dec 2003 18:25:55 GMT
From: Clint Olsen <clint@0lsen.net>
Subject: Can't call method "blah" on unblessed reference at
Message-Id: <slrnbu3s9j.kl3.clint@poly.0lsen.net>

So, why would I get this diagnostic _if_ I never intended to call it in the
method form?  The subroutine in question is call like so:

blah $foo;

Where the subroutine foo is in the same package scope and it is called from
a method, but $foo is _not_ the object.  There isn't a stinkin' arrow
there, so I don't know why Perl things I'm trying to call a method.

If I add parentheses like so:

blah($foo)

Then things seem to progress.

Confused,

-Clint


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

Date: Thu, 18 Dec 2003 18:38:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Can't call method "blah" on unblessed reference at
Message-Id: <x7brq6c6p3.fsf@mail.sysarch.com>

>>>>> "CO" == Clint Olsen <clint@0lsen.net> writes:

  > blah $foo;

  > If I add parentheses like so:

  > blah($foo)

  > Then things seem to progress.

from perlsyn:

	Declaring a subroutine allows a subroutine name to be used
	as if it were a list operator from that point forward in the
	program.  You can declare a subroutine without defining it
	by saying "sub name", thus:

	    sub myname;
	    $me = myname $0             or die "can't get myname";

you can't just use a sub as a list operator without predeclaring it. you
can put the sub's code before its use and that will work also. perl has
no way to differentiate these:

	foo $blah	# sub call
	Foo $arg	# indirect object call (class method).

so unless it knows foo is a sub it chooses the latter and in your case
barfs up the error.

the parens always mark it as a sub (no possible ambiguity) so it works
fine. this is a good reason to always use parens for your sub calls
(unless you want them to look like operators and then you have to
declare them in advance).

uri

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


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

Date: 18 Dec 2003 18:42:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Can't call method "blah" on unblessed reference at
Message-Id: <u9r7z2ynly.fsf@wcl-l.bham.ac.uk>

Clint Olsen <clint@0lsen.net> writes:

> So, why would I get this diagnostic _if_ I never intended to call it in the
> method form?  The subroutine in question is call like so:
> 
> blah $foo;
> 
> Where the subroutine foo is in the same package scope and it is called from
> a method, but $foo is _not_ the object.  There isn't a stinkin' arrow
> there, so I don't know why Perl things I'm trying to call a method.

If you look up "Method Invocation" in the relevant manual (perlobj)
you'll find that the very first thing it say is "There are two ways to
invoke a method...".

> If I add parentheses like so:
> 
> blah($foo)
> 
> Then things seem to progress.

That is correct.  You can call a subroutine using the explicit
parentheses syntax even if it's not yet been declared.  You can't call
a subroutine without parentheses until after the declaration.

This is, IIRC, explained in "perlsub".

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


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

Date: 18 Dec 2003 11:03:12 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Can't call method "blah" on unblessed reference at
Message-Id: <3fe1f9f0@news.victoria.tc.ca>

Clint Olsen (clint@0lsen.net) wrote:
: So, why would I get this diagnostic _if_ I never intended to call it in the
: method form?  The subroutine in question is call like so:

: blah $foo;

: Where the subroutine foo is in the same package scope and it is called from
: a method, but $foo is _not_ the object.  There isn't a stinkin' arrow
: there, so I don't know why Perl things I'm trying to call a method.

: If I add parentheses like so:

: blah($foo)

: Then things seem to progress.

: Confused,

	$foo->blah()

is the same as

	blah $foo

but the second form (so I am told) is ambiguous.  Apparently, in your
case, perl thought you were trying to use that second form.  The reasons
for that are in the rest of the code that you don't show - something about
the syntax you used made perl think you wanted to call a method.

The brackets dis-ambiguated this to be a simple function call.

I suspect that predeclaring the function would also do that, but I don't
that enough myself to say for sure.


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

Date: Thu, 18 Dec 2003 07:47:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Creating a list of HASHes
Message-Id: <slrnbu3bvm.jc8.tadmc@magna.augustmail.com>

Patrick Paquet <jack_luminous@hotmail.com> wrote:
> "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in message news:<Xns9454825E92C74asu1cornelledu@132.236.56.8>...


>> my $InfosMachine = shift;
> 
> That's interesting, had to look up SHIFT, 


Case matters. Perl has a shift(), it does not have a SHIFT().


> and think it thru for a few
> minutes.  So Shift passes the first element (the hash reference) to
> $InfosMachine.  


AND it removes that first element from @_, making it one element shorter.


> And you're right, it makes things pretty clear.  If
> you have time, I'd be curious to see how you would handle multiple
> arguments to a sub, for example (off the top of my head....  really):
> 
> EcriteSQL($SQLConnect,$RecordStatus,\%InfoMachine)
> 
> I guess shift is not useable in that context since it only returns the
> first element from the array.(?)


You can always call shift() another time:

   my $connect = shift;   # get 1st argument
   my $status  = shift;   # get 2nd argument
   my $href    = shift;   # @_ now has 3 less elements in it

or, better IMO:

   my($connect, $status, $href) = @_;  # @_ still has all original elements


> And after all that, I've got the script running properly now, and I
> also have a better (although not yet perfect) grasp of scope, hashes


Both variable scope and hashing are taught in the usual CS curriculum,
you'll need to pick them up yourself if you are a self-taught programmer.

I can't remember if this article has been mentioned in this thread yet:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


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


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

Date: 18 Dec 2003 07:01:34 -0800
From: jack_luminous@hotmail.com (Patrick Paquet)
Subject: Re: Creating a list of HASHes
Message-Id: <14e35cbb.0312180701.a8b96c4@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<brs3mo$8s2$1@mamenchi.zrz.TU-Berlin.DE>...
<snip>
> I hope you didn't overlook the more severe error of assigning an array
> to a scalar.   That's what made your attempt fail.

Indeed, that was sorted out.  I ended up using A. Sinan Unur's method
of passing along the reference to the HASH. ie:

    my $InfosMachine = shift;

in the sub.

Actually, I now use that method for all the subs where I have only one
argument to pass.

<snip>
> 
> Anno

Thanks for your help!


Patrick


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

Date: Thu, 18 Dec 2003 08:01:48 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Determine DaysInMonth($month)
Message-Id: <slrnbu3cqc.jc8.tadmc@magna.augustmail.com>

Eric <Eric@nowhere.com> wrote:

> Can you help me write a piece of code to do this:


No.

Trolls can write their own code.


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


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

Date: Thu, 18 Dec 2003 14:28:51 -0000
From: "Eric" <Eric@nowhere.com>
Subject: Re: Determine DaysInMonth($month)
Message-Id: <brsdij$90c$1@newsg3.svr.pol.co.uk>

> > Can you help me write a piece of code to do this:
>
> No.
>
> Trolls can write their own code.

Wasn't trolling. What made you think I was?




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

Date: Thu, 18 Dec 2003 15:08:12 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Determine DaysInMonth($month)
Message-Id: <wpjEb.18282$G9.8166@nwrddc01.gnilink.net>

Eric wrote:
[...]
> I don't have the ability to install modules as I'm on a shared
> server.

So what? That's not a valid excuse.
Apparently you can install your own programs. Then you can install your own
modules, too. Please see the FAQ about how to do that ("How do I keep my own
module/library directory?")

> And I don't have Time::DaysInMonth installed.

Well, you can still copy and paste the code from Time::DaysInMonth into your
own code, can't you (unless this module is not written in Perl, but I don't
think so).

jue




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

Date: Thu, 18 Dec 2003 16:44:26 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Determine DaysInMonth($month)
Message-Id: <brsl2t$dlp$1@news.dtag.de>

Eric wrote:

> Hi,
> 
> Can you help me write a piece of code to do this:
> 
> my $daysinmonth = &DaysInMonth($month)
> 
> Where $month is the month num (1-12).

You really dont want to this yourself. Finding leap years, as others 
suggested, is not as easy as one might think on the first look.


> I don't have the ability to install modules as I'm on a shared server. And I
> don't have Time::DaysInMonth installed.

If you can install a regular Perl application, you can install any other 
module which is written in Perl, too.

Bye
malte

--
http://www.tfu-films.de



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

Date: Thu, 18 Dec 2003 10:03:33 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Determine DaysInMonth($month)
Message-Id: <slrnbu3jul.jgc.tadmc@magna.augustmail.com>

Eric <Eric@nowhere.com> wrote:

[ please include an attribution when you quote someonw ]


>> Trolls can write their own code.
> 
> Wasn't trolling. What made you think I was?


You said so yourself in:

   Message-ID: <brs1fb$rc6$1@news6.svr.pol.co.uk>

   For the sole purpose of annoying you.


Posting only to annoy folks is pretty much the definition of trollism.


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


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

Date: 18 Dec 2003 17:29:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Determine DaysInMonth($month)
Message-Id: <brso5c$oc6$1@mamenchi.zrz.TU-Berlin.DE>

Carsten Aulbert  <carsten@welcomes-you.com> wrote in comp.lang.perl.misc:
> 
> 
> Eric wrote:
> > Hi,
> > 
> > Can you help me write a piece of code to do this:
> > 
> > my $daysinmonth = &DaysInMonth($month)
> > 
> > Where $month is the month num (1-12).
> 
> That's pretty simple, all month have (at least) 28 days ;-)
> 
> Ok, enough of the kidding:
> 
> sub DaysInMonth {
>    my $month = shift;
>    my $year = shift; # need full year, i.e. 03 is _not_ sufficient
>    my @month_length = (0,31,28,31,30,31,30,31,31,30,31,30,31);
> 
>    # only special month is February
>    return $month_length[$month] unless $month == 2;
> 
>    # February has always 28 days, except if the year is
>    # dividable by 4 (without remainder). Exceptions are
>    # full centuries
> 
>    return 29 if $year % 4 == 0 and $year % 100 != 0;
>    return 29 if $year % 400 == 0;
>    return 28;
> }

The code is fine, as far as I can tell from manual inspection, but the
comment doesn't match the code.  It fails to acknowledge the exception
from the exception for years divisible by 400.

I mention this not for the pure joy of pedantry (or not purely for the
joy of pedantry), but because it is a good illustration of how fragile
comments are.  I mean, a slip like that happens easily, in fact it's hard
to avoid entirely when you do a lot of commenting.  It wouldn't even hurt
much in this case because the leap year algorithm is well known and easily
accessible.

But finding one comment in a program that's clearly out of sync with the
code means that you'll have to think of that possibility with every comment
in the program.  That reduces their utility considerably.  Old story about
one bad apple...

I guess what I'm saying is not that comments are useless, but they take
more effort, in writing *and* maintenance, than is usually acknowledged.
They should be considered potentially expensive parts of the code that
are to be used sparingly, not proliferated.

Anno


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

Date: Thu, 18 Dec 2003 18:52:10 -0000
From: "Eric" <Eric@nowhere.com>
Subject: Re: Determine DaysInMonth($month)
Message-Id: <brst0a$mie$1@newsg4.svr.pol.co.uk>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbu3jul.jgc.tadmc@magna.augustmail.com...
> Eric <Eric@nowhere.com> wrote:
>
> [ please include an attribution when you quote someonw ]
>
>
> >> Trolls can write their own code.
> >
> > Wasn't trolling. What made you think I was?
>
>
> You said so yourself in:
>
>    Message-ID: <brs1fb$rc6$1@news6.svr.pol.co.uk>
>
>    For the sole purpose of annoying you.
>
>
> Posting only to annoy folks is pretty much the definition of trollism.
>

If you read that whole thread you'd realise you've taken me completely out
of context. I was being sarcastic.

You're probably American I guess.

Eric




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

Date: Thu, 18 Dec 2003 16:53:12 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: html-->text, keep line breaks, best strategy is?
Message-Id: <Xns945578EA0DA6Fdkwwashere@216.168.3.30>

Henry <henryn@zzzspacebbs.com> wrote:

> In short, I need extract text from HTML, preserving breaks.
[snip for space]
> As it stands, HTML::Parse seems my best bet.  Comments?

HTML::Parse is deprecated, use HTML::Parser.  IF HTML::Parser seems 
weird you can use the alternative interface provided by 
HTML::TokeParser.

> It it fairly typical to load a couple of different modules, trying
> them on for size until the best fit is found?

I don't know about other people, but that's what I often do.  You 
don't actually have to install them, though.  You can read the docs 
on the CPAN site and see if they do what you want in a way that 
you're comfortable with.  Running the examples can help.  I often 
write short programs to test the particular functions that interest 
me before I try to use the module in the real program I'm writing.

> Any particular penalty besides disk space used for leaving unused
> modules lying around?

None that I know of.  I suppose you could argue that it increases the 
size of the directory it's in and makes filesystem lookups slower for 
other module files in that directory, but that's a bit too esoteric 
for me to worry about.

-- 
David Wall


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

Date: Thu, 18 Dec 2003 17:19:05 -0000
From: "Chris Arnott" <chris.arnottHATESSPAM@uk.lionbioscience.com>
Subject: logonserver value
Message-Id: <hklEb.29$rR6.378@psinet-eu-nl>

Hello & thanks for any help in advance.

I have a perl script which gathers information on a remote machine and
creates a php file from the gathered info.

I'd like to gather the logonserver value from the remote machine but if I
try reading the hkcu/volatile environment/logonserver value i get a
overlapped io in progress error.

Does anyone know of a good way to achieve this?

Thanks,

Chris Arnott.




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

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


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