[22039] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4261 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 14 00:05:36 2002

Date: Fri, 13 Dec 2002 21:05:07 -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           Fri, 13 Dec 2002     Volume: 10 Number: 4261

Today's topics:
    Re: .NET, a necessary conflict? =?iso-8859-1?Q?=A9?= (P <mgjv@tradingpost.com.au>
    Re: another sorting question <dtweed@acm.org>
    Re: Building DBD::Chart prerequisite GDTextUtil-0.80 on <mgjv@tradingpost.com.au>
    Re: Delete series of bit sequences 1A1A from end of fil <Patrick_member@newsguy.com>
    Re: Delete series of bit sequences 1A1A from end of fil (Tad McClellan)
    Re: Delete series of bit sequences 1A1A from end of fil <Patrick_member@newsguy.com>
    Re: Delete series of bit sequences 1A1A from end of fil (Tad McClellan)
    Re: Eject CD with Perl <pkent77tea@yahoo.com.tea>
    Re: escape special chars before loading into MySQL (Malcolm Dew-Jones)
    Re: escape special chars before loading into MySQL <pkent77tea@yahoo.com.tea>
    Re: hash efficiency and key/value/array reading file <tassilo.parseval@post.rwth-aachen.de>
        Newbie - How do I get data from a webpage <res0up89@verizon.net>
    Re: Newbie - How do I get data from a webpage <noone@nowhere.com>
    Re: Newbie - How do I get data from a webpage (Tad McClellan)
    Re: Newbie - How do I get data from a webpage <jurgenex@hotmail.com>
    Re: Newbie - How do I get data from a webpage (Tad McClellan)
        Newbie question <invalid-email@melodyland.net>
    Re: Newbie question <uri@stemsystems.com>
    Re: Perl step-thru debugger in browser? (Mike)
    Re: Perl step-thru debugger in browser? (Tad McClellan)
        Perl timeout without killing script? (Matt Oefinger)
    Re: Perl timeout without killing script? <nospam@nospam.com>
    Re: Sending MIME attachment using Mail::Sender <ron@savage.net.au>
    Re: unix2dos newbie question <pkent77tea@yahoo.com.tea>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 14 Dec 2002 11:52:19 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: .NET, a necessary conflict? =?iso-8859-1?Q?=A9?= (Please read this!)
Message-Id: <slrnavl063.aid.mgjv@martien.heliotrope.home>

On Fri, 13 Dec 2002 21:06:33 GMT,
	Daniel Blood <dblood@2c-b.net> wrote:
> Yeah, but what are you going to use when M$ buys Borland?

Do not respond to blatantly offtopic messages with absolutely no Perl
content in clp.misc.

Do not put your reply before the text you reply to.

Do not quote large numbers of lines simply to add one comment.


Do read the message in news.anounce.newusers.

Do read the regularly posted guidelines for posting to this newsgroup.


Failing to do so might result in you ending up in the scrore- or
killfiles of many knowledgable people.


[SNIP of fully quoted large offtopic message]

Martien
-- 
                        | 
Martien Verbruggen      | The world is complex; sendmail.cf reflects
                        | this.
                        | 


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

Date: Fri, 13 Dec 2002 23:24:25 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: another sorting question
Message-Id: <3DFA6887.F55C4A38@acm.org>

Aaron wrote:
> I have the hardest time sorting stuff.

No wonder, if you never call the "sort" function :-)

> I have an array with this contents:
> 2002-12-12,ascend_rtr,CA1905R1,88.87,76783
> 2002-12-12,cabletron_sw,CA1022V1,99.65,86100
> 2002-12-12,ascend_rtr,CA1022R1,99.67,86113
> 2002-12-12,ascend_rtr,CA0313R1,100.00,86400
> 
> I want to sort this information by the uptime. If it's lower then 100%
> I want it at the top of the list... kinda like it is now (88.87).
> 
> I tried $value = (@data,split /,/)[4]; but that didn't work.

Direct approach, for small data sets:
   @data = sort {(split /,/,$a)[3] <=> (split /,/,$b)[3]} @data;

Schwartzian transform, for larger data sets:
   @data = map $_->[1],
      sort {$a->[0] <=> $b->[0]}
      map [(split /,/)[3], $_], @data;

-- Dave Tweed


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

Date: Sat, 14 Dec 2002 11:48:08 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Building DBD::Chart prerequisite GDTextUtil-0.80 on cygwin fails - perl 5.8.0 and very recent and complete cygwin
Message-Id: <slrnavkvu8.aid.mgjv@martien.heliotrope.home>

On 13 Dec 2002 05:44:01 -0800,
	M Buckle <markbuckle30@hotmail.com> wrote:
> Has anyone built DBD::Chart under cygwin successfully, if so can they
> post details of how they went about it.
> I get this error with the prerequisite GDTextUtil :-

And you do have a working copy of GD installed, right?

> bash-2.05b$ cd ../GDTextUtil-0.80
> bash-2.05b$ ls
> Changes
> MANIFEST
> Makefile.PL
> README
> Text
> Text.pm
> cetus.ttf
> demo
> t
> bash-2.05b$ perl Makefile.PL
> Checking if your kit is complete...
> Looks good
> C:\cygwin\bin\perl.exe: *** unable to remap C:\cygwin\bin\cygpng12.dll
> to same address as parent(0xB90000) != 0xC00000
>      22 [main] perl 263 sync_with_child: child 249(0xD8) died before
> initialization with status code 0x1
>   48450 [main] perl 263 sync_with_child: *** child state child loading
> dlls

Hmmm... That looks like something internal to cygwin. cygpng12.dll is
probably the PNG library, which is linked in by libgd, which is the
backend for GD, which is used by GD::Text.

The only advice I can give for this one is to see whether you can use
programs with the GD module. If that ends up with the same error
message, try a small C program with the libgd library. If that's still
the same, try a C program that uses the PNG library.

Whatever it is, it doesn't look at all that it has anything to do with
GD::Text or DBD::Chart, but more with a possibly broken cygwin install,
or perl, or cygwin png library.

But then, I don't know much about cygwin.

Martien
-- 
                        | 
Martien Verbruggen      | I used to have a Heisenbergmobile. Every time
                        | I looked at the speedometer, I got lost.
                        | 


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

Date: 13 Dec 2002 15:14:39 -0800
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: Re: Delete series of bit sequences 1A1A from end of file.
Message-Id: <atdpkv0j8v@drn.newsguy.com>

Thanx Michele,

  I tried this and get back the message:

  'Can't do inplace edit without backup'

(Nor do I find the file modified after running the command).

  pat



In article <039jvuko1jqmfgljnqlhdihrrpfs8h9odh@4ax.com>, Michele says...
>
>On 12 Dec 2002 21:46:04 -0800, Patrick Flaherty
><Patrick_member@newsguy.com> wrote:
>
>>Hi,
>>
>>As an artifact of the software that we use to span our old and new systems
>>(software = PATHworks old system = VMS new system = Windows), we get an artifact
>>at the end of VMS text files (at some point opened and then saved from Windows)
>>where there are word-aligned series of the sequence 1A1A at the end of the file
>>(my ASCII table tells me that 1A is SUB whatever that means).
>
>They're text files, so the following should work:
>
>perl -pi -e 's/\x1a//g' test.txt
>
>or, just to be sure,
>
>perl -p0777 -i -e 's/\x1a+$//g' test.txt
>
>caveat: I'm a beginner!!
>
>
>Michele
>-- 
>>It's because the universe was programmed in C++.
>No, no, it was programmed in Forth.  See Genesis 1:12:
>"And the earth brought Forth ..."
>- Robert Israel on sci.math, thread "Why numbers?"



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

Date: Fri, 13 Dec 2002 18:56:33 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Delete series of bit sequences 1A1A from end of file.
Message-Id: <slrnavl0e1.7l4.tadmc@magna.augustmail.com>


[ please don't top-post ]

Patrick Flaherty <Patrick_member@newsguy.com> wrote:
> In article <039jvuko1jqmfgljnqlhdihrrpfs8h9odh@4ax.com>, Michele says...

>>perl -p0777 -i -e 's/\x1a+$//g' test.txt

>>-- 
>>>It's because the universe was programmed in C++.
>>No, no, it was programmed in Forth.  See Genesis 1:12:
>>"And the earth brought Forth ..."
>>- Robert Israel on sci.math, thread "Why numbers?"


Please don't quote signatures either.


>   I tried this and get back the message:
> 
>   'Can't do inplace edit without backup'


Errr, then do it _with_ a backup:


    perl -p0777 -i.bu -e 's/\x1a+$//g' test.txt
                  ^^^

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


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

Date: 13 Dec 2002 18:04:02 -0800
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: Re: Delete series of bit sequences 1A1A from end of file.
Message-Id: <ate3ii01ufo@drn.newsguy.com>


  Thanx.  I think.

I 'top-posted' because after the several yrs I've used (extensively) Usenet,
this is the _first_ I've ever even heard of this.  And I'm still not _entirely_
sure what it is (it's probably of course self-describing, but anyway ...).  I
just use what Newsguy gives me by way of quoting what you're replying to.  And
this is certainly the first that I've ever hear these particular (or almost any)
objections.

  You're a consultant right?

And yes the addition to the code worked.  I went back and studied perl -v a
little more carefully and grokked what was going on.  (I believe I did say that
I hadn't turned my hand to Perl for some time ... not that that should be any
reason whatsoever for cutting someone the slightest amount of slack).

  pat



  



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

Date: Fri, 13 Dec 2002 22:45:40 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Delete series of bit sequences 1A1A from end of file.
Message-Id: <slrnavldrk.87o.tadmc@magna.augustmail.com>

Patrick Flaherty <Patrick_member@newsguy.com> wrote:

>   Thanx.  I think.

You're welcome, I think.

(If it was me you are referring to. You should have quoted some context)


> I 'top-posted' because after the several yrs I've used (extensively) Usenet,
> this is the _first_ I've ever even heard of this.  And I'm still not _entirely_
> sure what it is


   http://www.tuxedo.org/~esr/jargon/html/entry/top-post.html

   http://www.geocities.com/nnqweb/nquote.html

   http://mail.augustmail.com/~tadmc/clpmisc.shtml


>   You're a consultant right?


Yes. Why do you ask?


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


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

Date: Sat, 14 Dec 2002 01:14:23 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Eject CD with Perl
Message-Id: <pkent77tea-8E45CB.01142014122002@news-text.blueyonder.co.uk>

In article <411fc73f.0212122028.415def6a@posting.google.com>,
 miketaylorsf@yahoo.com (Mike) wrote:

> I need to create a perl script to eject a CD.  
> 
> Can anybody help with providing the code to do that?

from
http://search.cpan.org/author/CNANDOR/AudioCD-Mac-0.25/Mac.pm

    use AudioCD;
    use strict;
    my $cd = new AudioCD;
    $cd->eject;

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: 13 Dec 2002 15:44:46 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: escape special chars before loading into MySQL
Message-Id: <3dfa70ee@news.victoria.tc.ca>

user (du_bing@hotmail.com) wrote:
: Thanks,

: Malcolm Dew-Jones wrote:

: > user (du_bing@hotmail.com) wrote:
: > : Does Perl have any similar funtion to addslashes() that PHP does?
: > : What I want to do is to insert uploaded file into MySQL.
: >
: > : =========
: > : open(F,$upload_name) || die "can not open $uploaded for reading;
: > : read F,$content,$upload_size;
: > : close(F);
: >
: > : $mysql_dbh->do("INSERT INTO $table (content,filename,filesize) VALUES
: > : ('$content', '$upload_name','$upload_size')");
: > : ==========
: >
: > : My $content may have some special charactors, e.g single quote ('), that
: > : must be escaped before it can be accepted by MySQL.  Just wondering if
: > : there is any funtion that can escape _all_ the characters considered
: > : special by MySQL?
: >
: > : Thanks for any help,
: >
: > how about a function called "quote" which is documented in DBI
: >
: >         perldoc DBI

: Ah, thanks for the pointer.  I saw this in the manual:

: =========
: Quote will probably not be able to deal with all
:            possible input (such as binary data or data containing
:            newlines), and is not related in any way with escaping
:            or quoting shell meta-characters. There is no need to
:            quote values being used with the section on
:            /"Placeholders and Bind Values.
: =========

: So it does not fit out needs because uploaded files can be of any type.  I'm

You said you wanted something to escape special characters, and that is
what quote does.  If quote can't quote the string into a format acceptable
by a mysql insert statement then no other quote/char-escape method will do
that either, including the php addslashes method you initially mentioned
(though mysql is pretty liberal about what data can be inserted by
including it literally in an insert if correctly quoted). 

: thinking about using MIME::Base64.  

Well you can always (as you now mention) encode the data yourself if you
wish. That can always be done with any database.  On the other hand you
then have to decode the data every time you extract it, whereas if you
inserted the data itself (as opposed to an encoding of it) then you could
retrieve the data directly without decoding it later. 

: .. Anybody has any better suggestions?

How about re-reading the last sentence of the paragraph from the manual
that you referenced above. (hint: "bind")

You also have to define the correct column datatype to receive the data.


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

Date: Sat, 14 Dec 2002 01:15:54 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: escape special chars before loading into MySQL
Message-Id: <pkent77tea-065589.01155214122002@news-text.blueyonder.co.uk>

In article <3DFA63B5.A8BF5D71@hotmail.com>, user <du_bing@hotmail.com> 
wrote:

> Ah, thanks for the pointer.  I saw this in the manual:
> 
> =========
> Quote will probably not be able to deal with all
>            possible input (such as binary data or data containing
>            newlines), and is not related in any way with escaping
>            or quoting shell meta-characters. There is no need to
>            quote values being used with the section on
>            /"Placeholders and Bind Values.
> =========
> 
> So it does not fit out needs because uploaded files can be of any type.  I'm
> thinking about using MIME::Base64.  Anybody has any better suggestions?

use "Placeholders and Bind Values" like it says in that bit of the 
manual. That's what I always do.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: 13 Dec 2002 23:39:01 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: hash efficiency and key/value/array reading file
Message-Id: <atdr2l$qaq$1@nets3.rz.RWTH-Aachen.DE>

Also sprach qanda:

> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in message news:<atcclg$9d8$1@nets3.rz.RWTH-Aachen.DE>...

> Thanks, a small working sample like that really helps, with that in
> mind I've changed it slightly so only keys with values are saved: -
> 
> #!/usr/bin/perl -w
> use diagnostics -verbose;
> use warnings;
> use strict;
> 
> my %hash;
> while (<DATA>)
> {
> 	chomp;
> 	s/\s+|#.*$//g;
> 	# The hash works, but I don't fully understand.
> 	$hash{$1} = $2, next if /(\w+)=(\w+)/;
> }
> 
> # This does what I want but is it perlistic!
> foreach my $key (keys %hash )
> {
> 	print "$key:$hash{$key}\n";
> }

Your modified approach looks very ok to me (the 'next' in your code is
spurious, though). As for iterating over a hash, you can do it your way
or you use each() which might be even better if you are interested in
both the keys and the values:

    while (my ($key, $val) = each %hash) {
        print "$key:$val\n";
    }
    
> __DATA__
> # normal comment
>     # comment with spaces2
> 	# comment with tabs 
> key1 = value1
> key4  
> # random comment
> key5 = value5
> key2 = # comment on key line, no value
> key3       = value3  # comment on key/value line
> key7 = value7
> key6 = value6
> 
> Seeing DATA surprised me but know I now what it does I like it - LOTS!

It can be a real lifesaver for testing purpose as well as shipping data
along with your script.

> Thanks for the reply, you can see there are two places I'm still
> trying to get round my head (keep in mind I come from a C/UNIX
> background which may help to explain).  The script works OK but there
> are two more issues for me, both related to efficiency and perlisms.
> 
> Lets suppose I now have a file with 10 million key value pairs and I'm
> only interested in say for example 100 keys (lets say key1...key20,
> key21...key40, etc).  Should we use the above to load 10 million
> key/value pairs and then sort/search for the 100 we want or should we
> build a list of the 100 we are interested in and then only load those
> 100 (assuming they have a value) into the hash?

Definitely the second. This can easily be done by extending your
while-loop a little. Add a check whether $1 is within the list of
allowed keys. It might even be a good idea to store those keys you want
in another hash since the existance of a particular key can be checked
much more quickly than the existance of an element inside an array:

    my %allowed;
    @allowed{ qw/key1 key2 key3 .../ } = (); # we set them to undef
    while (<DATA>) {
        chomp;
        s/\s+|#.*$//g;
        if (/(\w+)=(\w+)/) {
            next if ! exists $allowed{ $1 };
            $hash{ $1 } = $2;
        }
    }
        
You might not be acquainted with this @var{ ... } thing. This is a
hash-slice. Slices in Perl are lists (which is why they are prepended
with the @) that you can assign data to. They work both for arrays and
hashes:

    # set the three first elements of @array to a, b, c
    @array[ 0, 1, 2 ] = qw/a b c/; 
    
    # set the keys key1, key2 and key3 of %hash accordingly
    @hash{ qw/key1 key2 key3/ } = qw/val1 val2 val3/;

The distinction between a hash and an array slice is done using the
respective subscript parens: [ ] for arrays and { } for hashes.

They are too useful to slip unmentioned. More to be found in
perldata.pod under "Slices".

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Sat, 14 Dec 2002 00:25:25 GMT
From: "res0up89" <res0up89@verizon.net>
Subject: Newbie - How do I get data from a webpage
Message-Id: <VTuK9.2863$4W1.2476@nwrddc02.gnilink.net>

I want to be able to get various data from a webpage to use in other
applications. Anyone have a script that will get me started in the right
direction.

Thanks

Dan




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

Date: Sat, 14 Dec 2002 00:26:20 GMT
From: "gibbering poster" <noone@nowhere.com>
Subject: Re: Newbie - How do I get data from a webpage
Message-Id: <MUuK9.252$VK.16863826@newssvr21.news.prodigy.com>


"res0up89" <res0up89@verizon.net> wrote in message
news:VTuK9.2863$4W1.2476@nwrddc02.gnilink.net...
> I want to be able to get various data from a webpage to use in other
> applications. Anyone have a script that will get me started in the right
> direction.
>


Try this:

Use LWP::Simple;

my $data = get ('www.perl.org');

print $data;





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

Date: Fri, 13 Dec 2002 18:59:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie - How do I get data from a webpage
Message-Id: <slrnavl0jv.7l4.tadmc@magna.augustmail.com>

res0up89 <res0up89@verizon.net> wrote:

> I want to be able to get various data from a webpage


   perldoc -q HTML

      "How do I fetch an HTML file?"


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


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

Date: Sat, 14 Dec 2002 01:43:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie - How do I get data from a webpage
Message-Id: <n1wK9.2161$_S2.295@nwrddc01.gnilink.net>

Tad McClellan wrote:
> res0up89 <res0up89@verizon.net> wrote:
>> I want to be able to get various data from a webpage
>
>    perldoc -q HTML
>       "How do I fetch an HTML file?"

Considering that the OP wanted data from a page (not just the page itself)
he probably should look into
    "How do I remove HTML from a string?"
too.
Otherwise the next question is likely to be "How to I extract my data from
an HTML page?"

jue




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

Date: Fri, 13 Dec 2002 22:04:27 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie - How do I get data from a webpage
Message-Id: <slrnavlbeb.837.tadmc@magna.augustmail.com>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> Tad McClellan wrote:
>> res0up89 <res0up89@verizon.net> wrote:
>>> I want to be able to get various data from a webpage
>>
>>    perldoc -q HTML
>>       "How do I fetch an HTML file?"
> 
> Considering that the OP wanted data from a page (not just the page itself)
> he probably should look into
>     "How do I remove HTML from a string?"
> too.


If he typed the perldoc query that I suggested, he'd see that too.  :-)


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


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

Date: Sat, 14 Dec 2002 12:30:36 +0800
From: "-SmC-" <invalid-email@melodyland.net>
Subject: Newbie question
Message-Id: <ateccd$7a3$1@nobel.pacific.net.sg>

If it possible to make the value .. lets say

1232  into   000001232 ?

I wanted to print out some data to the web but as it starts from 1 all the
way to 200
it becomes

1
10
100
200

which i hope it to be seens as

001
010
100
200
as as it might look neater..

please advice




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

Date: Sat, 14 Dec 2002 04:37:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Newbie question
Message-Id: <x71y4l5i7b.fsf@mail.sysarch.com>

>>>>> "-" == -SmC-  <invalid-email@melodyland.net> writes:

  -> If it possible to make the value .. lets say
  -> 1232  into   000001232 ?


  -> 001
  -> 010
  -> 100
  -> 200
  -> as as it might look neater..

perldoc -q pad

uri

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


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

Date: 13 Dec 2002 18:44:01 -0800
From: info@damigella.com (Mike)
Subject: Re: Perl step-thru debugger in browser?
Message-Id: <f5bdcb8b.0212131844.400d0a69@posting.google.com>

Thanks Tad.  Problem is that I use a virtual server web host and don't
have telnet priviledges.  Thus the question about a browser-based
debugger method.  I'd appreciate hearing about anything else I can
try.

Thanks.

-Mike

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnavefqg.5qv.tadmc@magna.augustmail.com>...
> Mike <info@damigella.com> wrote:
> 
> > Anybody know if there's a perl debugger I can use in my browser to
> > step-thru a script?
> 
> 
> That would be a really good trick, as CGI programs do not
> execute in a browser.
> 
> You can debug your CGI programs from the server's command line,
> or even from the command line on your home computer.
> 
> 
> You have no doubt already seen the CGI FAQ, right?
> 
>    "Troubleshooting a CGI application"
> 
>    http://www.webthing.com/tutorials/cgifaq.4.html


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

Date: Fri, 13 Dec 2002 22:01:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl step-thru debugger in browser?
Message-Id: <slrnavlb9k.837.tadmc@magna.augustmail.com>


[ please do not top-post ]


Mike <info@damigella.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnavefqg.5qv.tadmc@magna.augustmail.com>...

>> or even from the command line on your home computer.


> I'd appreciate hearing about anything else I can
> try.


Debug it from the command line on your home computer.

Or better yet, install a free web server on your home computer,
and debug it in a real CGI environment.

But it would still be best to get it working from the
command line first.


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


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

Date: 13 Dec 2002 16:41:45 -0800
From: oefinger@mit.edu (Matt Oefinger)
Subject: Perl timeout without killing script?
Message-Id: <e9b08c9f.0212131641.25a15a5e@posting.google.com>

I'm running a long loop of events, some of which are hanging. When an
event hangs it's NOT fatal, so I'm not happy with the default behavior
whereby Perl kills my script when the alarm event occurs. I'd instead
prefer that the alarm event just skips to the next foreach iteration.
Here's an example of my code...

foreach(@)
  {
  eval {
       alarm 5;
       # code that occasionally hangs alarm 0;};

       if ($@) {
       # timed out
               }
       else {
            # didn't
            }
  }

As I've written it above, the alarm event will cause my script to die.
How can I fix it so that the alarm event merely spits out a print
statement then allows the loop to continue.

Thanks in advance!


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

Date: Fri, 13 Dec 2002 17:54:54 -0800
From: "Tan D Nguyen" <nospam@nospam.com>
Subject: Re: Perl timeout without killing script?
Message-Id: <ate2tp$13617q$1@ID-161864.news.dfncis.de>


"Matt Oefinger" <oefinger@mit.edu> wrote in message
news:e9b08c9f.0212131641.25a15a5e@posting.google.com...
> I'm running a long loop of events, some of which are hanging. When an
> event hangs it's NOT fatal, so I'm not happy with the default behavior
> whereby Perl kills my script when the alarm event occurs. I'd instead
> prefer that the alarm event just skips to the next foreach iteration.
> Here's an example of my code...
>
> foreach(@)
>   {
>   eval {
>        alarm 5;
>        # code that occasionally hangs alarm 0;};
>
>        if ($@) {
>        # timed out
>                }
>        else {
>             # didn't
>             }
>   }
>
> As I've written it above, the alarm event will cause my script to die.
> How can I fix it so that the alarm event merely spits out a print
> statement then allows the loop to continue.
>
> Thanks in advance!

Put the if-else clause outside of eval.




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

Date: Sat, 14 Dec 2002 13:51:40 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Sending MIME attachment using Mail::Sender
Message-Id: <ate6dc$864$1@arachne.labyrinth.net.au>

> You seem to use SendLine() method where you should be using another
> method, probably Attach().
>
> > Thanks in Advance.
>
> If you are going to do something in advance, perhaps it should be to
> consult the manual.

Good point.

And a warning: Mail::Sender V 0.8.00 works on Perl 5.6.1 and fails on Perl
5.8.0.

Here's how I do it:

sub send_mail
{
 my($self, $to, $reply_to, $subject, $body, $file) = @_;

 my($mail);

 ref
 (
  $mail = Mail::Sender -> new
  ({
   from => $$self{'_mail_from'},
   replyto => $reply_to,
   to  => $to,
   cc  => '',
   bcc  => '',
   smtp => $$self{'_mail_server'},
  })
 ) || throw Error::Simple("Can't call Mail::Sender -> new(...)");

 if ($file)
 {
  (
   ref
   (
    $mail -> MailFile
    ({
     subject => $subject,
     msg  => join("\n", @$body),
     file => $file,
    })
   )
  ) || throw Error::Simple($Mail::Sender::Error);
 }
 else
 {
  (
   ref
   (
    $mail -> MailMsg
    ({
     subject => $subject,
     msg  => join("\n", @$body),
    })
   )
  ) || throw Error::Simple($Mail::Sender::Error);
 }

} # End of send_mail.






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

Date: Sat, 14 Dec 2002 01:22:19 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: unix2dos newbie question
Message-Id: <pkent77tea-FDDA12.01221714122002@news-text.blueyonder.co.uk>

In article <slrnavi713.48l.tadmc@magna.augustmail.com>,
 tadmc@augustmail.com (Tad McClellan) wrote:

> Edward Quick <vervoom@hotmail.com> wrote:
> > I need to perform a unix2dos function on $ftpbuf,
> > but I'm not too sure how to do this in Perl.
> 
> If your Perl program is running on Unix:
> 
>    $ftpbuf =~ s/\n/\r\n/g;

And as we know what code points are used for the line ending sequences 
on DOS and Unix, what's wrong with:

$ftpbuf =~ s/\x0A/\x0D\x0A/g;
# I really hope those are the right way round.

and that will work on any OS, converting Unix line endings to DOS line 
endings. Problem is that it _assumes_ your input really does have Unix 
line endings but maybe that's covered elsewhere in the thread.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

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


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