[18551] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 719 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 09:46:29 2001

Date: Thu, 19 Apr 2001 06:46:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987687974-v10-i719@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 19 Apr 2001     Volume: 10 Number: 719

Today's topics:
    Re: using Unicode::String -- ordinals <flavell@mail.cern.ch>
        View Source Code/ Display Images & URL Mike_from_Conn@webtv.net
    Re: View Source Code/ Display Images & URL Mike_from_Conn@webtv.net
    Re: View Source Code/ Display Images & URL Mike_from_Conn@webtv.net
    Re: View Source Code/ Display Images & URL (Eric Bohlman)
    Re: What is taking so long? (Profiling) <comdog@panix.com>
    Re: What is taking so long? (Profiling) (Chris Fedde)
    Re: What is taking so long? (Profiling) <comdog@panix.com>
        Why does Perl stringify this number? <newspost@coppit.org>
    Re: Why does Perl stringify this number? <newspost@coppit.org>
    Re: Why does Perl stringify this number? <bart.lateur@skynet.be>
    Re: Why does Perl stringify this number? <bart.lateur@skynet.be>
    Re: Why would printing to FILEHANDLE wipe out contents  <joe+usenet@sunstarsys.com>
        WIMP programming on Linux <bernie@fantasyfarm.com>
    Re: WIMP programming on Linux <ocschwar@mit.edu>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Apr 2001 14:17:44 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: using Unicode::String -- ordinals
Message-Id: <Pine.LNX.4.30.0104191403530.12952-100000@lxplus003.cern.ch>

On Wed, 18 Apr 2001, B McDonald wrote:

(in an attempt to represent utf-8 in an 8-bit posting)

|    <name>Edén</name>
|
| and
|
|    <address1>6ª Calle entre 3ª y 4ª Avenidas, Zona 1</address1>


> These should be, respectively
>
>     Edén

OK

> and
>
>     6^o Calle entre 3^o y 4^o Avenidas, Zona 1

I understand that you're attempting to represent masculine ordinals in
your posting.  Apparently you are mistaken: the original contains
feminine ordinals.

> This correctly transliterated most of the characters; however, the ordinals
> got turned into these:
>
>     6ª Calle entre 3ª y 4ª Avenidas, Zona 1

Feminine ordinals, as in the original.

> Does anyone know how I can properly convert these ordinal characters as well
> as the other Latin-1 chars?

It seems you already did.

cheers



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

Date: Tue, 17 Apr 2001 14:04:05 -0400 (EDT)
From: Mike_from_Conn@webtv.net
Subject: View Source Code/ Display Images & URL
Message-Id: <20907-3ADC8595-36@storefull-102.iap.bryant.webtv.net>



If someone could help point me in the right direction, I will be forever
grateful

I need code that will display images from a web site along with its URL.

I am trying to help fellow webtvers who do not have the view-source
option, and have limited understanding of relative URLs.

Thank you very much!

Mike 



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

Date: Tue, 17 Apr 2001 16:03:08 -0400 (EDT)
From: Mike_from_Conn@webtv.net
Subject: Re: View Source Code/ Display Images & URL
Message-Id: <18751-3ADCA17C-37@storefull-105.iap.bryant.webtv.net>

Steve writes:
>"Try and put something together yourself, and
> once you've got something and if you're
> having real problms getting it to work then post the relevant source
code here and tell us what the particular problem is and you're sure to
get some useful help.



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

Date: Tue, 17 Apr 2001 16:14:02 -0400 (EDT)
From: Mike_from_Conn@webtv.net
Subject: Re: View Source Code/ Display Images & URL
Message-Id: <18755-3ADCA40A-1@storefull-105.iap.bryant.webtv.net>

Steve writes:
>"Try and put something together yourself, and
> once you've got something and if you're
> having real problms getting it to work then
> post the relevant source code here and tell us
> what the particular problem is and you're sure
> to get some useful help."

Hi Steve. Thanks for the vote of confidence. The only skills I have are
cut and paste and grovelling.

I was hoping someone would take pity on the 1 million webtv users that
do not have view-source capabilities.

I've been going through free script sites looking for something I might
be able to get help in modifying. 

Most "view source" will display all of the HTML code. We need a "view
source" that will display only the image URLs. It would be way cool if
they displayed the image along with its URL.

Mike



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

Date: 18 Apr 2001 00:28:20 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: View Source Code/ Display Images & URL
Message-Id: <9bin34$p13$2@bob.news.rcn.net>

Mike_from_Conn@webtv.net wrote:
> Most "view source" will display all of the HTML code. We need a "view
> source" that will display only the image URLs. It would be way cool if
> they displayed the image along with its URL.

Do I understand correctly that you want to create a CGI program that, 
given a URL corresponding to a Web page, will generate a listing of the 
URLs of all images on that page, preferably showing the images adjacent to 
the URLs?

If so, you'll want to look into three Perl modules that just need to be 
"glued" together to do the job:

1) CGI.pm, to handle the communications between the script and the server 
it's running on.

2) LWP::Simple (or maybe LWP::UserAgent) to fetch the page in question.

3) HTML::LinkExtor, to parse the page for image URLs.

There are some complications; for example, if the URL given is to a framed 
page, what you'll get back is a frameset document which you'll have to 
parse to get the URLs of the individual frame contents which you'll then 
have to retrieve.  You'll need to become reasonably familiar with HTTP to 
understand what you'll need to do.  But it should be doable.



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

Date: Tue, 17 Apr 2001 10:46:04 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: What is taking so long? (Profiling)
Message-Id: <comdog-70E8A2.10460417042001@news.panix.com>

In article <3ADC50A8.F2CA273F@merck.com>, david_kershaw@merck.com 
wrote:

> I tried to profile my perl script to find out what routines are doing
> the most work. My script will be forced to parse over 4 million records
> from a text file; so speed and efficiency matter a lot. I ran on 10,000
> records and it took 146 secs. But my problem is when I ran dprofpp on
> the output here is what I got:

> Total Elapsed Time = 146.5911 Seconds
>   User+System Time = 6.181192 Seconds

remember that DProf runs a bunch of code for every executed
statement that you are profiling.  that can add a lot of overhead.
how long does it take the script to run when you are not profiling?

-- 
brian d foy <comdog@panix.com>



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

Date: Tue, 17 Apr 2001 17:10:33 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: What is taking so long? (Profiling)
Message-Id: <dO_C6.1187$T3.195746816@news.frii.net>

In article <comdog-70E8A2.10460417042001@news.panix.com>,
brian d foy  <comdog@panix.com> wrote:
>In article <3ADC50A8.F2CA273F@merck.com>, david_kershaw@merck.com 
>wrote:
>
>> I tried to profile my perl script to find out what routines are doing
>> the most work. My script will be forced to parse over 4 million records
>> from a text file; so speed and efficiency matter a lot. I ran on 10,000
>> records and it took 146 secs. But my problem is when I ran dprofpp on
>> the output here is what I got:
>
>> Total Elapsed Time = 146.5911 Seconds
>>   User+System Time = 6.181192 Seconds
>
>remember that DProf runs a bunch of code for every executed
>statement that you are profiling.  that can add a lot of overhead.
>how long does it take the script to run when you are not profiling?
>
>

I've not seen a problem like this one though. I've seen profiling add say
2x to execution time but not the kind of delay that david_kershaw is
reporting.   It looks like his code might be blocking somewhere that Dprof
does not count.

He might want to run the same test using SmallProf.



-- 
    This space intentionally left blank


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

Date: Tue, 17 Apr 2001 18:29:43 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: What is taking so long? (Profiling)
Message-Id: <comdog-9AFE38.18294317042001@news.panix.com>

In article <dO_C6.1187$T3.195746816@news.frii.net>, 
cfedde@fedde.littleton.co.us (Chris Fedde) wrote:

> In article <comdog-70E8A2.10460417042001@news.panix.com>,
> brian d foy  <comdog@panix.com> wrote:

> >In article <3ADC50A8.F2CA273F@merck.com>, david_kershaw@merck.com 
> >wrote:

> >> Total Elapsed Time = 146.5911 Seconds
> >>   User+System Time = 6.181192 Seconds

> >remember that DProf runs a bunch of code for every executed
> >statement that you are profiling.  that can add a lot of overhead.
> >how long does it take the script to run when you are not profiling?

> I've not seen a problem like this one though. I've seen profiling add say
> 2x to execution time but not the kind of delay that david_kershaw is
> reporting. 

i've noticed very large differences when profiling code that was
mostly simple statements (i.e. just perl builtins) executed many 
(10^6 or more) times.  that way the DB stuff is also executed
many, many times.

i wasn't keeping good notes on that though because i didn't 
need it to happen very quickly. ;)

-- 
brian d foy <comdog@panix.com>



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

Date: Tue, 17 Apr 2001 11:10:12 -0400
From: David Coppit <newspost@coppit.org>
Subject: Why does Perl stringify this number?
Message-Id: <Pine.SUN.4.33.0104171106080.20220-100000@mamba.cs.Virginia.EDU>

Hi all,

I'm using Storable (with canonical=1) to compare data structures.
However, I'm running into a problem in which Perl is stringifying a
number, causing my data structures not to match. Here's sample code:

--------
$h->{foo} = 1;
$i->{bar} = 4 - $h->{foo};

use Data::Dumper;
print Dumper $i;
--------

I'd expect the output to be this:

$VAR1 = {
          'bar' => 3
        };

but I'm getting this:

$VAR1 = {
          'bar' => '3'
        };

I can wrap the computation in an int(), but I would think that this
would be unnecessary...

I'm on Perl 5.6.0, built for Linux.
--
David



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

Date: Tue, 17 Apr 2001 12:33:04 -0400
From: David Coppit <newspost@coppit.org>
To: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why does Perl stringify this number?
Message-Id: <Pine.SUN.4.33.0104171221430.20220-100000@mamba.cs.Virginia.EDU>

[posted & mailed]

On Tue, 17 Apr 2001, Bart Lateur wrote:

> Data::Dumper always does that.

I'm not sure what you mean. Data::Dumper does *not* stringify all numbers.
For example,

  $i->{bar} = 4 - 1;

  use Data::Dumper;
  print Dumper $i;

doesn't result in a stringified $i->{bar}.

It seems to me that Perl is stringifying "4 - $h->{foo}" before
Data::Dumper sees it. I would think that Perl would evaluate $h->{foo}
as a number, then evaluate 4-1 as a number, and store a number into
$i->{bar}.

> And I don't see you using Storable anywhere.

It's not relevant for the sample code I posted, except to say that
Storable::freeze generates different results depending on whether a
number is stringified or not.

David



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

Date: Tue, 17 Apr 2001 15:42:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why does Perl stringify this number?
Message-Id: <i4podt4qm4csgj82mbec62sm01q22s131n@4ax.com>

David Coppit wrote:

>I'm using Storable (with canonical=1) to compare data structures.
>However, I'm running into a problem in which Perl is stringifying a
>number, causing my data structures not to match. Here's sample code:

>$h->{foo} = 1;
>$i->{bar} = 4 - $h->{foo};
>
>use Data::Dumper;
>print Dumper $i;
>--------
>
>I'd expect the output to be this:
>
>$VAR1 = {
>          'bar' => 3
>        };
>
>but I'm getting this:
>
>$VAR1 = {
>          'bar' => '3'
>        };

Data::Dumper always does that.

And I don't see you using Storable anywhere.

-- 
	Bart.


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

Date: Tue, 17 Apr 2001 22:21:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why does Perl stringify this number?
Message-Id: <tdgpdtojvr3vga4u41bj71eludji8ncg7g@4ax.com>

David Coppit wrote:

>> Data::Dumper always does that.
>
>I'm not sure what you mean. Data::Dumper does *not* stringify all numbers.

Eh, no. Apparently not. But I'm used to seeing it already. It's far from
uncommon.

-- 
	Bart.


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

Date: 15 Apr 2001 16:25:14 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Why would printing to FILEHANDLE wipe out contents of that file?
Message-Id: <m3lmp129n9.fsf@mumonkan.sunstarsys.com>

"Arvin Portlock" <temp133@hotmail.com> writes:

> What sorts of things could cause this persistent problem? What
> kinds of diagnostics can I try to pinpoint the problem?

Unless you are running this program concurrently with another program
that is trying to access these files, I really don't know.  You could
try putting in some locking mechanism like flock (which has been
discussed extensively in the recent clp.misc archives), but since
you've asked for diagnostic tips I'll recommend some changes to your
script might help you determine what's going wrong.

> Roughly here is what's happening:
> 
> foreach $log (keys %logs) {   # thus files are guaranteed unique
>    open (LOG, ">$log") || die;

    open LOG, "> $log" or die "open failed for '$log': $!";

>    print LOG $header || die;

Why do you care whether or not $header is a false value?  Just use

    print LOG $header;
    
>    my $line;
>    foreach $error (@{$errors{$log}}) {
>       $line .= "$error\n";
>    }
>    # Breakpoint here confirms log has $header information
>    print LOG $line || die;

    print LOG $line;

>    # Breakpoint here confirms file is now EMPTY!
>    print LOG $footer || die;

    print LOG $footer;

>    # Breakpoint here confirms file contains only the $footer
>    close (LOG);

    close LOG or die <<ERROR;
error closing '$log': $!
\$header was '$header'
\$line   was '$line'
\$footer was '$footer'
ERROR

> }

If there was an error writing to LOG, it should be reported to the
close call.

HTH
-- 
Joe Schaefer                 "Language is the dress of thought."
                                               -- Samuel Johnson


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

Date: Mon, 16 Apr 2001 20:36:57 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: WIMP programming on Linux
Message-Id: <jmsmdtc20lihov0tutblcfvm0jh6s615q5@nntp.usit.net>

I'm about to take the plunge: after decades of being a staunch "command
line" Unix user, I'm going to be running Linux with X [probably with
GNOME].  That has got me to thinking it'd be neat to write some real WIMP
apps with Perl [I've done this on my Windows box in the past using
VisBasic].  But I know close to nothing about all this, and I apologize for
this inquiry seeming a bit dumb, but I'm at a bit of a loss --- is there a
faq/howto/tutorial/??? on doing this sort of stuff with Perl?

I see on CPAN [and in faq3] a 'tk' module, and I vaguely remembe "TCL/tk"
from about 15 years ago, and so I guess that module would suffice, but I
also see a "Gnome" module, an X11 module and a lot of choices...    Any
advice/roadmap/overview on all these?  Would I do OK just to pick up the tk
module and forget about the rest?

I'm facile with CGI/JavaScript and VisBasic and so I understand generally
how to organize/write WIMP-style programs and how that kind of thing works,
I'm just stuck on how to get started doing all that kind of thing with Perl
directly to X [rather than via CGI]...

Thanks!!
  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: 17 Apr 2001 03:09:45 -0400
From: Omri Schwarz <ocschwar@mit.edu>
Subject: Re: WIMP programming on Linux
Message-Id: <octwv8kuhmu.fsf@nerd-xing.mit.edu>

Bernie Cosell <bernie@fantasyfarm.com> writes:

> I'm about to take the plunge: after decades of being a staunch "command
> line" Unix user, I'm going to be running Linux with X [probably with
> GNOME].  That has got me to thinking it'd be neat to write some real WIMP
> apps with Perl [I've done this on my Windows box in the past using
> VisBasic].  But I know close to nothing about all this, and I apologize for
> this inquiry seeming a bit dumb, but I'm at a bit of a loss --- is there a
> faq/howto/tutorial/??? on doing this sort of stuff with Perl?
> 
> I see on CPAN [and in faq3] a 'tk' module, and I vaguely remembe "TCL/tk"

Same widgets without the Tcl.

Lovely stuff.

> from about 15 years ago, and so I guess that module would suffice, but I
> also see a "Gnome" module, an X11 module and a lot of choices...    Any
> advice/roadmap/overview on all these?  Would I do OK just to pick up the tk
> module and forget about the rest?

Yes, unless you're going for really fancy 
WIMPage, and if you're a stalwart CLI man,
I doubt that.

-- 
Omri Schwarz --- 
Timeless wisdom of biomedical engineering:
"Noise is principally due to the presence of the 
patient." -- R.F. Farr


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

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


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