[26839] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8865 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 18 18:05:40 2006

Date: Wed, 18 Jan 2006 15:05:08 -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           Wed, 18 Jan 2006     Volume: 10 Number: 8865

Today's topics:
        Cant' call method "EOF" on an undefined value... <mbaker@selectsa.com>
    Re: FAQ 3.5 How do I debug my Perl programs? <matthew.garrish@sympatico.ca>
        hash mystery <steve@statenet.com>
    Re: hash mystery <noreply@gunnar.cc>
    Re: hash mystery <ddunham@redwood.taos.com>
        limiting a loop to 100 <Mark.Fenbers@noaa.gov>
    Re: limiting a loop to 100 <xx087@freenet.carleton.ca>
    Re: limiting a loop to 100 <Mark.Fenbers@noaa.gov>
        looking for a sample program <nospam@home.com>
    Re: Netiquette aspect <noreply@gunnar.cc>
    Re: Open Source Blog SW wanted <tlviewerSHRUB@yahooCHENEY.com>
    Re: Open Source Blog SW wanted <RemoveThisPrefixmatts2nospam@ix.netcom.com>
    Re: Open Source Blog SW wanted <usenet200601@tobyinkster.co.uk>
    Re: Open Source Blog SW wanted <phaylon@dunkelheit.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Jan 2006 22:41:41 GMT
From: "Marc Baker" <mbaker@selectsa.com>
Subject: Cant' call method "EOF" on an undefined value...
Message-Id: <Fuzzf.1408$Ql1.553@chiapp18.algx.net>

Hi all,

I'm a newbie here, so bear with my ignorance.  I have an existing perl 
script that I inherited.  Basically, it is erroring out sporadically with 
"Can't call method "EOF" on an undefined value at...".  The line of code 
that it references is doing a SELECT from a MSSQL database.  The perl script 
is being called from the Microsoft SQL Server Agent.  The weird thing is 
that this code is not failing all the time, and if I run it manually after 
it fails, it will run fine.  The data that is being SELECT'ed is static so 
nothing is changing from the unsuccessful to a successful run.  Below is the 
a snippet of the code.  The line that it is failing on is:  while(! 
$rec_set->EOF) {



   $rec_set = $conn->Execute("SELECT INVOICES.CLIENT_ID, INVOICES.MATTER_ID, 
INVOICES.INVOICE_NO, INVOICES.INVOICE_DATE, IMBAL.INVOICE_ID, 
IMBAL.DET_BALANCE, IMBAL.SUM_BALANCE FROM MNT_IMBAL_INVOICE_RECS IMBAL LEFT 
OUTER JOIN $MNT_ODS_DB.dbo.INVOICES INVOICES ON INVOICES.ID = 
IMBAL.INVOICE_ID WHERE INVOICES.INVOICE_DATE > '1994-12-31 00:00:00' AND 
IMBAL.MNT_BAL_REPORT_ID = $id");

   print REPORT_FILE sprintf("\n%-78s\n\n", "Invoices whose detail balance 
does not agree with their summary balance");

   print REPORT_FILE sprintf("%11s %9s %11s %12s %11s %15s %15s\n", 
"CLIENT_ID", "MATTER_ID", "INVOICE_NO", "INVOICE_DATE", "INVOICE_ID", 
"Detail Balance", "Summary Balance");
   my($invoice_id, $det_bal, $sum_bal, $m_matter_id, $m_client_id, 
$m_invoice_no, $m_invoice_date);


   while(! $rec_set->EOF) {
      $m_client_id = $rec_set->Fields('CLIENT_ID')->Value;
      $m_matter_id = $rec_set->Fields('MATTER_ID')->Value;
      $m_invoice_no = $rec_set->Fields('INVOICE_NO')->Value;
      $m_invoice_date = $rec_set->Fields('INVOICE_DATE')->Value;
      $invoice_id = $rec_set->Fields('INVOICE_ID')->Value;
      $det_bal = $rec_set->Fields('DET_BALANCE')->Value;
      $sum_bal = $rec_set->Fields('SUM_BALANCE')->Value;
      print REPORT_FILE sprintf("%9s %9s %11s %12s %8s %15s %15s\n",
                           $m_client_id, $m_matter_id, $m_invoice_no, 
$m_invoice_date,
                           $invoice_id, commify(sprintf("%.2f", $det_bal)), 
commify(sprintf("%.2f", $sum_bal)));
      $rec_set->MoveNext; 




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

Date: Wed, 18 Jan 2006 14:49:23 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: FAQ 3.5 How do I debug my Perl programs?
Message-Id: <1Zwzf.7574$924.158068@news20.bellglobal.com>


"Jim Gibson" <jgibson@mail.arc.nasa.gov> wrote in message 
news:180120061104210746%jgibson@mail.arc.nasa.gov...
> In article <20060117205548.955$A8@newsreader.com>, <xhoster@gmail.com>
> wrote:
>
>> Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
>> > In article <dqbvv4$ps$1@reader2.panix.com>, PerlFAQ Server
>> > <comdog@pair.com> wrote:
>> >
>> > >
>> > > 3.5: How do I debug my Perl programs?
>> > >
>> >
>> > [5 good suggestions snipped]
>> >
>> >    Use the print statement.
>>
>> I would usually suggest warn rather than print.
>
> Acknowledged. You and I are on different sides in the print vs. warn
> issue (<http://tinyurl.com/9x9j6>) but I think the advice to use warn
> doesn't have the simplicity and directness of using print.

I agree, even if I don't completely agree. It would depend on the 
circumstances. If I were leaving the statements in for some reason or the 
value being printed would get jumbled into the program's output, I'd use 
warn. If it really doesn't make a difference if the value goes to STDOUT or 
STDERR my mind always drifts to print. I also have to debug a lot of Web 
apps, so printing the values back to the browser might be clouding my 
judgement.

Matt 




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

Date: Wed, 18 Jan 2006 21:02:03 GMT
From: monkeys paw <steve@statenet.com>
Subject: hash mystery
Message-Id: <f1yzf.716502$_o.120739@attbi_s71>

For some reason i'm forced to use a scalar for
ONE hash element and not the rest. Here is how the
code behaves:

This works:

$qry = new CGI;

foreach (@names) {
   if ($_ =~ /^newsummary(.*)$/ && $qry->param($_)) {
   # I have no clue why 'id' must be a scalar to work. [sf]
   my $id = $qry->param('id' . $1);
   %hash = (
       file_name => $qry->param('file_name' . $1),
       id => $id,
       comment_name => $qry->param('newsum_name' . $1),
       id_type => 'bill',
       commentary => $qry->param($_),
   );
   }
}

At his point the hash looks like:

file_name => 'file',
id => 'CA2005',
comment_name => 'cname',
id_type => 'bill',
commentary => 'some comment',

However, if i use $qry for 'id' the hash gets whacked like
so:

   %hash = (
       file_name => $qry->param('file_name' . $1),
       id => $qry->param('id' . $1),
       comment_name => $qry->param('newsum_name' . $1),
       id_type => 'bill',
       commentary => $qry->param($_),
   );


CA2005 => undef,
file_name => 'file',
id => 'CA2005',
comment_name => 'cname',
id_type => 'bill',
commentary => 'some comment',



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

Date: Wed, 18 Jan 2006 22:16:00 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: hash mystery
Message-Id: <437pchF1m4tf2U1@individual.net>

monkeys paw wrote:
> For some reason i'm forced to use a scalar for
> ONE hash element and not the rest.

<incomplete code snipped>

Please post a short but _complete_ program that people can copy and run, 
and that illustrates your observation - just as is recommended in the 
posting guidelines for this group: 
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 18 Jan 2006 21:41:17 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: hash mystery
Message-Id: <1Cyzf.490$2O6.33@newssvr12.news.prodigy.com>

monkeys paw <steve@statenet.com> wrote:
> For some reason i'm forced to use a scalar for
> ONE hash element and not the rest. Here is how the
> code behaves:

>    my $id = $qry->param('id' . $1);

perhaps param('id' . $1) is multivalued?  

-- 
Darren Dunham                                           ddunham@taos.com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Wed, 18 Jan 2006 16:49:52 -0500
From: Mark <Mark.Fenbers@noaa.gov>
Subject: limiting a loop to 100
Message-Id: <dqmf4k$ht5$1@news.nems.noaa.gov>

I have a loop similar to the following:

foreach (keys %myhash) {
   # do stuff
}

My hash table can be quite large in certain situations, and so I need to 
modify the loop such that it only iterates only 100 times.  Can I limit 
it cleverly?  I know I can do it by keeping a counter, like so:

$c = 0;
foreach (keys %myhash) {
   last if $c++ >= 100;
   # do stuff
}

But this seems clunky to me.  I am curious as to whether there is a more 
elegant way (or "trick"), such as something like this:

foreach (grep 0,100 keys %myhash) {
   # do stuff
}

Am I stuck with the clunky way?

Still learnin'
Mark


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

Date: 18 Jan 2006 22:16:21 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: limiting a loop to 100
Message-Id: <slrndstfhl.j8f.xx087@smeagol.ncf.ca>

At 2006-01-18 04:49PM, Mark <Mark.Fenbers@noaa.gov> wrote:
>  My hash table can be quite large in certain situations, and so I need to 
>  modify the loop such that it only iterates only 100 times.  Can I limit 
>  it cleverly?  I know I can do it by keeping a counter, like so:
>  
>  $c = 0;
>  foreach (keys %myhash) {
>     last if $c++ >= 100;

Perhaps:
    foreach ((keys %myhash)[0..99]) {
       # do stuff
    }


-- 
Glenn Jackman
Ulterior Designer


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

Date: Wed, 18 Jan 2006 17:18:54 -0500
From: Mark <Mark.Fenbers@noaa.gov>
To: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: limiting a loop to 100
Message-Id: <43CEBECE.2070407@noaa.gov>

> Perhaps:
>     foreach ((keys %myhash)[0..99]) {
>        # do stuff
>     }

Yes, Thank you!  This is what I was looking for!
Mark


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

Date: Wed, 18 Jan 2006 21:58:35 GMT
From: "Nospam" <nospam@home.com>
Subject: looking for a sample program
Message-Id: <fSyzf.59198$Dg6.29129@newsfe3-gui.ntli.net>

I am looking for a perl script on a server that takes an email address input
from a web user on a form on the html page and posts info to the email
address




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

Date: Wed, 18 Jan 2006 21:50:51 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Netiquette aspect
Message-Id: <437ntdF1m03blU1@individual.net>

John Bokma wrote:
> Gunnar Hjalmarsson wrote:
>>John Bokma wrote:
>>>And no, I am not going to reload the whole thread :-D.
>>
>>Then you should probably think twice before jumping in, since there is
>>no way you can tell whether you will add any value if you post.
> 
> Yup, I agree, and I do that more and more nowadays (thinking twice before 
> posting).

Well, no need to extrapolate my remark like that. ;-)  I was just trying 
to show that some ways to handle the participation in the group may be 
incompatible with good netiquette.

> OTOH, I guess that a lot (and I mean a lot) of posts on Usenet 
> are just repeating the same stuff over, and over again.

Unfortunately true. The reasons being lazy dogs, people who don't care 
about the netiquette, and Google.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 18 Jan 2006 19:18:22 GMT
From: "tlviewer" <tlviewerSHRUB@yahooCHENEY.com>
Subject: Re: Open Source Blog SW wanted
Message-Id: <2wwzf.936$Z3.470@tornado.socal.rr.com>


"Matt Silberstein" <RemoveThisPrefixmatts2nospam@ix.netcom.com> wrote in
message news:b83ts19plbuc7ojb4d3555tqlu7k7c32gk@4ax.com...
> I am looking for advice on an open source Blog system, preferably in
> Perl.

www.movabletype.org

there is a single license version that is still free, though you will have
to
register.

--

good luck,
tlviewer




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

Date: Wed, 18 Jan 2006 19:38:09 GMT
From: Matt Silberstein <RemoveThisPrefixmatts2nospam@ix.netcom.com>
Subject: Re: Open Source Blog SW wanted
Message-Id: <l46ts11imbb3g72joplmeovuou47uojfqt@4ax.com>

On Wed, 18 Jan 2006 19:18:22 GMT, in comp.lang.perl.misc , "tlviewer"
<tlviewerSHRUB@yahooCHENEY.com> in
<2wwzf.936$Z3.470@tornado.socal.rr.com>  wrote:

>
>"Matt Silberstein" <RemoveThisPrefixmatts2nospam@ix.netcom.com> wrote in
>message news:b83ts19plbuc7ojb4d3555tqlu7k7c32gk@4ax.com...
>> I am looking for advice on an open source Blog system, preferably in
>> Perl.
>
>www.movabletype.org
>
>there is a single license version that is still free, though you will have
>to
>register.

Sorry I was not clear. I need the source since I am going to do
extensive modifications. I am looking for a scaffold to hang a system
on and a blog system, like WebAPP would be a start. I did find both
Explosive and Weeblog at Sourceforge, so if anyone has experience with
them please let me know. 

-- 
Matt Silberstein

Do something today about the Darfur Genocide

http://www.beawitness.org
http://www.darfurgenocide.org
http://www.savedarfur.org

"Darfur: A Genocide We can Stop" 


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

Date: Wed, 18 Jan 2006 19:30:36 +0000
From: Toby Inkster <usenet200601@tobyinkster.co.uk>
Subject: Re: Open Source Blog SW wanted
Message-Id: <sjh2a3-p0h.ln1@ophelia.g5n.co.uk>

Matt Silberstein wrote:

> I am looking for advice on an open source Blog system, preferably in
> Perl.

MoveableType is probably the best known Perl blog software. It's not Open
Source though, so you'll need to check licencing conditions before making
any modifications.

-- 
Toby A Inkster BSc (Hons) ARCS
Contact Me  ~ http://tobyinkster.co.uk/contact



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

Date: 18 Jan 2006 20:48:22 GMT
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: Open Source Blog SW wanted
Message-Id: <43cea996$0$21025$9b4e6d93@newsread2.arcor-online.net>

Matt Silberstein <RemoveThisPrefixmatts2nospam@ix.netcom.com> wrote
> I am looking for advice on an open source Blog system, preferably in
> Perl.

The Catalyst development community (www.catalystframework.org) is
currently finishing a Blog-Application named Agave (IIRC just a
temporary project name). The repo seems down currently, but you could
ask the ML or on irc.perl.org.

hth, phay

-- 
The eternal mistake of mankind is to set up an attainable ideal.
                        -- Aleister Crowley


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

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


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