[21825] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4029 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 25 18:07:01 2002

Date: Fri, 25 Oct 2002 15:05:19 -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           Fri, 25 Oct 2002     Volume: 10 Number: 4029

Today's topics:
        [ANNOUNCE] Apache::SessionManager 0.04 <enrico@sorcinelli.it>
    Re: [REPOST] Need advice on a project (wrt to tie'ing t <goldbb2@earthlink.net>
        Before I buy the Book ... <pasdespam_desmond@zeouane.org>
    Re: Before I buy the Book ... <comdog@panix.com>
    Re: Before I buy the Book ... <pasdespam_desmond@zeouane.org>
    Re: Before I buy the Book ... <jhalpin@nortelnetworks.com_.nospam>
    Re: Before I buy the Book ... <twhu@lucent.com>
        Chart creation <mgauf@yahoo.com>
    Re: Chart creation <comdog@panix.com>
    Re: GNU plot in perl (Anirban Chakraborti)
        Help: Sending to a $ variable in cgi SMTP (Terry Taft)
    Re: Help: Sending to a $ variable in cgi SMTP (Helgi Briem)
    Re: Help: Sending to a $ variable in cgi SMTP <nobull@mail.com>
    Re: Help: Sending to a $ variable in cgi SMTP <nobull@mail.com>
    Re: Help: Sending to a $ variable in cgi SMTP <alecler@sympatico.ca>
    Re: HTML:Parser (Jay Tilton)
    Re: HTML:Parser <bart.lateur@pandora.be>
    Re: Image::Magick <codmate@NOSPAMntlworld.com>
    Re: IO::Socket::INET and telnet <goldbb2@earthlink.net>
    Re: IO::Socket::INET and telnet <jason@baugher.pike.il.us>
        ISO guide to the Perl source code <bill_knight2@yahoo.com>
    Re: ISO guide to the Perl source code <tassilo.parseval@post.rwth-aachen.de>
    Re: MD5 password encryption <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 25 Oct 2002 16:02:22 GMT
From: Enrico Sorcinelli <enrico@sorcinelli.it>
Subject: [ANNOUNCE] Apache::SessionManager 0.04
Message-Id: <20021025181454.1e291067.enrico@sorcinelli.it>

Hi all,
a new version 0.04 of Apache::SessionManager is now available via CPAN

Download site for Apache::SessionManager
 
http://www.cpan.org/authors/id/E/EN/ENRYS/Apache-SessionManager-0.04.tar.gz

Changes from previous version
-----------------------------
This is a maintenance release. It fixes some problems of test suite.
 
+ Set '/' as default path attribute for session cookies
! Updated Makefile.PL in order to skip generation of Apache test section
  in Makefile if 'use Apache::test' fails (noticed by Jeroen Latour
  <jlatour@www.arens.nl>). 
! Updated t/01real.t in order to skip it if 'use Apache::test' fails. 
  I've chosen simply to skip test if eval "use Apache::test" fails in 
  Makefile.PL, even if I think that Apache::SessionManager hasn't a 
  sense unless mod_perl :-)

Description
-----------
This package contains an Apache mod_perl module to manage HTTP sessions.
Apache::SessionManager is a mod_perl module that helps 
session management of a web application. This module is a 
wrapper around Apache::Session persistence framework for session data.
It creates a session object and makes it available to all other handlers 
transparenlty by putting it in pnotes. 

See:

   perdoc Apache::SessionManager

for module documentation and use.

Any comment/criticism are welcome

	- Enrico


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

Date: Fri, 25 Oct 2002 14:54:04 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: [REPOST] Need advice on a project (wrt to tie'ing to a file and general strategy)
Message-Id: <3DB9934C.745DFE6@earthlink.net>

Michele Dondi wrote:
> 
> On Thu, 24 Oct 2002 02:07:11 -0400, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
> 
> >> I still have some questions: as you might have read I had thought
> >> of using a hash whose values are array refences. In any case it
> >> seems that I can't have a tied hash of arrays, can I?!?
> >
> >You can and you can't.  You can't, in that if you simply store an
> >arrayref in a tied database, it gets stringified as something like
> >"ARRAY(0x12345678)", and of course you can't go from this string back
> >to an array (especially not between seperate executions of perl). 
> 
> This is exactly what I meant with "I can't".
> 
> >You can, in that if you install a filter (see perldoc perldbmfilter),
> >you can have your arrayrefs automatically serialized when stored in
> >the database and deserialized when retrieved.
> >
> >Depending on what's in those array references you mentioned,
> >serializing can be easy or hard.
> 
> Easy, in my case.
> 
> >> Most probably I wasn't clear. I was thinking of an algorithm taking
> >> checksums only of files with the same size.
> >
> >Why?  It seems to me that you would have to keep a list of all the
> >different possible sizes, then.  Also, it sounds like you'd first
> >need to do one pass to find out what each of the different sizes are,
> >and then, for each different size, another pass to deal with (find
> >checksums of) all files of that particular size.  This sounds like
> >many, many, passes through the filesystem.
> >
> >If you just make one pass through the filesystem, calculating
> >checksums, that should be sufficient.
> 
> Well, my old, ineffiecient and error prone script used only one pipe
> and one pass through the filesystem. The pass was done once for all
> with 'find' (printing filesizes directly), then it sorted by filesize
> and uniq'ed for printing duplicate entries only. Then checksums were
> calculated on these entries and the stream was sorted again by the
> checksums and uniq'ed for printing duplicates once again. And that's
> all...

Well, if you're storing *all* of the filenames, then discarding non-uniq
ones, then I suppose that works, too.

But you're still making multiple passes through the filenames, just not
through the filesystem.

> >> My original, gross, shell script used the algorithm roughly
> >> described above because taking a file size is *much* faster than
> >> taking a checksum and two files having different sizes is a
> >> sufficient condition for them to be different (mathematically, it's
> >> an "invariant", isn't it?).
> >
> >Hmm.  I think I see what you're saying -- if there's only one file of
> >a particular size, then you can be certain that it's not a duplicate
> >of any other file.
> >
> >However, for every size for which there's more than one file of that
> >size, you have to calculate a checksum of all of those files.  So
> >really, the only point of keeping track of file sizes is that little
> >"if there's only one file of this size" optomization.
> 
> Yes, that's it. And in my experience this was a good optimization,
> that is, without it, the process always took much more time, even if I
> never did any quantitative verification about this.
> 
> >Not that it's a bad optimization, of course, but it doesn't seem like
> >there's any way to use this and do only one pass through the
> >filesystem.
> 
> Well, as I implicitly (through an example) said above, in a certain
> sense you CAN do only one pass, at the expense of storing the
> filenames (with paths).

Many algorithms have time/memory tradeoffs... you can do it fast,
consuming lots of memory, or slower, using less memory.  Perl often
picks the "throw memory at the problem" solution.  Storing the filenames
instead of refetching them thus sounds like a rather perlish solution :)

> >Ok, here's what I would add to my prior code:
> 
> Thanks, as in the previous case, it will take some time for me to
> examine the provided code: what is elementary for you may be advanced
> for me. And I'm rather busy these days, D'Oh!
> 
> In the meantime I managed to give a peek into File::Find::Duplicates.
> Quite surprisingly, it's not difficult at all to understand, so I have
> plenty of sources to take inspiration from...
> 
> In the meanwhile I also ran the duplicates finding function from the
> above mentioned module and contrarily to what I had expected, it
> worked without going out of memory. So, after all, the tie strategy
> was not needed at all for this task, but I'm happy to have begun
> exploring it!
> 
> Also, I won't use File::Find::Duplicates, because
> (1) It returns a hask keyed on the filesize. But each array (ref)
> associated to a key might contain more than one group of duplicate
> files.

With one small change to the subroutine, this can be changed.

From this:
      push @{$dupes{$size}}, @{$md5{$hash}} 
To this:
      push @{$dupes{$size}}, $md5{$hash}

> (2) I have to do other, massive, "operations" on the files and I don't
> want to browse through the directory tree twice. In this respect
> tieing might become a strict necessity.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Fri, 25 Oct 2002 20:17:37 +0000
From: Desmond Coughlan <pasdespam_desmond@zeouane.org>
Subject: Before I buy the Book ...
Message-Id: <slrnarj9n1.6g6.pasdespam_desmond@lievre.voute.net>

Hi,
This is my first post here.  I've been lurking for a while, trying to
decide which book to buy to learn perl.  After scouting around the web,
and asking some friends, I've decided to buy _Learning Perl_ by Schwartz
and Phoenix.  Whilst waiting for payday, I checked out some online
tutorials, and found this one ... 

url:http://archive.ncsa.uiuc.edu/General/Training/PerlIntro/

 ... however, I get to the following ... 

	'You're wasting perl if you don't use associative arrays. 
	Associative arrays, sometimes called "hashes", are arrays that
	are indexed not on ordered integers, but on arbitrary string 
	values. Typically, elements of an associative array are refered to 
	as "key" and "value" pairs - the "key" is used to find the element 
	of the array that has the "value". Basic operators are ...'

 ... and might as well be reading Chinese.  Is this the sort of shit that
I can expect ?  Learning perl is purely for recreation, as I no longer work
in IT.  Thanks in advance for your opinions.

-- 
Desmond Coughlan      |CUNT#1 YGL#4 YFC#1 YFB#1 UKRMMA#14 two#38
desmond @ zeouane.org |BONY#48 ANORAK#11
http: // www . zeouane . org


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

Date: Fri, 25 Oct 2002 15:25:44 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Before I buy the Book ...
Message-Id: <251020021525448962%comdog@panix.com>

In article <slrnarj9n1.6g6.pasdespam_desmond@lievre.voute.net>, Desmond Coughlan <pasdespam_desmond@zeouane.org> wrote:

> This is my first post here.  I've been lurking for a while, trying to
> decide which book to buy to learn perl.  After scouting around the web,
> and asking some friends, I've decided to buy _Learning Perl_ by Schwartz
> and Phoenix.  Whilst waiting for payday, I checked out some online
> tutorials, and found this one ... 
> 
> url:http://archive.ncsa.uiuc.edu/General/Training/PerlIntro/

>  'You're wasting perl if you don't use associative arrays. 
>  Associative arrays, sometimes called "hashes"...'

> ... and might as well be reading Chinese.  Is this the sort of shit that
> I can expect ?  

what is "shit"? since you do not know Perl yet, you shouldn't be
surprised if you jump in the middle of a tutorial and do not understand
the terms.

but, more importantly, as with anything, you can't really compare what
you should expect from one author by reading a different one.

Randal did not write what you called "shit", so you should not expect the
same thing in his book.  you can read many of Randal's magazine columns
online to see if you like his writing style:

   http://www.stonehenge.com/merlyn/columns.html

-- 
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl 
<http://www.theperlreview.com>


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

Date: Fri, 25 Oct 2002 20:27:59 +0000
From: Desmond Coughlan <pasdespam_desmond@zeouane.org>
Subject: Re: Before I buy the Book ...
Message-Id: <slrnarjaaf.6je.pasdespam_desmond@lievre.voute.net>

Le Fri, 25 Oct 2002 15:25:44 -0500,  brian d foy <comdog@panix.com> a écrit : 

{ snip }

>> ... and might as well be reading Chinese.  Is this the sort of shit that
>> I can expect ?  

> what is "shit"? since you do not know Perl yet, you shouldn't be
> surprised if you jump in the middle of a tutorial and do not understand
> the terms.

You should not interpret the word 'shit' as being pejorative.  It means,
'stuff'.  Sorry if I gave the impression that I was criticising.

Thanks for the link. :-)

-- 
Desmond Coughlan      |CUNT#1 YGL#4 YFC#1 YFB#1 UKRMMA#14 two#38
desmond @ zeouane.org |BONY#48 ANORAK#11
http: // www . zeouane . org


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

Date: 25 Oct 2002 16:03:01 -0500
From: Joe Halpin <jhalpin@nortelnetworks.com_.nospam>
Subject: Re: Before I buy the Book ...
Message-Id: <yxs7n0p2mdtm.fsf@nortelnetworks.com_.nospam>

Desmond Coughlan <pasdespam_desmond@zeouane.org> writes:

> This is my first post here.  I've been lurking for a while, trying
> to decide which book to buy to learn perl.  After scouting around
> the web, and asking some friends, I've decided to buy _Learning
> Perl_ by Schwartz and Phoenix.  Whilst waiting for payday, I checked
> out some online tutorials, and found this one ...

Take a look at the man pages and other stuff available at 

http://www.perldoc.com/
http://www.perl.com/pub/q/documentation

in particular

http://www.perldoc.com/perl5.6/pod/perl.html

From this page you can get a beginner's view of perl syntax, data
types, etc. See especially the perlfaq man page.

I personally like "Programming Perl" as a language reference, but
"Perl Cookbook" is quite nice to have around too.

Joe


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

Date: Fri, 25 Oct 2002 17:16:55 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Before I buy the Book ...
Message-Id: <apccce$1fa@netnews.proxy.lucent.com>

It is similar to the Hashtable in Java and Map in C++
if you have even learned a programming language before.

"Desmond Coughlan" <pasdespam_desmond@zeouane.org>
> 'You're wasting perl if you don't use associative arrays.
> Associative arrays, sometimes called "hashes", are arrays that
> are indexed not on ordered integers, but on arbitrary string
> values. Typically, elements of an associative array are refered to
> as "key" and "value" pairs - the "key" is used to find the element
> of the array that has the "value". Basic operators are ...'




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

Date: Fri, 25 Oct 2002 19:03:31 GMT
From: Michael Gauf <mgauf@yahoo.com>
Subject: Chart creation
Message-Id: <3DB996B5.B779EC7F@yahoo.com>

I am looking a open-source, server-side chart (bar, pie, candlestick,
fever, etc.) creation program for UNIX environment. It should also be
able to connect to a MySQL database.

Thanks in advance.

Mike


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

Date: Fri, 25 Oct 2002 14:11:05 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Chart creation
Message-Id: <251020021411050248%comdog@panix.com>

In article <3DB996B5.B779EC7F@yahoo.com>, Michael Gauf <mgauf@yahoo.com> wrote:

> I am looking a open-source, server-side chart (bar, pie, candlestick,
> fever, etc.) creation program for UNIX environment. It should also be
> able to connect to a MySQL database.

GD::Graph can make nice charts, and DBI can connect to databases.  it's
up to you to glue them together. :)

-- 
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl 
<http://www.theperlreview.com>


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

Date: 25 Oct 2002 12:49:05 -0700
From: achakrab@nmsu.edu (Anirban Chakraborti)
Subject: Re: GNU plot in perl
Message-Id: <f33fa166.0210251149.601c8d27@posting.google.com>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnar79sa.kud.mgjv@verbruggen.comdyn.com.au>...
> On 20 Oct 2002 21:04:42 -0700,
> 	Anirban Chakraborti <achakrab@nmsu.edu> wrote:
> > hi,
> >       I am using GNU plot function in perl.I am able to use it
> > properly when i initalize the x and y axis arrays in the function.But
> > I am not able to initialise it outside the function at run time.Like
> > say the x and y axis arrays may be filled by a for loop and the loop
> > is outside the function but in the same program.but it doesn't work???
> 
> What is the code you're using? It isn't clear at all from your rather
> vague description what the problem is, or even what you are talking
> about.
> 
> Martien

hi Martien

here is what I did

I have installed a perl module named Chart::Graph, a front end to
gnuplot in perl.you can see the documentation for this in

http://www.caida.org/tools/utilities/graphing/graph_gnuplot.xml#name

and the code I wrote according to the documentation given in the above
weblink is

use Chart::Graph::Gnuplot qw(gnuplot);

    gnuplot({"title" => "sapa",
             "output type"=>"png",
             "output file"=>"gnupsa1.png"},
             [{"title" => "data1",
               "style" => "lines",
               "type" => "columns"},  [5,67,89,67,1,],
                                      [5,28,50,60,70] ],
);    


This code works and plot the graph according to the values gven in the
array.

Then I tried to write a program  


#! /usr/bin/perl

@x=[1,2,4,5,6];
@y=[1,2,4,5,6];

use Chart::Graph::Gnuplot qw(gnuplot);

gnuplot({"title" => "sapa",
             "output type"=>"png",
             "output file"=>"gnupsa1.png"},
             [{"title" => "data1",
               "style" => "lines",
               "type" => "columns"},  @x,
                                      @y]
);

    


Even this program works 

Next when I tried to give values automatically using a for loop the
program does not work

#! usr/bin/perl

for($i = 0;$i<6;$i++)
{
 $x[$i]=6;

}

@y=[1,2,3,4,5,6];

use Chart::Graph::Gnuplot qw(gnuplot);

gnuplot({"title" => "sapa",
             "output type"=>"png",
             "output file"=>"gnupsa1.png"},
             [{"title" => "data1",
               "style" => "lines",
               "type" => "columns"},  @x,@y],
);    

When I run the above program it gives an error

"Column data must be a reference to an array at testsap.pl line 15"


can you please help in writing a code using which we can be able to
give as many x-values and y-values using for loop.


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

Date: 25 Oct 2002 08:14:53 -0700
From: Terry_Taft@hotmail.com (Terry Taft)
Subject: Help: Sending to a $ variable in cgi SMTP
Message-Id: <5563bcc9.0210250714.15fb5f6d@posting.google.com>

Hello. I can't seem to find the answer to this question in previous
newsgroups posts. I'm using SMTP to mail to an email address entered
through a form field. I can't seem to get the variable for To to work.
The variable for FROM works and the variable for MESSAGEDATA works,
but for some reason TO doesn't. Any suggestions or help??

Here's the code (roughly):

#!c:\perl\bin\perl -wT
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);


my $q = new CGI;
print $q->header;

my($from) = $q->param('from'); # search string from outside script
if (!$from){&noanswer;} # sets string to space if no search string
given
unless ($from =~ /^[\w .,!'?@-]+$/ ) {&noanswer; 
}
# this is the part that doesn't work
my($to) = $q->param('to'); # search string from outside script
if (!$to){&noanswer;} # sets string to space if no search string given
unless ($to =~ /^[\w .,!'?@-]+$/ ) {&noanswer; 
}

use Net::SMTP;

        $smtp = Net::SMTP->new(MYSERVER); # connect to an SMTP server
        $smtp->mail( '$from' );     # use the sender's address here
        $smtp->to( '$to' );        # recipient's address
        $smtp->data();                      # Start the mail

        # Send the header.
        $smtp->datasend("To: '$to'\n");
   $smtp->datasend("From: $from\n");
        $smtp->datasend("Subject: Check out this website!\n");
        $smtp->datasend("\n");

        # Send the body.
        $smtp->datasend("MYDATAMESSAGE\n");
        $smtp->dataend();                   # Finish sending the mail
        $smtp->quit;                        # Close the SMTP
connection


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

Date: Fri, 25 Oct 2002 15:42:35 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Help: Sending to a $ variable in cgi SMTP
Message-Id: <3db965ab.822474625@news.cis.dfn.de>

On 25 Oct 2002 08:14:53 -0700, Terry_Taft@hotmail.com (Terry
Taft) wrote:

>Hello. I can't seem to find the answer to this question in previous
>newsgroups posts. I'm using SMTP to mail to an email address entered
>through a form field. I can't seem to get the variable for To to work.
>The variable for FROM works and the variable for MESSAGEDATA works,
>but for some reason TO doesn't. Any suggestions or help??

The $to needs to be in double quotes so that it is 
interpolated, single quotes don't interpolate. 
However, it seems to me that the $from variable
would have the same problem:

>        $smtp->mail( '$from' );     # use the sender's address here
>        $smtp->to( '$to' );        # recipient's address
Should be:

$smtp->mail( "$from" );   
 $smtp->to("$to" );  

And
>        $smtp->datasend("To: '$to'\n");
should be
        $smtp->datasend("To: "$to"\n");
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: 25 Oct 2002 17:20:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Help: Sending to a $ variable in cgi SMTP
Message-Id: <u91y6e5w2s.fsf@wcl-l.bham.ac.uk>

Terry_Taft@hotmail.com (Terry Taft) writes:

>         $smtp->mail( '$from' );     # use the sender's address here
>         $smtp->to( '$to' );        # recipient's address

Go look up what single quotes mean in Perl. See 'Quote and Quote-like
Operators' in perlop.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 25 Oct 2002 17:32:12 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Help: Sending to a $ variable in cgi SMTP
Message-Id: <u9of9i4gz7.fsf@wcl-l.bham.ac.uk>

helgi@decode.is (Helgi Briem) writes:

> Should be:
> 
> $smtp->mail( "$from" );   

See FAQ: What's wrong with always quoting "$vars"?

:-)

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 25 Oct 2002 16:30:13 -0400
From: Andre <alecler@sympatico.ca>
Subject: Re: Help: Sending to a $ variable in cgi SMTP
Message-Id: <alecler-FB254A.16301325102002@news1.qc.sympatico.ca>

In article <3db965ab.822474625@news.cis.dfn.de>, helgi@decode.is wrote:

> On 25 Oct 2002 08:14:53 -0700, Terry_Taft@hotmail.com (Terry
> Taft) wrote:
[...]
> >        $smtp->datasend("To: '$to'\n");

> should be
>         $smtp->datasend("To: "$to"\n");

Brilliant.

Andre


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

Date: Fri, 25 Oct 2002 21:47:33 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: HTML:Parser
Message-Id: <3db9bb8e.24712620@news.erols.com>

sailordwarf@hotmail.com (Andrew Gatt) wrote:

: Hi, i'm new to Perl and am trying to knock up a site search program. 
: I wanted the text out of the html pages and so after a bit of a look
: around used the HTML:Parser module. It seems to be working fine except
: it returns javascript functions as part of the text.
: e.g.
: <SCRIPT LANGUAGE="JavaScript">    not text
: <!--                              text
: function x                        text
: {
: 
: }
: //-->                             text
: </script>                         not text
: 
: Am i right in thinking there is some way to filter (HTML:Filter??)
: these javascript functions out. Something like, ignore everything
: between script tags. If there is could someone point me in the right
: direction.

It's just personal preference, but for most simple HTML operations, I
like HTML::TreeBuilder more than I like the raw HTML::Parser.  A
ready-made tree seems much easier to visualize and manipulate.

    #!perl
    use warnings;
    use strict;
    use HTML::TreeBuilder;
    my $filename = shift or die "Filename, please.";
    my $tree = HTML::TreeBuilder->new->parse_file($filename);

Then you can clobber whatever elements of the tree you like
(don't like, even).

    $_->delete foreach $tree->find_by_tag_name( qw/ script / );

Or, if all you want is the text content, skip that and go right to the
big finish.

    my $text = $tree->as_text;

Nothing to it.



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

Date: Fri, 25 Oct 2002 21:52:04 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: HTML:Parser
Message-Id: <4vejruc9gob0bjqcr1uh1dokcnmr3gebs1@4ax.com>

Andrew Gatt wrote:

>I wanted the text out of the html pages and so after a bit of a look
>around used the HTML:Parser module. It seems to be working fine except
>it returns javascript functions as part of the text.

You think that's counter-intuitive? Join the club, now there's at least
two of us.

The thing is, recent incarnations of HTML::Parser treat whatever is
between "<script>" and "</script>" tags, as CDATA, i.e. special "text"
with reduced parsing. (There must be at least one more tag that does the
same, but I forgot which that is.). That's good.The event it triggers,
is the ordinary "text" event, which now has an extra argument. That's
not so good. So check that new third argument in the text event, a flag,
and you can make the distinction.

-- 
	Bart.


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

Date: Fri, 25 Oct 2002 16:11:18 +0100
From: Codmate <codmate@NOSPAMntlworld.com>
Subject: Re: Image::Magick
Message-Id: <apbmld$a6a$1@nntp0.reith.bbc.co.uk>

Jonas Nilsson wrote:
> I can't seem to get what I want...
> 
> I need to be able to just add some empty lines to the right or at the bottom
> of the picture.
> 
> Now, I use Montage which feels like sub-optimal. Like this:
> 
> 
> $res=$p->Read($file);   warn "$res" if "$res";
> $p->Set('compression'=>'none');
> $res=$p->Crop(geometry=>'100x100+10+90'); warn "$res" if "$res";
> 
> my $p2=$p->Montage(geometry=>'100x150',gravity=>'northwest'); # 50 empty
> line at the bottom...
> $res=$p2->Crop(geometry=>'100x150'); warn "$res" if "$res";         #
> Montage adds two extra unwanted
> 
> #lines at the bottom - allways?!?!
> $res=$p2->Write(filename=>"out.tif"); warn "$res" if "$res";
> 
> 
> Please assist me...
> /jN

A system call to mogrify might be the easiest way to tackle this  :)

Get your terminal open and 'man mogrify'.



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

Date: Fri, 25 Oct 2002 15:05:11 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: IO::Socket::INET and telnet
Message-Id: <3DB995E7.67C2138F@earthlink.net>

Jason Baugher wrote:
> 
> I've got the following simple code that I can't get to work:
> 
> #!/usr/bin/perl -w
> use strict;
> use IO::Socket;
> 
> my $request = IO::Socket::INET->new(
>     PeerAddr => 'marianne',
>     PeerPort => '23',
>     Proto    => 'tcp',
>     Type     => SOCK_STREAM,
> ) or die "$!";
> 
> print while <$request>;
> 
> Basically, when I run this script, I get nothing at all, and it never
> completes - which tells me the socket opened, just that it isn't
> reading the data I expect to see.
> 
> Doing a normal telnet to this machine on port 23 works:
> 
> $ telnet marianne 23
> Trying 10.10.10.4...
> Connected to marianne (10.10.10.4).
> Escape character is '^]'.
> Red Hat Linux release 7.3 (Valhalla)
> Kernel 2.4.18-3 on an i686
> login:
> 
> Why don't I see the 3 "Red Hat .... login:" lines from the perl
> script?

This is because your perl code:

   print while <$request>;

is trying to read whole (newline delimited) lines.  So it gets "login:",
and waits for a newline... and since it doesn't get one, <$request>
blocks.

Try changing it to:

   $| = 1;
   print while sysread $request, $_, 4096;

> When I alter it to use PeerPort => '25', it gives me the return string
> from the FTP server, like I expect it to.

This is because the FTP server appends a CRLF to every line that it
sends.

> What is really annoying is that I can find examples of this all over
> Google, and even though I follow the various examples, I can't get it
> to spit out anything.

Oh?  How many of those examples use the <> operator to recieve
information from a service which doesn't stick newlines on the ends of
lines?

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Fri, 25 Oct 2002 20:13:30 GMT
From: Jason Baugher <jason@baugher.pike.il.us>
Subject: Re: IO::Socket::INET and telnet
Message-Id: <Xns92B29AE063E9Ejasonbaugherpikeilus@209.242.76.10>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in comp.lang.perl.misc:

>> Why don't I see the 3 "Red Hat .... login:" lines from the perl
>> script?
> 
> This is because your perl code:
> 
>    print while <$request>;
> 
> is trying to read whole (newline delimited) lines.  So it gets
> "login:", and waits for a newline... and since it doesn't get one,
> <$request> blocks.
> 
> Try changing it to:
> 
>    $| = 1;
>    print while sysread $request, $_, 4096;

A similar response came from someone else.  Try it yourself, it doesn't
work.  What you'll get from the sysread is the garbage from the telnet
server's attempt at negotiation, which of course my client program isn't
capable of handling.  Therefore you'll never see the text lines, since
the telnet server never gets that far. 

Hence the suggestion by someone else to use Net::Telnet, which handles
the negotiation for you. 

> 
>> When I alter it to use PeerPort => '25', it gives me the return
>> string from the FTP server, like I expect it to.
> 
> This is because the FTP server appends a CRLF to every line that it
> sends.
> 
>> What is really annoying is that I can find examples of this all over
>> Google, and even though I follow the various examples, I can't get it
>> to spit out anything.
> 
> Oh?  How many of those examples use the <> operator to recieve
> information from a service which doesn't stick newlines on the ends of
> lines?
> 

There are many examples of connecting to a port and reading from it
simply - just like I showed.  If I could have found one that
specifically addressed the telnet(23) port, then I'm sure it would have
explained what I was missing. 

So, it isn't about the newlines, it's about the telnetd never completing
negotiation, and therefore never kicking out the text I wanted to
capture.  Using Net::Telnet, it negotiates for me, and I can getline
what I need. 

Thanks to Ilja Tabachnik for explaining this elsewhere in this thread!


-- 
Jason Baugher 
Virtual Adept Professional Consulting Services
1406 Adams Street, Quincy, IL 62301 - (217) 221-5406
jason@baugher.pike.il.us - http://baugher.pike.il.us/virtualadept


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

Date: Fri, 25 Oct 2002 19:40:54 +0000 (UTC)
From: bill <bill_knight2@yahoo.com>
Subject: ISO guide to the Perl source code
Message-Id: <apc6o6$qie$1@reader1.panix.com>




Like almost every Perl programmer I know, I taught myself Perl, but
I've reached a point at which most of my questions about Perl would
require me to delve into Perl's source code.  I've tried this, in
fact, but I discovered than doing this on my own, without any form of
assistance, would take more time than I can devote to it, and at any
rate, is beyond my powers of concentration.

Does anybody know of any assistance (book, workshop, website) for
someone who wants to know Perl down to its source code?  I'm willing
to travel and pay (within reason) for this instruction/coaching.

TIA,

bill



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

Date: 25 Oct 2002 21:30:05 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: ISO guide to the Perl source code
Message-Id: <apcd4t$cl2$1@nets3.rz.RWTH-Aachen.DE>

Also sprach bill:

> Like almost every Perl programmer I know, I taught myself Perl, but
> I've reached a point at which most of my questions about Perl would
> require me to delve into Perl's source code.  I've tried this, in
> fact, but I discovered than doing this on my own, without any form of
> assistance, would take more time than I can devote to it, and at any
> rate, is beyond my powers of concentration.

Eh, what kind of questions does the source answer that the docs don't?
I am referring to pure Perl questions here.

The source will tell you what Perl's data types really are, how it
parses Perl code, how open() and every other functions works and so on.

> Does anybody know of any assistance (book, workshop, website) for
> someone who wants to know Perl down to its source code?  I'm willing
> to travel and pay (within reason) for this instruction/coaching.

The information are cluttered around the internet. Start with
perlguts.pod. A nice visualization can be found at
http://gisle.aas.no/perl/illguts/. There are also a few pamphlets by
Simon Cozens, for instance at http://www.netthink.co.uk/downloads.html.

These things are probably awfully hard when solely discovered through
reading. Since you feel ready to tackle the core, better start with
something that is both enlighting and useful, like writing some XS
yourself (see perlxstut.pod and perlxs.pod). You'll be digging through
the Perl source (the headers at least) often enough in due course.

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: 25 Oct 2002 17:18:57 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: MD5 password encryption
Message-Id: <u965vq5w5q.fsf@wcl-l.bham.ac.uk>

"cheechew" <cheechew@hotmail.com> top-posts:

[ Text reordered.  Top posting is rude.  Do not do it unless it is your
intent to cause offence. ]

> "Brian McCauley" <nobull@mail.com> wrote in message
> news:u93cqv6iaf.fsf@wcl-l.bham.ac.uk...
> > "Chee Chew" <cheechew@hotmail.com> writes:
> >
> > > I am planning to put MD5 password encryption text into the program for
> > > security. This program will be using the password to login to some other
> > > machine to run certain batch job.
> >
> > MD5 is irreversable - you cannot retrieve the plaintext password or a
> > password-equivalent.
> >
> > I suspect your real question is essentially the same as that asked
> > numerous previous threads in this newsgroup. The most recent such
> > thread being "Hiding password variables in PERL" earlier this week.

Why did you not look at the "numerous previous threads" I mentioned?

Please see article <u94rs2nu6a.fsf@wcl-l.bham.ac.uk>
http://groups.google.com/groups?selm=u94rs2nu6a.fsf%40wcl-l.bham.ac.uk

> MD5 could not be appropriate. How about 3DES with key.

How are you going to keep the key secure?  Whatever method you are
going to use to secure the key why not just use that to secure the
password in the first place?

> Any perl module on that?

Have you bothered to look before asking?

I didn't know the answer but it took me only a few seconds to find

But like I said before this won't help you because your problem is not
what you think it is.  You think your problem is "How can I achive X
by doing Y in Perl?"  But your real problem is "I thought I wanted to
do Y but Y is fundamentally impossible, what else can I do
instead to achieve X?"

Like I say this particular "X" has been discussed here many times
before, there is nothing to be gained by discussing it again.  Anyhow
this is nothing to do with Perl.  The solutions to "X" do not relate
to any particular programming language.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


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