[24342] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6531 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 6 14:06:00 2004

Date: Thu, 6 May 2004 11:05:09 -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           Thu, 6 May 2004     Volume: 10 Number: 6531

Today's topics:
    Re: Books online???? (GreenLight)
    Re: Books online???? (taswold)
    Re: Books online???? <dwall@fastmail.fm>
    Re: Directory sorted in chronological order <uri@stemsystems.com>
    Re: for loop <mark.clements@kcl.ac.uk>
    Re: for loop <Graham.T.Wood@oracle.com>
    Re: free source authentication script <vetro@online.no>
    Re: How do I get MIME skeleton? (Malcolm Dew-Jones)
    Re: How do I get MIME skeleton? <raj.kothary@thus.net>
        List questions on form (Roger)
    Re: Passing data from javascript to perl? <dragnet@internalysis.com>
    Re: perl require (GreenLight)
    Re: Please Recommend A Good Perl Book. (Greg Bacon)
    Re: Please Recommend A Good Perl Book. (Mark Jason Dominus)
    Re: read from comma delimited file ctcgag@hotmail.com
    Re: Sort Hash o Hash accordint to two keys <uri@stemsystems.com>
    Re: Strange DBI problem <tore@aursand.no>
    Re: Strange DBI problem ctcgag@hotmail.com
        Trapping warnings <raj.kothary@thus.net>
    Re: Trapping warnings <1usa@llenroc.ude>
    Re: Trapping warnings <GM@foo.bar>
    Re: Use of goto after an alarm? axel@white-eagle.co.uk
    Re: Use of goto after an alarm? ctcgag@hotmail.com
    Re: Use of goto after an alarm? axel@white-eagle.co.uk
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 6 May 2004 08:50:10 -0700
From: google@milbaugh.com (GreenLight)
Subject: Re: Books online????
Message-Id: <c4b60ce1.0405060750.26769105@posting.google.com>

Henry Williams <***************> wrote in message news:<f64590houchivatqrgusbvpsqn29nk1r8f@4ax.com>...
> I have been researching Perl extensively for the last 3 weeks. Along
> the way I have found several Internet sites that have all the O'Reilly
> books on perl, online. The even have the copyright notice published

Okay, I have read this entire thread (ouch), and I agree that it is
trivially easy to find these books online by simply googling for the
copyright notice. I have to think, then, that someone at O'Reilly is
doing this on a regular basis, and probably does not need me to report
the infraction.

I have noticed, however, that many of the infringing sites are in .cn
domains, and that the operators of those sites generally have little
regard for intellectual property.


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

Date: 6 May 2004 09:48:56 -0700
From: hen_mcgiggle@yahoo.co.uk (taswold)
Subject: Re: Books online????
Message-Id: <288fb229.0405060848.25f73386@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news: 

> When a posting annoys me, I reserve the right to reply in kind.  Why
> should the wishes of the poster take precedence?

That depends on how easily annoyed you are, and how justified your
annoyance.

People in the real world might expect you to keep your irritation to
yourself for the general good. Whereas I (after long lurking) expect
you to pedantically reply to this with horribly specious arguments
that I really hope you don't believe.

I *almost* sympathise with you about the trolls and the
do-my-homeworks. You guys sometimes do some great things on here*.
Unfortunately, you're also such a pompous bunch of nitwits.

"RTFM"  IS rude and unhelpful, how in God's name can you seriously
pretend otherwise?

I've read that nonsensical document (can't find the bookmark just now)
that says how great hackers are, how they don't need to spend their
time here, so we should feel honoured to have incurred their rudeness.
All evidence that you lot can't think straight about much other than
IT.

Go on, ignore the criticism as usual, I await with joyous
anticipation.

tas

* usually when you feel guilty about the last flame war.


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

Date: Thu, 06 May 2004 17:14:44 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Books online????
Message-Id: <Xns94E186BD7E2D9dkwwashere@216.168.3.30>

GreenLight <google@milbaugh.com> wrote:

> "bxb7668" <bxb7668@somewhere.nocom> wrote in message
> news:<Hx5Bp0.Dn1@news.boeing.com>... 
> 
>> stuck or didn't know where to find the answer. I have a firm rule
>> on questions: "There is no such thing as a stupid question. Just
>> stupid answers."
> 
> Well, I completely disagree. I have heard a lot of questions that
> I can only characterize as "stupid". I have never quite grasped
> how that little saying came about...

"There may be no stupid questions, but there sure are a lot of 
inquisitive idiots."


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

Date: Thu, 06 May 2004 16:09:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Directory sorted in chronological order
Message-Id: <x7ad0l35co.fsf@mail.sysarch.com>


don't top post.

edit quotes (i don't need to see my whole post again).

use Benchmark.pm

run the benchmark many times. the first time could be much slower as it
loads the ram with dir and inode entries.

if the file data is fully cached you will get different (and hard to
compare) results than if you had to hit the disk each time. it would be
tricky to create a benchmark that forced disk hits.

name your test files something useful. testtime[12].pl is meaningless
and is the first thing shown. going back and forth to see
which numbers correlate to which code is a pain.

read sysarch.com/perl/sort_paper.html

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: Thu, 06 May 2004 16:11:18 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: for loop
Message-Id: <409a5589$1@news.kcl.ac.uk>

Richard Morse wrote:
> In article <409a0400$1@news.kcl.ac.uk>,
>  Mark Clements <mark.clements@kcl.ac.uk> wrote:

>>for(my $i = 0 ; $i < $#array ; $i++){
> Shouldn't that be either:
> 
>    $i <= $#array
> or
>    $i < @array
er - yes. off by one, and not for the first time :(

> (or, and I know I will be castigated to kingdom come for this, but my 
> preferred version is:
> 
>    $i < scalar(@array)
does it for me: nothing wrong with adding clarity by being explicit.

Mark


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

Date: Thu, 06 May 2004 17:09:52 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: for loop
Message-Id: <409A6350.D768AFAA@oracle.com>



Mark Clements wrote:
> 
> Fatted wrote:
> 
> > for($i = 0, @array, $i++)
> > {
> >     print $_."\n";
> > }
> >
> > This prints:
> > 1
> > first
> > second
> > third
> > fourth
> > 0
> 
<SNIP>
I think what is happening here, to quote from perldoc perlop, is " list
operators tend to gobble up all arguments that follow, and then act like
a simple TERM with regard to the preceding expression. "  So the list in
your for loop ends up being $i++ then the elements in @array then the
$i=0 which is then treated as one expression with values:
1, first, second, third, fourth, 0

Can anyone confirm this theory?

Graham


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

Date: Thu, 06 May 2004 19:52:37 +0200
From: Vetle Roeim <vetro@online.no>
Subject: Re: free source authentication script
Message-Id: <m3isf9fnoa.fsf@quimby.dirtyhack.org>

* webmaster @ infusedlight . net
> "Tore Aursand" <tore@aursand.no> wrote in message
> news:pan.2004.05.05.09.47.28.929692@aursand.no...
>> On Tue, 04 May 2004 22:22:45 -0800, Robin wrote:
>> > www.infusedlight.net/robin/temp/auth.txt
>>
>> A short summary:
>>
>>   * You're _still_ not indenting your code properly.
>
> It's indented in the way I like it. How would you define "properly"?

  You're free to indent as you wish, of course, but it would probably
  be easier to get help if you formatted your code the way people here
  suggest.

  You could try using perltidy,
  <URL:http://perltidy.sourceforge.net/>.


[...]

-- 
Touch eyeballs to screen for cheap laser surgery!


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

Date: 6 May 2004 09:53:03 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How do I get MIME skeleton?
Message-Id: <409a6d6f@news.victoria.tc.ca>

Mark (admin@asarian-host.net) wrote:
: Good morning,

: I have been using MIME::Parser (From MIME-tools-6.200_02) to get a list of
: all the "part" names of a MIME encoded message. I used something like:

: $entity -> dump_skeleton ();

: However, that decodes the entire message, and writes its parts to disk. And
: all I want, is a list of names of all the parts (recursed). Like
: dump_skeleton does, but then without the expensive decoding/disk IO.

: Does anyone know whether there is an existing function for this?

: Thank you,


Try the following module (not yet on cpan)

	http://nisoftware.com/files/MIME-Xparser-0.0.tar.gz

Then use a script something like the following example (which handles a 
single message in a file passed on the command line).

#!/usr/bin/perl

use MIME::Xparser;

package handler;

sub new { bless \ my $obj , 'handler' }
sub AUTOLOAD {}

sub header
{   my $obj = shift;
    my $header = shift;
    my $name;

    if ( ($name) = $header =~ m/^content-type:.*?\bname=(.*)/is )
    {
        $name = MIME::Xparser::parse_value( $name);
        print "name=$name\n";
    }

    elsif (($name)=$header=~m/^content-disposition:.*?\bfilename=(.*)/is)
    {
        $name = MIME::Xparser::parse_value( $name);
        print "filename=$name\n";
    }

}

package main;

my $parser = new MIME::Xparser( new handler );

$parser->start_document();

while (<>)
{
    $parser->line($_);
}

$parser->end_document();



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

Date: Thu, 6 May 2004 18:05:47 +0100
From: "Raj" <raj.kothary@thus.net>
Subject: Re: How do I get MIME skeleton?
Message-Id: <c7drd4$lcv$1$8302bc10@news.demon.co.uk>

"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:409a6d6f@news.victoria.tc.ca...
> Mark (admin@asarian-host.net) wrote:
> : Good morning,
>
> : I have been using MIME::Parser (From MIME-tools-6.200_02) to get a list
of
> : all the "part" names of a MIME encoded message. I used something like:
>
> : $entity -> dump_skeleton ();
>
> : However, that decodes the entire message, and writes its parts to disk.
And
> : all I want, is a list of names of all the parts (recursed). Like
> : dump_skeleton does, but then without the expensive decoding/disk IO.
>
> : Does anyone know whether there is an existing function for this?

You could also try this:

sub find_part() {
        my $fname = shift;
        my($message) = new MIME::Parser;
        $message->output_to_core(1);

        my($entity) = $message->parse_open($fname);

        $e_part = undef;
        for($i=0; $i< $entity->parts; $i++) {
                $part = $entity->parts($i);
                $part_name = $part->head->recommended_filename || "(null)";

                print "  Part $i=$part_name\n" if ($opt_v);

                if ($part_name =~ /part.you.want/i) {
                        $e_part = $part->bodyhandle;
                        last;
                }
            return $e_part;
        }

Or something similar!

I hope this helps (this is the first time I have posted a solution to
anything).

Regards
Raj




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

Date: 6 May 2004 10:43:47 -0700
From: roger10232001@yahoo.com (Roger)
Subject: List questions on form
Message-Id: <a872a169.0405060943.1f99374c@posting.google.com>

Here's the code, a comment at the end about what I'm trying to do.


@list = ("w","d","e","e","d","r","f","e","d",
"c","v","g","h","t","y","h","g","t","h","y","D","P");


  while( @list )  # just debugging here
  {
  @end = @list[16..19];
  splice (@list,16,17, "Z", "X"); # after this 18..21 are undef
  splice(@list ,18,1, @end);
  ($Fld1) = "|" . join "|", @list ;
  ($Fld1) .= "|";
  print $Fld1;
  }
  
  #The basic idea here is to take a list, remove some values in the middle
  #and replace them with some other values, and then make the entire record
  #pipe delimited, beginning to end.
  #It might be a hash would be a better choice, but my 'expertise' does
  #not yet reach to that data type
  #I have accomplished the tasks mentioned but it's real, real ugly, I know.
  #Obviously I'm very new to Perl, thanks for any help.


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

Date: Thu, 06 May 2004 17:43:25 GMT
From: Marc Bissonnette <dragnet@internalysis.com>
Subject: Re: Passing data from javascript to perl?
Message-Id: <Xns94E18B9FD680Adragnetinternalysisc@207.35.177.134>

Bryan Coon <bcoon@sequenom.com> wrote in news:k8emc.60621$4o1.57902
@newssvr25.news.prodigy.com:

> Hi,
> 
> I have some perl scripts built which do pagination.  They just connect 
> to mysql and retrieve data sets using limit().  I have been informed by 
> the powers that be however that they want to have multiple selections 
> available -accross- pages.
> 
> I set up CGI::Session, and have built in the functionality to store the 
> id's of all items checked in the Session object, and to recheck items 
> that were previously checked.  The big problem is if a user deselects an 
> item.  How do I notify the perl script which item or items (there could 
> be a bunch per page) have been deselected????
> 
> At the end of the day, I need to have a perl array with the deselected 
> values in it, so I can compare it to the previously selected items 
> stored in their array in the Session object.  It would then be easy to 
> compare and remove the deselected items.
> 
> The only thing I can think of at the moment is some javascript array 
> that stuffs in the deselected id's, and then passes this array to the 
> perl cgi.  But there's no way I know of to pass a javascript array to 
> perl...
> 
> Anyone have any ideas?

I'm no javascript expert, but what about passing them via URL?

http://www.yoursite.com/cgi-bin/script.cgi?var1=value1&var2=value3&var4
=value4 and so on ?


-- 
Marc Bissonnette
CGI / Database / Web Management Tools: http://www.internalysis.com
Something To Sell? Looking To Buy? http://www.whitewaterclassifieds.ca
Looking for a new ISP? http://www.canadianisp.com


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html


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

Date: 6 May 2004 08:59:44 -0700
From: google@milbaugh.com (GreenLight)
Subject: Re: perl require
Message-Id: <c4b60ce1.0405060759.6dcf0a48@posting.google.com>

"bob" <mail@mail.com> wrote in message news:<njWdnaXCoucLhwfdSa8jmA@karoo.co.uk>...
> Is it possible to dynamically change the location of a module
> i.e.
> require Plugins::Wetherbys::Generate::GenerateXML;
> Plugins::Wetherbys::Generate::GenerateXML->import('help');
> 
> works fine
> 
> but ideally
> 
> i would like
> 
> require Plugins::$VAR::Generate::GenerateXML;
> Plugins::Wetherbys::$VAR::GenerateXML->import('help');
> 
> I have looked through the FAQs and couldn't find anything.
> I know you can do require $VAR;
> 
> Cheers

perldoc LIB


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

Date: Thu, 06 May 2004 15:41:26 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <109kn56b0594h1e@corp.supernews.com>

In article <baafbb898a252fe81cbcac6b55ac3103@news.teranews.com>,
    Randal L. Schwartz <merlyn@stonehenge.com> wrote:

: My point is that the existing rules need to be followed. [...]

I explicitly rejected the opposing view: ". . . not, for example, that
people ought to make unauthorized publications."

Greg
-- 
If you can't beat your computer at chess, try kickboxing.


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

Date: Thu, 6 May 2004 15:53:42 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <c7dn26$v3g$1@plover.com>

In article <109i74k5j85h023@corp.supernews.com>,
Greg Bacon <gbacon@hiwaay.net> wrote:
>Actually, I can't wait to own a copy of mjd's upcoming book[*] and
>plan to spend lots of time (re)reading the dead tree rendering, but he
>secured contract terms that will allow him to publish the complete
>text beerfree on the web. 

I want everyone to know that I talked to five publishers about
publishing my book, and all five agreed that I could put it on the
web.  Some agreed readily and some reluctantly, but they all agreed.

So if you're writing a book, and you want it to be on the web, ask,
and the publisher will probably say yes.

> I don't know his motivation behind this particular move,

While I was trying to pick out a publisher, I wrote to Philip
Greenspun for advice.  In fact, I submitted the proposal to Morgan
Kaufman solely on the strength of the good review he gave them on his
web site.  Greenspun wrote back:

        You didn't ask for advice on goals but if you had, I would
        have encouraged you to

        a) forget about how much cash you're going to get from the
        book itself; it won't be significant compared to the effort
        you'll put in

        b) keep the Web rights and have a free Web edition; people in
        Africa will be able to read your book who would never have had
        an opportunity or the ability to buy it; you owe it to
        yourself as an author to ensure that your work gets widely
        read.

I realized that he was absolutely right, so there you have the
motivation.

Around the same time I was corresponding occasionally with a person in
Gabon (West Africa) who wrote to me with Perl questions.  When I
consider the decision to publish the book on the web for free, I think
of this person, who might not otherwise have an opportunity to read it.

>[*] http://perl.plover.com/book/

The book now has a title.  It will be called "Higher Order Perl".


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

Date: 06 May 2004 17:01:17 GMT
From: ctcgag@hotmail.com
Subject: Re: read from comma delimited file
Message-Id: <20040506130117.567$yC@newsreader.com>

Jim Cochrane <jtc@shell.dimensional.com> wrote:
>
> I bet it's possible to come up with an RE for the split that would work,
> but it will not be an easy task.


I'll quote myself from a few years ago:

==============
Alan Pettigrew <alan1.pettigrew1@fox1-europe1.com> wrote:
> But what about embedded commas?  What happens with a line like
>    field1,"field2a, field2b, field2c",field3 ...
> I haven't worked out the regex for this.  Perhaps one of you can.

This seems to work, but I'm sure someone will find some pathological cases
where it won't.  (Other than the obvious of unpaired quotes).  I don't
imagine that it is horribly efficient.

my @x = split /,(?=[^\"]*(?:\"[^\"]*\"[^\"]*)*$)/ ;


Xho
============

Note that this is specifically for the convention where literal q{"} are
protected by doubling them q{""}.  After doing the split, you would still
have to strip the surrounding quotes off of fields that had surrounding
quotes, and undouble the q{""} from literal q{"}.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 06 May 2004 15:56:59 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sort Hash o Hash accordint to two keys
Message-Id: <x7d65h35x0.fsf@mail.sysarch.com>


first, don't top post. read the group guidelines which are posted
regularly.

>>>>> "MY" == Malik Yousef <yousef@pcbi.upenn.edu> writes:

  MY> Let me make it simple
  MY> I have the hash keys with two information, the name and the window
  MY> position separated by <->, for example:

what is a window position? this is already more complex than simple.

  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->1492
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->1531
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->1795
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->23
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->2918
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->2921
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->2925
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->3304
  MY> Bc007713_220356885-220369973_intron15_hsa-mir-153-1<->3305

  MY> I want to sort this keys according to the name and the window
  MY> position, so
  MY> *<->23 should be as the first element, so how could one sort according
  MY> to the first part ($1)<->($2) and the second part at the same time.

you don't have any hash i can see there. you have a list of
values. again, i refer you to the FAQ which answers this. read perldoc
-q sort and write some code and come back if you need more help. post
just the short code sample you wrote.

  MY> Please send your reply also to yousef@pcbi.upenn.edu

you post here, you read here. 

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: Thu, 06 May 2004 17:30:47 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Strange DBI problem
Message-Id: <pan.2004.05.06.14.45.14.414222@aursand.no>

On Thu, 06 May 2004 05:03:48 -0700, Gil Vautour wrote:
> my($query) = @_;
> my(@form,$values,$key);
> 
> foreach $key ($query->param) {
>         if ($query->param($key) ne "") {
> 	    $values = $query->param($key);
>             $values = $dbh->quote($values);
>             push @form,$values;
> 	} else {
> 	    $values = "null";
>             push @form,$values;
>         }
> }
> 
> my $sql = "insert into Responses
> values(null,$form[0],$form[1],$form[2],$form[3],$form[4],".
> "$form[5],$form[6],$form[7],$form[8],$form[9],$form[10],$form[11],$form[12],$form[13],NOW());";
> 
> my $sth = $dbh->prepare($sql) || die "Can't prepare $sql:
> $dbh->errstr\n";
> 
> my $rv = $sth->execute || die "Can't execute $sql: $sth->errstr\n";
> 
> my $rc = $sth->finish;

IMO, better written as (with error checking removed, but I would have used
'eval' instead of a 'die');

  my $query = shift;
  my @form  = ();
  foreach ( $query->param() ) {
      push( @form, $_ );
  }

  my $sth = $dbh->prepare( 'INSERT INTO Responses
                            VALUES (null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())' );
  $sth->execute( @form );
  $sth->finish();

You should also be careful when using SQL queries as the one above; You
don't specify which columns to insert the data into.  What do you think
happen if you change the layout of the 'Responses' table (ie. add, remove
or rearrange the table's columns)?

Please read 'perldoc DBI'; there's a lot of information for you there!


-- 
Tore Aursand <tore@aursand.no>
"Out of missiles.  Out of bullets.  Down to harsh language." (Unknown)


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

Date: 06 May 2004 15:59:22 GMT
From: ctcgag@hotmail.com
Subject: Re: Strange DBI problem
Message-Id: <20040506115922.137$4B@newsreader.com>

vautour@unb.ca (Gil Vautour) wrote:
> "David K. Wall" <dwall@fastmail.fm> wrote in message
> >
> > Check the server logs and see what the error is. If you don't have
> > access to the server logs, put
> >
> >     use CGI::Carp qw(fatalsToBrowser);
> >
>
> Well I have been using Carp but it still only produces a 500 error.  I
> don't have direct access to the server logs, I had a sys admin take a
> look for me.  The only thing he could find was a mal-formed Header
> problem, but it seemed like this was caused by the script failing in
> general.

If you are using plain old Carp, that's the problem.  You need to use
CGI::Carp. If you are using CGI::Carp, which version?  Some versions had a
problem in that only dies within your script got redirected to CGI::Carp,
the die done by used modules would not.  I think CGI::Carp 1.24 had that
problem and 1.26 fixed it.  It doesn't look like you are using RaiseError
anyway, but I'd still check into it.

Also, add a "print $query->header()" as soon as it would be legal to do so,
just for debugging purposes.  (What the heck, print $query->Dump() too)


> Here is a snippet of the DBI code that I think is where the
> problem occurs:
>
> my $dbh = DBI->connect("DBI:mysql:$database:$hostname",$user,$password)||
> die "Connect failed: $dbh->errstr\n";
>
> my($query) = @_;
> my(@form,$values,$key);
>
> foreach $key ($query->param) {
>         if ($query->param($key) ne "") {
>             $values = $query->param($key);
>             $values = $dbh->quote($values);
>             push @form,$values;
>         } else {
>             $values = "null";
>             push @form,$values;
>         }
> }
>
> my $sql = "insert into Responses
> values(null,$form[0],$form[1],$form[2],$form[3],$form[4],".
> "$form[5],$form[6],$form[7],$form[8],$form[9],$form[10],$form[11],
> $form[12],$form[13],NOW());";

Dude, that is bloody aweful.  You should probably check to see what the
field names are, and you should definately use bind variables.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 6 May 2004 17:48:53 +0100
From: "Raj" <raj.kothary@thus.net>
Subject: Trapping warnings
Message-Id: <c7dqde$fbs$1$830fa7a5@news.demon.co.uk>

Hi,

I am using some code to talk to a third party server via an HTTPS GET.

The problem I have is that when the server is unavailable, the object method
thrown an error of the form:

"(Use of uninitialized value in split at
/opt/perl5/lib/site_perl/5.6.1/sun4-solaris-64int/eo.pm line 151.)"

I need to be able to suppress these warnings, but trap them so that I can
report them back via my code gracefully.

I know I can trap die using eval() but what can I do to deal with the above
warning?

Thanks in advance!

Regards,
Raj




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

Date: 6 May 2004 17:08:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Trapping warnings
Message-Id: <Xns94E1859DBAF50asu1cornelledu@132.236.56.8>

"Raj" <raj.kothary@thus.net> wrote in
news:c7dqde$fbs$1$830fa7a5@news.demon.co.uk: 

> Hi,
> 
> I am using some code to talk to a third party server via an HTTPS GET.
> 
> The problem I have is that when the server is unavailable, the object
> method thrown an error of the form:
> 
> "(Use of uninitialized value in split at
> /opt/perl5/lib/site_perl/5.6.1/sun4-solaris-64int/eo.pm line 151.)"
> 
> I need to be able to suppress these warnings, but trap them so that I
> can report them back via my code gracefully.
> 
> I know I can trap die using eval() but what can I do to deal with the
> above warning?

Well, how about not using split if there is nothing to split?

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


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

Date: Thu, 06 May 2004 17:33:49 GMT
From: GM <GM@foo.bar>
Subject: Re: Trapping warnings
Message-Id: <1Gumc.43088$I%1.2791545@attbi_s51>

A. Sinan Unur wrote:
> "Raj" <raj.kothary@thus.net> wrote in
> news:c7dqde$fbs$1$830fa7a5@news.demon.co.uk: 
> 
> 
>>Hi,
>>
>>I am using some code to talk to a third party server via an HTTPS GET.
>>
>>The problem I have is that when the server is unavailable, the object
>>method thrown an error of the form:
>>
>>"(Use of uninitialized value in split at
>>/opt/perl5/lib/site_perl/5.6.1/sun4-solaris-64int/eo.pm line 151.)"
>>
>>I need to be able to suppress these warnings, but trap them so that I
>>can report them back via my code gracefully.
>>
>>I know I can trap die using eval() but what can I do to deal with the
>>above warning?
> 
> 
> Well, how about not using split if there is nothing to split?
> 

Ditto!

You should be looking at what you get back from the server before trying 
to do anything with it.


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

Date: Thu, 06 May 2004 15:21:48 GMT
From: axel@white-eagle.co.uk
Subject: Re: Use of goto after an alarm?
Message-Id: <gKsmc.9112$4m5.6597@front-1.news.blueyonder.co.uk>

Toni Erdmann <for-spammers-only@web.de> wrote:
> The difference between your first posting and this one here is
> that "LAB1:" here is declared/used before sub xx {} is defined.

> Maybe this can explain the error?

I had thought of that... but that should have be taken care of at
compile time, which it is, just as a subroutine need not be declared in
advance of its being used. The same applies with goto's and labels... no
prior declarations are required... all my experiments have confirmed
that in normal usage no problem arises... except when I try to catch an
alarm signal... I know I must be missing something here, but would be
delighted to know what exactly :)

Axel




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

Date: 06 May 2004 16:17:40 GMT
From: ctcgag@hotmail.com
Subject: Re: Use of goto after an alarm?
Message-Id: <20040506121740.518$px@newsreader.com>

axel@white-eagle.co.uk wrote:
> Toni Erdmann <for-spammers-only@web.de> wrote:
> > The difference between your first posting and this one here is
> > that "LAB1:" here is declared/used before sub xx {} is defined.
>
> > Maybe this can explain the error?
>
> I had thought of that... but that should have be taken care of at
> compile time, which it is, just as a subroutine need not be declared in
> advance of its being used. The same applies with goto's and labels... no
> prior declarations are required... all my experiments have confirmed
> that in normal usage no problem arises... except when I try to catch an
> alarm signal... I know I must be missing something here, but would be
> delighted to know what exactly :)

You are missing the fact that signal handlers are weird.
(Sorry, that's the best description I can come up with.)

Apparently, the only way to break free of signal handler is to die out of
it; hopefully to be caught by eval, then after the eval you can check for
the die and goto whereever you want.  Not very intellectually satisifying,
I know, but sometimes life is messy.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 06 May 2004 16:48:43 GMT
From: axel@white-eagle.co.uk
Subject: Re: Use of goto after an alarm?
Message-Id: <L%tmc.12115$kn3.10741@pathologist.blueyonder.net>

ctcgag@hotmail.com wrote:
> Apparently, the only way to break free of signal handler is to die out of
> it; hopefully to be caught by eval, then after the eval you can check for
> the die and goto whereever you want.  Not very intellectually satisifying,
> I know, but sometimes life is messy.

True. The odd thing is that I can call another subroutine, use a
backticks expression to execute an 'ls' for example... do all sorts of
things... except use an internal perl 'goto'!

Axel





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

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


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