[29848] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1091 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 5 11:09:48 2007

Date: Wed, 5 Dec 2007 08:09:09 -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, 5 Dec 2007     Volume: 11 Number: 1091

Today's topics:
        Better way to invoke dynamic function? <howachen@gmail.com>
    Re: Better way to invoke dynamic function? <joost@zeekat.nl>
    Re: Better way to invoke dynamic function? <howachen@gmail.com>
    Re: Better way to invoke dynamic function? <glennj@ncf.ca>
        Gtk2::SimpleList question? <robertospara@gmail.com>
        how check new URL of redirected page zawszedamian_p@gazeta.pl
    Re: how check new URL of redirected page <ben@morrow.me.uk>
    Re: How to make thumbnail image from web page? <bugbear@trim_papermule.co.uk_trim>
    Re: How to make thumbnail image from web page? <marthan@csv.t-portal.cc>
    Re: OT raibow <1usa@llenroc.ude.invalid>
        reuse code inquiry <a@a.com>
    Re: reuse code inquiry <joost@zeekat.nl>
    Re: reuse code inquiry <ben@morrow.me.uk>
    Re: reuse code inquiry <bik.mido@tiscalinet.it>
    Re: Tk Compilation on Solaris 10 Failing <muralikrishnan.s@gmail.com>
    Re: Tk Compilation on Solaris 10 Failing <muralikrishnan.s@gmail.com>
        variable number of arguments to bind_columns <alexxx.magni@gmail.com>
    Re: variable number of arguments to bind_columns <alexxx.magni@gmail.com>
    Re: variable number of arguments to bind_columns <glennj@ncf.ca>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 5 Dec 2007 06:34:42 -0800 (PST)
From: howa <howachen@gmail.com>
Subject: Better way to invoke dynamic function?
Message-Id: <8dc5615e-5042-4c42-a8c0-9cff61fea78d@d27g2000prf.googlegroups.com>

I have some codes which I want to dynamically select the algorithm at
runtime, currently can be done via using  eval(), e.g.
#######################
package P1;

sub foo {
	print "foo";
}

sub bar {
	print "bar";
}

1;

$function_to_call = "P1.bar";

eval( $function_to_call );

exit;
#######################

But the drawback is eval() is sloooow..., e.g.

##############
cmpthese( 1_000_000, {

  'foo' => sub{ foo(); },
  'bar' => sub{ eval("foo()"); }

});
##############

result:

bar   19967/s    --  -98%
foo 1315789/s 6490%    --


as you can see, using eval() is slower a lot, not to mention the
actual function execution time.

Are there any better method to archive runtime algorithm selection?

thanks.


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

Date: 05 Dec 2007 14:59:44 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Better way to invoke dynamic function?
Message-Id: <4756bce0$0$20398$e4fe514c@dreader32.news.xs4all.nl>

On Wed, 05 Dec 2007 06:34:42 -0800, howa wrote:

> I have some codes which I want to dynamically select the algorithm at
> runtime, currently can be done via using  eval(), e.g.
> #######################
> package P1;
> 
> sub foo {
> 	print "foo";
> }
> 
> sub bar {
> 	print "bar";
> }
> 
> 1;
> 
> $function_to_call = "P1.bar";
> 
> eval( $function_to_call );

Use a function reference:

$function_to_call = \&PI::bar;

$function_to_call->();

Joost.


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

Date: Wed, 5 Dec 2007 07:53:41 -0800 (PST)
From: howa <howachen@gmail.com>
Subject: Re: Better way to invoke dynamic function?
Message-Id: <73f472e7-b275-4d52-a93a-89dfb1bf44a6@d4g2000prg.googlegroups.com>

On 12$B7n(B5$BF|(B, $B2<8a(B10$B;~(B59$BJ,(B, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> On Wed, 05 Dec 2007 06:34:42 -0800, howa wrote:
> > I have some codes which I want to dynamically select the algorithm at
> > runtime, currently can be done via using  eval(), e.g.
> > #######################
> > package P1;
>
> > sub foo {
> >    print "foo";
> > }
>
> > sub bar {
> >    print "bar";
> > }
>
> > 1;
>
> > $function_to_call = "P1.bar";
>
> > eval( $function_to_call );
>
> Use a function reference:
>
> $function_to_call = \&PI::bar;
>
> $function_to_call->();
>
> Joost.


The function name is unknown at runtime, it is input by user.


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

Date: 5 Dec 2007 16:06:25 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Better way to invoke dynamic function?
Message-Id: <slrnfldj41.qp6.glennj@smeagol.ncf.ca>

At 2007-12-05 10:53AM, "howa" wrote:
>  On 12$B7n(B5$BF|(B, $B2<8a(B10$B;~(B59$BJ,(B, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> > On Wed, 05 Dec 2007 06:34:42 -0800, howa wrote:
> > > I have some codes which I want to dynamically select the algorithm at
> > > runtime, currently can be done via using  eval(), e.g.
[...]
> > Use a function reference:
> >
> > $function_to_call = \&PI::bar;
> >
> > $function_to_call->();
>  
>  The function name is unknown at runtime, it is input by user.

Presumably the user's input is validated against some number of existing
subroutines ... you want a dispatch table.  See
    http://www.perlmonks.org/?node_id=456530

e.g.
    my %subroutine_refs = (
        choice1 => \&PI::bar,
        choice2 => \&ALPHA::beta,
    );
    my $invalid_choice = sub { die "invalid choice"; }
    ( $subroutine_refs{$user_choice} or $invalid_choice )->();

-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

Date: Wed, 5 Dec 2007 03:16:11 -0800 (PST)
From: robertospara <robertospara@gmail.com>
Subject: Gtk2::SimpleList question?
Message-Id: <c5d22bdd-51be-4921-ac10-75ec1dbf4a37@w40g2000hsb.googlegroups.com>

Hi.I found problem in Gtk2::Perl with module Gtk2::SimpleList.
I want to have selection bar in different colors.Not only orange but
red blue and others. Sample code produce SimpleList and with moving up
and down keys
I move with this "orange bar" which I  call "select-bar" up and down.
How to change this color?Please for help or any advices.
Best regards and thanks in advance.

#!/usr/bin/perl -w

use Data::Dumper;
use Gtk2 '-init';
use Gtk2::SimpleList;

$window = Gtk2::Window->new;
$window->set_title ('SimpleList examples');
$window->signal_connect (delete_event => sub {Gtk2->main_quit; TRUE});

$hbox = Gtk2::HBox->new;
$window->add ($hbox);

$categories = Gtk2::SimpleList->new ('Categories' => 'text');
@{$categories->{data}} = qw/Meat Beer Pizza Pasta Soda Juice
Rabbitfood/;
$hbox->pack_start ($categories, FALSE, FALSE, 0);
$window->show_all;

Gtk2->main;


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

Date: Wed, 5 Dec 2007 06:39:46 -0800 (PST)
From: zawszedamian_p@gazeta.pl
Subject: how check new URL of redirected page
Message-Id: <4c72f65b-95fa-4b15-b20f-9b99f5bd6822@x69g2000hsx.googlegroups.com>


I read webpage using HTTP::Response but the page was redirected - how
can I read new url?
I tried HTTP::Response->base() but it returns orginal url.

Thanks


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

Date: Wed, 5 Dec 2007 15:26:22 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: how check new URL of redirected page
Message-Id: <uhsi25-8de.ln1@osiris.mauzo.dyndns.org>


Quoth zawszedamian_p@gazeta.pl:
> 
> I read webpage using HTTP::Response but the page was redirected - how
> can I read new url?
> I tried HTTP::Response->base() but it returns orginal url.

If you mean a proper HTTP redirect rather than an HTML meta-refresh or
something more evil in JavaScript,

    $response->header('Location');

However, LWP::UserAgent will follow redirects by default, so unless
you've turned it off this won't help :(. If the page is HTML with a
meta-refresh, you will need to parse it with e.g. HTML::Parser and
extract the <meta> elements, and find the one with the refresh in. If
it's using JS, you're out of luck, unless the pages you are working with
have similar pieces of JS every time and you can see how to extract the
URL.

Ben



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

Date: Wed, 05 Dec 2007 09:39:57 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: How to make thumbnail image from web page?
Message-Id: <13lcsfe1f594ga6@corp.supernews.com>

Trenk wrote:
> How to make thumbnail image from web page?
> Some thing like networksolutions.com do.
> eg. http://www.networksolutions.com/whois/results.jsp?domain=perl.com
> 
> Tnx.
> 
> 

Render, then subsample.

   BugBear


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

Date: Wed, 5 Dec 2007 10:51:31 +0100
From: "Marthan" <marthan@csv.t-portal.cc>
Subject: Re: How to make thumbnail image from web page?
Message-Id: <fj5sar$j57$1@ss408.t-com.hr>

Use PHP :)


"Trenk" <Karon@trenk.hrt> wrote in message
news:fj5m11$t5$1@ss408.t-com.hr...
> How to make thumbnail image from web page?
> Some thing like networksolutions.com do.
> eg. http://www.networksolutions.com/whois/results.jsp?domain=perl.com
>
> Tnx.
>
>




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

Date: Wed, 05 Dec 2007 13:54:35 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: OT raibow
Message-Id: <Xns99FD5A9F519D2asu1cornelledu@127.0.0.1>

"Petr Vileta" <stoupa@practisoft.cz> wrote in
news:fj57a0$f6i$2@ns.felk.cvut.cz: 

> Lars Haugseth wrote:
>>>> You don't see me asking for restaurant recommendations here, do
>>>> you? 
>>>
>>> No, thanks ;-) I not need to know good restaurants, but many people
>>> here use Perl for webs and trafic in groups about html or www is 1
>>> message per month :-(
>>
>> The cause of that particular traffic problem is that people post
>> their www and html related questions in groups dedicated to Perl
>> programming.
> 
> You are not right. Many times I sent something to www newsgroup but I
> was be a single man there :-)

I am not sure what the smiley means in this case. 

comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.stylesheets
comp.infosystems.www.authoring.site-design

are all active groups where I lurk.

I know that 

comp.infosystems.www.authoring.cgi

has been practically defunct for a while now.

In any case, even if all those groups were gone, that still would not 
justify posting off-topic messages on clpmisc.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Wed, 5 Dec 2007 22:34:39 +0800
From: "a" <a@a.com>
Subject: reuse code inquiry
Message-Id: <fj6cq6$knn$1@justice.itsc.cuhk.edu.hk>

Dear all, I am a perl beginner and I am suggested to parse HTML by using 
other codes but not re-inventing the wheel.

The following code is from Internet Search but what i find is a lot of 
subroutines. When I fed it with an HTM file, nothing is generated or printed 
out. Would anybody tell me where all the TD elements it store?

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

# HTML parser
# Jim Davis, July 15 1994

# This is an HTML parser not an SGML parser.  It does not parse a DTD,
# The DTD is implicit in the code, and specific to HTML.
# The processing of the HTML can be customized by the user by
#   1) Defining routines to be called for various tags (see Begin and End 
arrays)
#   2) Defining routines html_content and html_whitespace

# This is not a validating parser.   It does not check the content model
# eg you can use DT outside a DL and it won't know.  It is too liberal in
# what tags are allowed to minimize what other tags.

# Bugs - can't parse the prolog or whatever you call it
#   <!DOCTYPE HTML [
#     <!entity % HTML.Minimal "INCLUDE">
#     <!-- Include standard HTML DTD -->
#     <!ENTITY % html PUBLIC "-//connolly hal.com//DTD WWW HTML 1.8//EN">
#     %html;
#     ]>

# modified 3 Aug to add a bunch of HTML 2.0 tags
# modified 3 Sept to print HTML stack to STDERR not STDOUT, to add new
#  routines html_begin_doc and html_end_doc for application specific cleanup
#  and to break parse_html into two pieces.
# modified 30 Sept 94.  parse_attributes now handles tag attributes that
#   don't have values.  thanks to  Bill Simpson-Young 
<bill@syd.dit.csiro.au>
#   for the code.
# modified 17 Apr 95 to support FORMS tags.
# modified 8 Dec 95 by Daniel LaLiberte to centralize STDERR output
#   so it may be switched off more easily.

$debug = 0;

$whitespace_significant = 0;

# global variables:
#  $line_buffer is line buffer
#  $line_count is input line number.

$line_buffer = "";
$line_count = 0;

sub printErr {
    # All errors should be printed through here, so they may be turned off.
    print STDERR @_ if $debug;
}


sub parse_html {
    local ($file) = @_;
    open (HTML, $file) || die "Could not open $file: $!\nStopped";
    &parse_html_stream ();
    close (HTML);}

# Global input HTML is the handle to the stream of HTML
sub parse_html_stream {
    local ($token, $new);

    ## initialization
    @stack=();
    $line_count = 0;
    $line_buffer = "";

    ## application specific initialization
    &html_begin_doc();
  main:
    while (1) {

 # if whitespace does not matter, trim any leading space.
 if (! $whitespace_significant) {
     $line_buffer =~ s/^\s+//;}

 # now dispatch on the type of token

 if ($line_buffer =~ /^(\s+)/) {
     $token = $1;
     $line_buffer = $';
     &html_whitespace ($token);}

 # This will lose if there is more than one comment on the line!
 elsif ($line_buffer =~ /^(\<!--.*-->)/) {
     $token = $1;
     $line_buffer = $';
     &html_comment ($token);}

 elsif ($line_buffer =~ /^(\<![^-][^\>]*\>)/) {
     $token = $1;
     $line_buffer = $';
     &html_comment ($token);}

 elsif ($line_buffer =~ /^(\<\/[^\>]*\>)/) {
     $token = $1;
     $line_buffer = $';
     &html_etag ($token);}

 elsif ($line_buffer =~ /^(\<[^!\/][^\>]*\>)/) {
     $token = $1;
     $line_buffer = $';
     &html_tag ($token);}

 elsif ($line_buffer =~ /^([^\s<]+)/) {
     $token = $1;
     $line_buffer = $';
     $token = &substitute_entities($token); # not enough anyway.
     &html_content ($token); }

 else {
     # No valid token in buffer.  Maybe it's empty, or maybe there's an
     # incomplete tag.  So get some more data.
     $new = <HTML>;
     if (! defined ($new)) {last main;}
     # if we're trying to find a match for a tag, then get rid of embedded 
newline
     # this is, I think, a kludge
     if ($line_buffer =~ /^\</ && $line_buffer =~ /\n$/) {
  chop $line_buffer;
  $line_buffer .= " ";}
     $line_buffer .= $new;
     $line_count++;}
    }

    ## cleanup
    &html_end_doc();

    if ($#stack > -1) {
 &printErr ("Stack not empty at end of document\n");
 &print_html_stack();}
}


sub html_tag {
    local ($tag) = @_;
    local ($element) = &tag_element ($tag);
    local (%attributes) = &tag_attributes ($tag);

    # the tag might minimize (be an implicit end) for the previous tag
    local ($prev_element);
    while (&Minimizes(&stack_top_element(), $element)) {
 $prev_element = &stack_pop_element ();
 if ($debug)  {
     &printErr ("MINIMIZING $prev_element with $element on $line_count\n");}
 &html_end ($prev_element, 0);}

    push (@stack, $tag);

    &html_begin ($element, $tag, *attributes);

    if (&Empty($element)) {
 pop(@stack);
 &html_end ($element, 0);}
}

sub html_etag {
    local ($tag) = @_;
    local ($element) = &tag_element ($tag);

    # pop stack until find matching tag.  This is probably a bad idea,
    # or at least too general.
    local ( $prev_element) = &stack_pop_element();
    until ($prev_element eq $element) {
 if ($debug) {
     &printErr ("MINIMIZING $prev_element with /$element on $line_count 
\n");}
 &html_end ($prev_element, 0);

 if ($#stack == -1) {
     &printErr ("No match found for /$element.  You will lose\n");
     last;}
 $prev_element = &stack_pop_element();}

    &html_end ($element, 1);
}


# For each element, the names of elements which minimize it.
# This is of course totally HTML dependent and probably I have it wrong too
$Minimize{"DT"} = "DT:DD";
$Minimize{"DD"} = "DT";
$Minimize{"LI"} = "LI";
$Minimize{"P"} = "P:DT:LI:H1:H2:H3:H4:BLOCKQUOTE:UL:OL:DL";

# Does element E2 minimize E1?
sub Minimizes {
    local ($e1, $e2) = @_;
    local ($value) = 0;
    foreach $elt (split (":", $Minimize{$e1})) {
 if ($elt eq $e2) {$value = 1;}}
    $value;}

$Empty{"BASE"} = 1;
$Empty{"BR"} = 1;
$Empty{"HR"} = 1;
$Empty{"IMG"} = 1;
$Empty{"ISINDEX"} = 1;
$Empty{"LINK"} = 1;
$Empty{"META"} = 1;
$Empty{"NEXTID"} = 1;
$Empty{"INPUT"} = 1;

# Empty tags have no content and hence no end tags
sub Empty {
    local ($element) = @_;
    $Empty{$element};}


sub print_html_stack {
    &printErr ("\n  ==\n");
    foreach $elt (reverse @stack) {&printErr ("  $elt\n");}
    &printErr ("  ==========\n");}

# The element on top of stack, if any.
sub stack_top_element {
    if ($#stack >= 0) { &tag_element ($stack[$#stack]);}}

sub stack_pop_element {
    &tag_element (pop (@stack));}

# The element from the tag, normalized.
sub tag_element {
    local ($tag) = @_;
    $tag =~ /<\/?([^\s>]+)/;
    local ($element) = $1;
    $element =~ tr/a-z/A-Z/;
    $element;}

# associative array of the attributes of a tag.
sub tag_attributes {
    local ($tag) = @_;
    $tag =~ /^<[A-Za-z]+ +(.*)>$/;
    &parse_attributes($1);}

# string should be something like
# KEY="value" KEY2="longer value"  KEY3="tags o doom"
# output is an associative array (like a lisp property list)
# attributes names are not case sensitive, do I downcase them
# Maybe (probably) I should substitute for entities when parsing attributes.

sub parse_attributes {
    local ($string) = @_;
    local (%attributes);
    local ($name, $val);
  get: while (1) {
      if ($string =~ /^ *([A-Za-z]+)\s*=\s*\"([^\"]*)\"/) {
   $name = $1;
   $val = $2;
   $string = $';
   $name =~ tr/A-Z/a-z/;
   $attributes{$name} = $val; }
      elsif ($string =~ /^ *([A-Za-z]+)\s*=\s*(\S*)/) {
   $name = $1;
   $val = $2;
   $string = $';
   $name =~ tr/A-Z/a-z/;
   $attributes{$name} = $val;}
      elsif ($string =~ /^ *([A-Za-z]+)/) {
   $name = $1;
   $val = "";
   $string = $';
   $name =~ tr/A-Z/a-z/;
   $attributes{$name} = $val;}
      else {last;}}
    %attributes;}

sub substitute_entities {
    local ($string) = @_;
    $string =~ s/&lt;/</g;
    $string =~ s/&gt;/>/g;
    $string =~ s/&quot;/\"/g;
    $string =~ s/&nbsp;/ /g;
    # Other entities.

    $string =~ s/&amp;/&/g;  # Do this last.
    $string;}


@HTML_elements = (
    "A",
    "ADDRESS",
    "B",
    "BASE",
    "BLINK", #  Netscape addition :-(
    "BLOCKQUOTE",
    "BODY",
    "BR",
    "CITE",
    "CENTER", # Netscape addition :-(
    "CODE",
    "DD",
    "DIR",
    "DFN",
    "DL",
    "DT",
    "EM",
    "FORM",
    "H1", "H2", "H3", "H4", "H5", "H6",
    "HEAD",
    "HR",
    "HTML",
    "I",
    "ISINDEX",
    "IMG",
    "INPUT",
    "KBD",
    "LI",
    "LINK",
    "MENU",
    "META",
    "NEXTID",
    "OL",
    "OPTION",
    "P",
    "PRE",
    "SAMP",
    "SELECT",
    "STRIKE",
    "STRONG",
    "TITLE",
    "TEXTAREA",
    "TT",
    "UL",
    "VAR",
    );

sub define_element {
    local ($element) = @_;
    $Begin{$element} = "Noop";
    $End{$element} = "Noop";}

foreach $element (@HTML_elements) {&define_element($element);}

# do nothing
sub Noop {
    local ($element, $xxx) = @_;}

# called when a tag begins.  Dispatches using Begin
sub html_begin {
    local ($element, $tag, *attributes) = @_;

    local ($routine) = $Begin{$element};
    if ($routine eq "") {
 &printErr ("Unknown HTML element $element ($tag) on line $line_count\n");}
    else {eval "&$routine;"}}

# called when a tag ends.  Explicit is 0 if tag end is because of 
minimization
# not that you should care.
sub html_end {
    local ($element, $explicit) = @_;
    local ($routine) = $End{$element};
    if ($routine eq "") {
 &printErr ("Unknown HTML element \"$element\" (END $explicit) on line 
$line_count\n");}
    else {eval "&$routine(\"$element\", $explicit)";}}

sub html_content {
    local ($word) = @_;
}

sub html_whitespace {
    local ($whitespace) = @_;}

sub html_comment {
    local ($tag) = @_;}

# redefine these for application-specific initialization and cleanup

sub html_begin_doc {}

sub html_end_doc {}

# return a "true value" when loaded by perl.
1;





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

Date: 05 Dec 2007 14:53:43 GMT
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: reuse code inquiry
Message-Id: <4756bb77$0$20398$e4fe514c@dreader32.news.xs4all.nl>

On Wed, 05 Dec 2007 22:34:39 +0800, a wrote:

> Dear all, I am a perl beginner and I am suggested to parse HTML by using
> other codes but not re-inventing the wheel.

If you're looking for existing perl libraries, the best place to start is

http://search.cpan.org/

As for the HTML parser, try this one:
http://search.cpan.org/~gaas/HTML-Parser-3.56/Parser.pm

Joost.



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

Date: Wed, 5 Dec 2007 15:17:32 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: reuse code inquiry
Message-Id: <c1si25-8de.ln1@osiris.mauzo.dyndns.org>


Quoth "a" <a@a.com>:
> Dear all, I am a perl beginner and I am suggested to parse HTML by using 
> other codes but not re-inventing the wheel.

This is good advice. One of Perl's strengths is the large amount of
good-quality code that is available for reuse.

> The following code is from Internet Search but what i find is a lot of 
> subroutines. When I fed it with an HTM file, nothing is generated or printed 
> out. Would anybody tell me where all the TD elements it store?

Nowhere. Did you read the comments? The code calls subs, which you have
to define, whenever it encounters a tag. If you want to store them
somewhere, you have to do it yourself. Also, the file is a Perl 4-style
library, not a complete script. If you attempt to simply run it it will
do nothing at all.

It seems to me that you need to read a good beginners book on Perl
before you go much further; 'Learning Perl' by Randal Schwartz et al. is
recommended, or see perldoc -q book for more.

> # HTML parser
> # Jim Davis, July 15 1994

This looks (from a brief check) like basically decent code, but it is
*very* old. It was clearly written for Perl 4, and only supports HTML
3.2, both of which are extinct nowadays. Get the HTML::Parser module
from CPAN and use that instead.

In general searching CPAN http://search.cpan.org is a better place to
start when looking for Perl code than searching the whole web. There's
an awful lot of really bad Perl out there.

Ben



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

Date: Wed, 05 Dec 2007 16:30:47 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: reuse code inquiry
Message-Id: <mugdl35iff92nhent5e8vdqi41k9djkeke@4ax.com>

On Wed, 5 Dec 2007 22:34:39 +0800, "a" <a@a.com> wrote:

>Dear all, I am a perl beginner and I am suggested to parse HTML by using 
>other codes but not re-inventing the wheel.

Generally people are suggested more specifically to use good HTML
parsing modules out of CPAN. The code you pasted is not a module, and
doesn't look very good. Also, its release date -namely 1994- should
ring a bell.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 5 Dec 2007 03:06:03 -0800 (PST)
From: krishu <muralikrishnan.s@gmail.com>
Subject: Re: Tk Compilation on Solaris 10 Failing
Message-Id: <bbc2064d-2e16-49ff-a66f-5bf9811e2d89@e10g2000prf.googlegroups.com>

On Dec 4, 2:33 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth krishu <muralikrishna...@gmail.com>:
>
>
>
>
>
> > I'm trying to install Tk in a Solaris 10 box ( SunOS netra1 5.10
> > Generic_125100-10 sun4u sparc SUNW,Netra-240 ). I downloaded
> > Tk-804.027 Version and installed it usually.
>
> > perl Makefile.PL
>
> > but it is complaining the following error.
>
> > checking whether the C compiler (cc -D_LARGEFILE_SOURCE -
> > D_FILE_OFFSET_BITS=64 -xarch=v8 -D_TS_ERRNO -KPIC -D_LARGEFILE_SOURCE -
> > D_FILE_OFFS
> > ET_BITS=64 -xarch=v8 -D_TS_ERRNO ) works... no
> > configure: error: installation or configuration problem: C compiler
> > cannot create executables.
>
> > I'm using gcc 3.4.3 and assures it is  first in the PATH variable.
>
> You're using a perl built with Sun's cc. You have to build modules with
> the same compiler as perl, so you'll either have to obtain and install
> Sun's cc, or rebuild perl with gcc.
>
> Note that you have to be a little careful replacing the system perl on
> Solaris: IIRC you can replace /usr/bin/perl, as all the system stuff
> that requires a specific version refers to it as /opt/perl5/something,
> but you should check this before you do anything.
>
> Ben

Ben,

Awesome.. Information..
It just straight forward fixed my issue.

I installed perl compiled with gcc. (from sunfreeware.com ) and
compiled Tk Module with it. It went through fine and I could
run Tk Apps now. Thanks a lot Ben.
--
Regards
S.Murali Krishnan.


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

Date: Wed, 5 Dec 2007 03:06:49 -0800 (PST)
From: krishu <muralikrishnan.s@gmail.com>
Subject: Re: Tk Compilation on Solaris 10 Failing
Message-Id: <515eef42-3ac7-4bc1-a48c-c0eee606e976@i29g2000prf.googlegroups.com>

On Dec 4, 2:33 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth krishu <muralikrishna...@gmail.com>:
>
>
>
>
>
> > I'm trying to install Tk in a Solaris 10 box ( SunOS netra1 5.10
> > Generic_125100-10 sun4u sparc SUNW,Netra-240 ). I downloaded
> > Tk-804.027 Version and installed it usually.
>
> > perl Makefile.PL
>
> > but it is complaining the following error.
>
> > checking whether the C compiler (cc -D_LARGEFILE_SOURCE -
> > D_FILE_OFFSET_BITS=64 -xarch=v8 -D_TS_ERRNO -KPIC -D_LARGEFILE_SOURCE -
> > D_FILE_OFFS
> > ET_BITS=64 -xarch=v8 -D_TS_ERRNO ) works... no
> > configure: error: installation or configuration problem: C compiler
> > cannot create executables.
>
> > I'm using gcc 3.4.3 and assures it is  first in the PATH variable.
>
> You're using a perl built with Sun's cc. You have to build modules with
> the same compiler as perl, so you'll either have to obtain and install
> Sun's cc, or rebuild perl with gcc.
>
> Note that you have to be a little careful replacing the system perl on
> Solaris: IIRC you can replace /usr/bin/perl, as all the system stuff
> that requires a specific version refers to it as /opt/perl5/something,
> but you should check this before you do anything.
>
> Ben

Ben,

Awesome.. Information..
It just straight forward fixed my issue.

I installed perl compiled with gcc. (from sunfreeware.com ) and
compiled Tk Module with it. It went through fine and I could
run Tk Apps now. Thanks a lot Ben.
--
Regards
S.Murali Krishnan.


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

Date: Wed, 5 Dec 2007 04:58:56 -0800 (PST)
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: variable number of arguments to bind_columns
Message-Id: <ece02354-24d5-48ff-9053-fec8a6c756ad@e25g2000prg.googlegroups.com>


Hi,
I have to call the method bind_columns() of DBI, with a number of
arguments unknown at runtime: the args are references, each to a
column value

e.g. with 3 args:
$sth->bind_columns(undef,\$a[0],\$a[1],\$a[2]);

or 4:
$sth->bind_columns(undef,\$a[0],\$a[1],\$a[2],\$a[3]);


there is a way to construct this call in a single way, given the
$ncolumns value?

Thank you!

Alessandro


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

Date: Wed, 5 Dec 2007 06:01:01 -0800 (PST)
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: Re: variable number of arguments to bind_columns
Message-Id: <cc9ace20-ba6d-4941-9f62-fe6846dd58a8@e67g2000hsc.googlegroups.com>

ok, dumb question (I must be tired)
 ...
push @bindargs,\$a[1];
 ...
push @bindargs,\$a[2];
 ...
$sth->bind_columns(undef,@bindargs);

alessandro



alexxx.magni@gmail.com ha scritto:

> Hi,
> I have to call the method bind_columns() of DBI, with a number of
> arguments unknown at runtime: the args are references, each to a
> column value
>
> e.g. with 3 args:
> $sth->bind_columns(undef,\$a[0],\$a[1],\$a[2]);
>
> or 4:
> $sth->bind_columns(undef,\$a[0],\$a[1],\$a[2],\$a[3]);
>
>
> there is a way to construct this call in a single way, given the
> $ncolumns value?
>
> Thank you!
>
> Alessandro


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

Date: 5 Dec 2007 15:46:55 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: variable number of arguments to bind_columns
Message-Id: <slrnfldhvg.qp6.glennj@smeagol.ncf.ca>

At 2007-12-05 09:01AM, "alexxx.magni@gmail.com" wrote:
>  ok, dumb question (I must be tired)
>  ...
>  push @bindargs,\$a[1];
>  ...
>  push @bindargs,\$a[2];
>  ...
>  $sth->bind_columns(undef,@bindargs);

A more compact replacement for 'n' push commands is:
    my @bindargs = map { \$_ } @a;

As in:
    $ perl -MData::Dumper -e '@a=qw(a b c);@b=map{\$_}@a;print Dumper(\@a,\@b)'
    $VAR1 = [
              'a',
              'b',
              'c',
            ];
    $VAR2 = [
              \$VAR1->[0],
              \$VAR1->[1],
              \$VAR1->[2],
            ];

    
-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

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 V11 Issue 1091
***************************************


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