[19993] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2188 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 23 09:06:02 2001

Date: Fri, 23 Nov 2001 06:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006524315-v10-i2188@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 23 Nov 2001     Volume: 10 Number: 2188

Today's topics:
        [ANNOUNCE] HTTP::WebTest 1.07 <ilya@martynov.org>
        ANNOUNCE: Inline::Awk 0.03 (John McNamara)
        ANNOUNCE: Lingua::Ident 1.4 <mxp@dynalabs.de>
        ANNOUNCE: Log::Dispatch::Config miyagawa@bulklnews.net
        ANNOUNCE: XML::SAX::Simple (Matt Sergeant)
        Checking Disk Space of Win NT Box from Linux with Perl <Penton@nowhere.com>
        coudn't spawn child process <jerome.schnitzler@t-online.de>
    Re: coudn't spawn child process (Rafael Garcia-Suarez)
    Re: Do Not Redirect CGI Questions To CIWAC <godzilla@stomp.stomp.tokyo>
        Enigma encryption <jonni@ifm.liu.nospam.se>
    Re: Enigma encryption (Anno Siegel)
    Re: Enigma encryption <simon.oliver@umist.ac.uk>
    Re: eval or not eval <pne-news-20011123@newton.digitalspace.net>
        Front End for Perl (GetWebWise)
    Re: Front End for Perl (Helgi Briem)
        Help me define PACK? <jazz450@hotmail.com>
    Re: Help me define PACK? nobull@mail.com
    Re: Help me define PACK? <bart.lateur@pandora.be>
    Re: How do I make several modules reference variables f (Sara)
        HTML::TreeBuilder  and HTML conversion to XHTML <newsg1@cglcomputer.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Nov 2001 21:01:34 +0300
From: Ilya Martynov <ilya@martynov.org>
Subject: [ANNOUNCE] HTTP::WebTest 1.07
Message-Id: <tvsham4nm6g6bf@corp.supernews.com>


The uploaded file

    HTTP-WebTest-1.07.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/I/IL/ILYAM/HTTP-WebTest-1.07.tar.gz
  size: 61156 bytes
   md5: e7ca9ad3eb3a6020f380ffc4e84d6436

NAME
    HTTP::WebTest - Test remote URLs or local web files

DESCRIPTION
    This module runs tests on remote URLs or local web files containing
    Perl/JSP/HTML/JavaScript/etc. and generates a detailed test report.

    The test specifications can be read from a parameter file or input as
    method arguments. If you are testing a local file, Apache is started on
    a private/dynamic port with a configuration file in a temporary
    directory. The module displays the test results on the terminal by
    default or directs them to a file. The module optionally e-mails the
    test results.

    Each URL/web file is tested by fetching it from the web server using a
    local instance of an HTTP user agent. The basic test is simply whether
    or not the fetch was successful. You may also test using literal strings
    or regular expressions that are either required to exist or forbidden to
    exist in the fetched page. You may also specify tests for the minimum
    and maximum number of bytes in the returned page. You may also specify
    tests for the minimum and maximum web server response time.

    If you are testing a local file, the module checks the error log in the
    temporary directory before and after the file is fetched from Apache. If
    messages are written to the error log during the fetch, the module flags
    this as an error and writes the messages to the output test report.

Changes since 1.06:

   * HTTP::WebTest now uses Config.pm to find correct shebang string
     for script 'wt'. It should correctly set path to perl interpreter
     even if perl is installed in non-standart place.

   * Added test parameter mail_from which allows to set From: header
     in report e-mails. Thanks Joe Germuska <Joe.Germuska@JGSullivan.com>
     for patch.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




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

Date: Fri, 23 Nov 2001 12:46:28 -0000
From: jmcnamara@cpan.org (John McNamara)
Subject: ANNOUNCE: Inline::Awk 0.03
Message-Id: <tvsh94mvjl62ab@corp.supernews.com>

================================================================================
NAME

    Inline::Awk - Add awk code to your Perl programs.


================================================================================
SYNOPSIS

    Call an awk function from a Perl program:

        use Inline AWK;

        hello("awk");

        __END__
        __AWK__

        function hello(str) {
            print "Hello " str
        }

    Or, call an entire awk program using the awk() function:

        use Inline AWK;

        awk(); # operates on @ARGV by default

        __END__
        __AWK__

        # Count the number of lines in a file
        END { print NR }


================================================================================
DESCRIPTION


    The Inline::Awk module allows you to include awk code in your
    Perl program. You can call awk functions or entire programs.

    Inline::Awk works by converting the awk code into Perl code
    using the a2p utility which comes as standard with Perl. This
    means that you don't require awk to use the Inline::Awk module.


================================================================================
CHANGES

    This is the first CPAN release.


================================================================================
INSTALLATION

    Use the standard installation procedure for any Perl module.

        perl Makefile.PL
        make
        make test
        make install

	ActivePerl users can use PPM as follows:

		C:\ppm
		PPM> set repository tmp
http://homepage.eircom.net/~jmcnamara/perl
		PPM> install Inline-Awk
		PPM> quit
		C:\>

	If this fails try the following:

		PPM>install
http://homepage.eircom.net/~jmcnamara/perl/Inline-Awk.ppd


================================================================================
AUTHOR

    John McNamara jmcnamara@cpan.org
--
perl -e 'use Inline AWK=>q+function j(){print"Just Another Awk
Hacker"}+;j'






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

Date: Mon, 19 Nov 2001 00:12:00 +0100
From: Michael Piotrowski <mxp@dynalabs.de>
Subject: ANNOUNCE: Lingua::Ident 1.4
Message-Id: <tvsh9vlgmg2lb6@corp.supernews.com>

I've just uploaded a new version of the Lingua::Ident module to CPAN.
This is a Perl module that provides statistical language
identification.

Version 1.4 is a maintenance release, fixing several grave bugs.  A
complete overhaul of Lingua::Ident is currently under way, but not yet
ready.

When it has migrated to its final destination, you should be able to
find it via
  
   <http://search.cpan.org/search?dist=Lingua-Ident-1.4>
  
It's also immediately available from
  
   <http://www.dynalabs.de/mxp/perl/Lingua-Ident-1.4.tar.gz>  
   <ftp://ftp.linguistik.uni-erlangen.de/pub/perl/Lingua-Ident-1.4.tar.gz>

-- 
Michael Piotrowski, M.A.                                  <mxp@dynalabs.de>




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

Date: Sat, 17 Nov 2001 22:58:39 +0900
From: miyagawa@bulklnews.net
Subject: ANNOUNCE: Log::Dispatch::Config
Message-Id: <tvsh9jftlmrmb1@corp.supernews.com>

Here I've finished the first version of Log4j for perl.

There already exists a great Logging module Log::Dispatch by Dave
Rolsky and I don't like reinventing the wheels, so my new module
Log::Dispatch::Config just optionally drives configuration parsing
functionality, which Log::Dispatch lacks, against Log4j.

It's now on its way to CPAN and can also be downloaded from:

  http://bulknews.net/lib/archives/Log-Dispatch-Config-0.01.tar.gz

  file: $CPAN/authors/id/M/MI/MIYAGAWA/Log-Dispatch-Config-0.01.tar.gz
  size: 4656 bytes
   md5: 8300cde5fcf0b8d5f254464434d2f73b


Any suggestionss are highly welcome. Thanks.

--

NAME
    Log::Dispatch::Config - Log4j for Perl

SYNOPSIS
      use Log::Dispatch::Config;
      Log::Dispatch::Config->configure('/path/to/config');

      my $dispatcher = Log::Dispatch->instance;

DESCRIPTION
    Log::Dispatch::Config provides a way to configure Log::Dispatch with
    configulation file (in AppConfig format). I mean, this is log4j for Perl,
    not with all API compatibility though.

METHOD
    This module has one class method `configure' which parses config file and
    declares `instance' method in Log::Dispatch namespace. So what you should
    do is call `configure' method once in somewhere (like `startup.pl' in
    mod_perl), then you can get configured dispatcher instance via
    `Log::Dispatch->instance'.

CONFIGURATION
    Here is an example of the config file:

      dispatchers = file screen

      file.class = Log::Dispatch::File
      file.min_level = debug
      file.filename = /path/to/log
      file.mode = append
      file.format = [%d] [%p] %m at %F line %L%n

      screen.class = Log::Dispatch::Screen
      screen.min_level = info
      screen.stderr = 1
      screen.format = %m

    Config file is parsed with AppConfig module, see the AppConfig manpage
    when you face configuration parsing error.

  GLOBAL PARAMETERS

    dispatchers
          dispatchers = file screen

        `dispatchers' defines logger names, which will be splitted by spaces.
        If this parameter is unset, no logging is done.

    format
          format = [%d] [%p] %m at %F line %L%n
          format = [${datetime}] [${prioity}] ${message} at ${filename} line ${line}\n

        `format' defines log format. `%X' style and `${XXX}' style are both
        supported. Possible conversions format are

          %d ${datetime}        datetime string
          %p ${priority}        priority (debug, indo, warn ...)
          %m ${message}         message string
          %F ${filename}        filename
          %L ${line}            line number
          %P ${package}         package
          %n                    newline (\n)

        `format' defined here would apply to all the log messages to
        dispatchers. This parameter is optional.

  PARAMETERS FOR EACH DISPATCHER

    Parameters for each dispatcher should be prefixed with "name.", where
    "name" is the name of each one, defined in global `dispatchers' parameter.

    class
          screen.class = Log::Dispatch::Screen

        `class' defines class name of Log::Dispatch subclasses. This parameter
        is essential.

    format
          screen.format = -- %m --

        `format' defines log format which would be applied only to the
        dispatcher. Note that if you define global `format' also, `%m' is
        double formated (first global one, next each dispatcher one). This
        parameter is optional.

    (others)
          screen.min_level = info
          screen.stderr = 1

        Other parameters would be passed to the each dispatcher construction.
        See Log::Dispatch::* manpage for the details.

SINGLETON
    Declared `instance' method would make `Log::Dispatch' class singleton, so
    multiple calls of `instance' will all result in returning same object.

      my $one = Log::Dispatch->instance;
      my $two = Log::Dispatch->instance; # same as $one

    See GoF Design Pattern book for Singleton Pattern.

    But in practice, in persistent environment like mod_perl, Singleton
    instance is not so useful. Log::Dispatch::Config defines `instance' method
    so that the object reloads itself when configuration file is modified
    since its last object creation time.

TODO
    *   LogLevel configuration depending on caller package like log4j?

AUTHOR
    Tatsuhiko Miyagawa <miyagawa@bulknews.net>

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

SEE ALSO
    the Log::Dispatch manpage, the AppConfig manpage






--
Tatsuhiko Miyagawa <miyagawa@bulknews.net>




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

Date: 20 Nov 2001 08:47:10 -0800
From: msergeant@star.net.uk (Matt Sergeant)
Subject: ANNOUNCE: XML::SAX::Simple
Message-Id: <tvsha8rfpchfbb@corp.supernews.com>

XML::SAX::Simple is a module that builds on top of the framework
provided by XML::SAX and XML::Simple, to give you a version of
XML::Simple that can work without XML::Parser, by using any PerlSAX2
parser installed on your system, including the PurePerl parser shipped
with XML::SAX.

The interface remains exactly the same as XML::Simple (because
XML::SAX::Simple extends from XML::Simple), so it is as simple as
saying:

  use XML::SAX::Simple qw(XMLin XMLout);
  my $config = XMLin("config.xml");

Enjoy!




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

Date: Fri, 23 Nov 2001 13:21:48 -0000
From: "Penton" <Penton@nowhere.com>
Subject: Checking Disk Space of Win NT Box from Linux with Perl
Message-Id: <9tlihd$ott$1@lyonesse.netcom.net.uk>

I want to check the disks and space on a Windows Server from a linux box
using Perl.  I have this running on an NT box using SRVINFO from the
resource kit but would really like to be able to do this from Linux.

Any one have any Ideas ?  I don't want to use the script that enters each
directory and checks the size.  This takes too long and I have about a dozen
servers to check.  The SRVINFO.EXE uses an RPC call to the server and I
would like to go the same way if possible.




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

Date: Fri, 23 Nov 2001 11:53:46 +0100
From: "Jerome Schnitzler" <jerome.schnitzler@t-online.de>
Subject: coudn't spawn child process
Message-Id: <9tl9s3$hme$02$1@news.t-online.com>

Hi Newsgroup!

Everytime I want to start a CGI-Script written in Perl on a Apache 1.3.22 I
get an error:

couldn't spawn child process

What's wrong? Than in advance

Bye

Jerome




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

Date: 23 Nov 2001 11:01:40 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: coudn't spawn child process
Message-Id: <slrn9vsb65.2si.rgarciasuarez@rafael.kazibao.net>

Jerome Schnitzler wrote in comp.lang.perl.misc:
> 
> Everytime I want to start a CGI-Script written in Perl on a Apache 1.3.22 I
> get an error:
> 
> couldn't spawn child process

This has nothing to do with Perl. You'd better ask in a newsgroup about
web servers. And include the full description of the error (apache is
usually a bit more verbose).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
use lib sub{$_=$_[1];y;_.mp; ,\n;d;print;
open+0;*0};require Just_another_Perl_hacker;1


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

Date: Fri, 23 Nov 2001 04:38:53 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Do Not Redirect CGI Questions To CIWAC
Message-Id: <3BFE435D.834A42BE@stomp.stomp.tokyo>

Randal L. Schwartz wrote:
 
> Godzilla! wrote:
 
> > I will state again what I have recently stated.
> > Do not redirect people with cgi questions to
> > the comp.infosystems.www.authoring.cgi group.

> Ahh yes.  The Consensus of One.

It would appear I am the only person who cares
enough to express concerns about the defunct and
barely operative cgi group.

 
> As a counter-suggestion, I propose that people continue the reasonably
> appropriate behavior of the status quo, which is to redirect people to
> a different group if the topic is appropriate.

This redirection to a broken newsgroup is a poor choice.
It makes no sense to redirect people to a group to which
they cannot post or have extreme difficulties posting.
Doing this is very rude and completely thoughtless.

Until the cgi group is correctly repaired by Boutell
and again under the authority of Boutell, none should
be redirected there.

 
> > Reasons for this are very apparent.

> Really?  Not apparent to me.

Inability to post to a group strikes me as a valid reason.
When I posted this article, the cgi group was down for
nearly a day. Very recently, the cgi group was down for
a month or more, two months for sure before people could
begin posting again, although with great difficulty.

Those are apparent reasons to those of moderate intelligence.


> CIWAC is functioning just fine, although the boutell-bot outage
> was a bit troublesome.

The cgi group does not work fine. During the past few months
its uptime is less than seventy percent. When posting is a
rare possibility, posting is difficult and plagued with problems.
My experience is an unacceptable amount of my articles never
make it to the cgi group. I suspect others experience this.

Evidencing this are a large number of posts made by people
trying to post to the cgi group, without true success.


> Sheila stepping in to provide a replacement was a very needed thing.

Sheila King is a poser. King took over the cgi group behind
the scenes, in secrecy. Boutell is fully responsible for
maintaining the cgi group. King is not authorized to operate
nor hold control of the cgi group.

Boutell has abandoned ship, shirked his responsibilities.
This poser, Sheila King, has effected a takeover of the
cgi group with blatant disregard for USENET traditions.


> > Anyone care to present an argument, a rational
> > argument having an auto-bot moderated newsgroup
> > is both a logical idea and a good idea?

> That topic is off-topic here.  And already discussed to death
> in CIWAC.  Please take your discussion *back* there.

This is not off-topic here. Frequent postings of cgi questions
to this group, is a dead on topic, a topic often used by regulars
here to verbally harass participants.

There has been no discussion of this problem in the cgi group.
Sheila King flatly refuses to discuss this topic and, a vast
majority of comments passed consist only of ignorant insults
and trolls posted by well known regulars from here.

 
> > I certainly have acted in a responsible manner
> > by investing a lot of time and effort into
> > trying to restore the cgi group. Have you?

> It's not a responsible manner to have brought it into a different
> arena.  It's also not a responsible manner to oppose the efforts of
> Sheila, who is doing a fine volunteer job of getting *some* form of
> moderating-bot up and running again to revive the group.

It is responsible to try to involve all those affected, in
discussions on what to do about the problem plagued cgi group.
Posting of cgi question here is a historical problem. However,
the real problem here is regulars using supposed cgi related
questions as a lame excuse to verbally harass others.

This is an issue which directly effects this group, quite clearly.

Sheila King did not volunteer. King has deliberately taken
advantage of irresponsible Boutell and now, quite literally,
rules the cgi group in a dictatorial manner.

 
> Changing the location of a bot is easy.  Changing a group from
> moderated to unmoderated is Very Very Difficult because of the
> lame admins out there.

I was recently suckered into posting an article to a USENET
administrator's newsgroup. My article content indicates the
best benefit USENET could enjoy would be immediate removal
of all USENET administrators and their network. USENET
administrators are a serious detriment to USENET.


> But you were told this already in that group.
 
No. Sheila King refuses to discuss these problems with the cgi
group and regulars from here and there, only post insulting
articles or troll articles. Only one or two people, besides me,
have actually discussed these serious problems. None, however,
have attempted to seriously discuss these problems other than
myself, solely; a concensus of one.


>   Don't bring the discussion here.  {sigh}


There is no discussion. There are none responsible
enough to discuss these problems, other than myself.
You personally have not bothered to engage in discussion
of these problems other than to post this troll article,
your only article related to the cgi group problems
which directly and significantly effect this group.

My presumption is you believe yourself to be in charge
of this group just as this poser Sheila King believes
himself to be in charge of the cgi group.


Godzilla!

-- 

 "Do not pay any attention to what Godzilla says. It is a troll,
  and has no decent working knowledge of Perl or programming in
  general. Search groups.google.com to see a history of its posts
  and replies to these posts."

     - The Poser


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

Date: Fri, 23 Nov 2001 08:06:25 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Enigma encryption
Message-Id: <9tksfu$1nd$1@news.island.liu.se>

 ... so what does that have to do with perl?

Ok. I've produced a script trying to crack a message encrypted by the enigma
encryption (used by Germans in Wold War 2). The problem is that the average
run time is 40-130 hours :(

So my question. Is there some nice module that can wrap my code to measure
where the bottlenecks are, and thus where the code optimization is most
needed. I know about the Benchmark module, but it would be nice to do the
measurments in the complete script. Any suggestions?
/jN

--
/jN




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

Date: 23 Nov 2001 08:54:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Enigma encryption
Message-Id: <9tl2rd$fhh$1@mamenchi.zrz.TU-Berlin.DE>

According to Jonas Nilsson <jonni@ifm.liu.nospam.se>:
>  ... so what does that have to do with perl?
> 
> Ok. I've produced a script trying to crack a message encrypted by the enigma
> encryption (used by Germans in Wold War 2). The problem is that the average
> run time is 40-130 hours :(
> 
> So my question. Is there some nice module that can wrap my code to measure
> where the bottlenecks are, and thus where the code optimization is most
> needed. I know about the Benchmark module, but it would be nice to do the
> measurments in the complete script. Any suggestions?

use Devel::DProf;

Anno


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

Date: Fri, 23 Nov 2001 09:06:26 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Jonas Nilsson <jonni@ifm.liu.nospam.se>
Subject: Re: Enigma encryption
Message-Id: <3BFE1192.E9D4CDF1@umist.ac.uk>

I've never used it but perhaps Devel::DProf - a Perl code profiler?

--
  Simon Oliver


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

Date: Fri, 23 Nov 2001 08:36:09 +0100
From: Philip Newton <pne-news-20011123@newton.digitalspace.net>
Subject: Re: eval or not eval
Message-Id: <djtrvts5rs6vmbpmcflspuhi94of0dva06@4ax.com>

On Thu, 22 Nov 2001 16:53:56 +0100, "felix" <mr.thanquol@gmx.de> wrote:

> I finally reached a point where I can't concentrate any more! I'm trying to
> read stuff from a config-file and put it in hashes and scalars

That wheel has been reinvented several times.

If you aren't tied to that particular config file format (e.g. if you
can live with "[WebSite]" instead of plain "WebSite"), you could use
Config::IniFiles, I believe.

Have a look around on CPAN (e.g. at http://search.cpan.org/ ), there
should be several modules like that.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 23 Nov 2001 11:17:22 GMT
From: getwebwise@aol.com (GetWebWise)
Subject: Front End for Perl
Message-Id: <20011123061722.27419.00001372@mb-fl.aol.com>

Not knowing very much about PERL, I am wondering if there is a front end
package available along the lines of Visual Basic or Delphi which can be used
to develop interactive perl/html interactive sites.


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

Date: Fri, 23 Nov 2001 11:41:13 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Front End for Perl
Message-Id: <3bfe3450.3118525683@News.CIS.DFN.DE>

On 23 Nov 2001 11:17:22 GMT, getwebwise@aol.com (GetWebWise)
wrote:

>Not knowing very much about PERL, I am wondering if there is a 
>front end package available along the lines of Visual Basic or 
>Delphi 

I use Perl Builder and like it ( www.solutionsoft.com).

Others have spoken well of Visual Perl,
( http://www.activestate.com/Products/Visual_Perl/ ).
I have never used it, but Activestate certainly
provides excellent distributions of Perl and its
modules.

Some like Komodo from the same company
( http://www.activestate.com/Products/Komodo/ )
How similar they are I don't know.

There is also something called CodeMagic Universal IDE
( http://www.downlinx.com/proghtml/105/10528.htm )
which I know nothing about,

>which can be used to develop interactive perl/html 
>interactive sites.

What's an "interactive perl/html interactive site"?
Can I have that with nachos?

These things are used for programming in Perl.
Perl can be used for an astounding variety of
things.

Regards,
Helgi Briem




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

Date: Wed, 21 Nov 2001 23:21:52 -0800
From: john <jazz450@hotmail.com>
Subject: Help me define PACK?
Message-Id: <C1250E6918A586ED.D487100C96735AF6.685BECF44F6EB886@lp.airnews.net>

Hi All,
I'm teaching myself perl and I'm going throught the Perl commands. I hit
Pack and I found I need some sage advice, cause this doesn't quite make
sense.

A couple of the examples in the Programming Perl book, Chapter 3,
3.2.105 pack,  are...
$out = pack "B32", "01010000011001010111001001101100";
$out = pack "H8", "5065726c";    # both produce "Perl"
I checked. They both do.

It seems B means binary data, and H means hex, from the template table.
The number SEEM to apply to the number of characters the template should
apply to.
$out = pack "H4", "5065726c";
# produces "Pe

The documentation says that PACK means "This function takes a list of
values and packs it into a binary structure."  If it's making binary
structrures, shouldn't the above $out values be filled with
"01010000011001010111001001101100"?

This is my questions...
What is pack do?  In the above example, it seems it's just a gizmo that
transforms data formats to strings.  Is that what it is?
What is it used for?




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

Date: Fri, 23 Nov 2001 08:46:50 GMT
From: nobull@mail.com
Subject: Re: Help me define PACK?
Message-Id: <u9wv0hdak5.fsf@wcl-l.bham.ac.uk>

john <jazz450@hotmail.com> writes:

> I'm teaching myself perl and I'm going throught the Perl commands. I hit
> Pack and I found I need some sage advice, cause this doesn't quite make
> sense.
> 
> A couple of the examples in the Programming Perl book, Chapter 3,
> 3.2.105 pack,  are...
> $out = pack "B32", "01010000011001010111001001101100";
> $out = pack "H8", "5065726c";    # both produce "Perl"
> I checked. They both do.
> 
> It seems B means binary data, and H means hex, from the template table.

Yep.

> The number SEEM to apply to the number of characters the template should
> apply to.

In the case of H and B it is.  In some other cases it's the number of
elements in the input list.

> $out = pack "H4", "5065726c";
> # produces "Pe
> 
> The documentation says that PACK means "This function takes a list of
> values and packs it into a binary structure."  If it's making binary
> structrures, shouldn't the above $out values be filled with
> "01010000011001010111001001101100"?

No, that's the ASCII representation of a binary number.

In computing when we say a "binary structure" we mean a chunk of
memory where the bits and bytes are being used directly to store
values directly rather than being used to store a string represening
the value.

> What is pack do?

See "perldoc -f pack"

> In the above example, it seems it's just a gizmo that
> transforms data formats to strings.

Not strings, binary strucutres.

If the examples above the binary structures happen to be such that
they can meaningfully be treated as text.  This was just for the sake
of the examples.  It is not generally the case.

> What is it used for?

Writing non-text format files.

Constructing messages for non-text-based network protocols (e.g. in
Net::DNS).

Constructing parameters to pass to functions (or operating system
calls) written in other languages (particularly C).

Incidently the H and B formats are more often of real use with
unpack() rather than pack() which may be why you were having trouble
seeing what pack() was good for.

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


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

Date: Fri, 23 Nov 2001 12:27:47 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Help me define PACK?
Message-Id: <pjfsvt4hceofcuib3p87thuukabe6utg9m@4ax.com>

john wrote:

>A couple of the examples in the Programming Perl book, Chapter 3,
>3.2.105 pack,  are...
>$out = pack "B32", "01010000011001010111001001101100";
>$out = pack "H8", "5065726c";    # both produce "Perl"
>I checked. They both do.
>
>It seems B means binary data, and H means hex, from the template table.
>The number SEEM to apply to the number of characters the template should
>apply to.
>$out = pack "H4", "5065726c";
># produces "Pe

Yes.

Don't be fooled by the fact that the result here turns out to be a
readable string. That is an exception. It's just that "50" represents
the character code (Ascii code) of "P" in hex, and "01010000" idem ditto
in binary.

>The documentation says that PACK means "This function takes a list of
>values and packs it into a binary structure."  If it's making binary
>structrures, shouldn't the above $out values be filled with
>"01010000011001010111001001101100"?

No. That's a string representation of the desired binary format. In
general, pack() makes a more compact format of the data you supplied,
hence the name. (I'm not sure, but it makes for a nice mnemonic aid).
unpack() does the reverse.

>This is my questions...
>What is pack do?  In the above example, it seems it's just a gizmo that
>transforms data formats to strings.  Is that what it is?

It does turn data into "strings", but as I said, generally these aren't
readable strings. Instead, it makes a string of *bytes*. What it does,
is turn high level data, such as a number, into a binary representation
of that dat. For example:

	$struc = pack "N", 123456;

turns the number into a 4-byte, big endian, binary representation of the
integer.

>What is it used for?

Generally, for turning perl data into something you can save to a binary
file (don't forget binmode()), and unpack() for getting such data, for
example, from a TIFF image file. These form a general interface layer
between your program, and binary files from the outside world. Or, for
example, for building binary structures which can then be passed to API
calls to the OS, for example using Win32::API on Windows.

-- 
	Bart.


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

Date: 23 Nov 2001 05:24:03 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: How do I make several modules reference variables from one file?
Message-Id: <776e0325.0111230524.133f7ae3@posting.google.com>

john <jazz450@hotmail.com> wrote in message news:<99CB451DC872FDED.B64C34114294EC16.D2B8E458022B2BD1@lp.airnews.net>...
> Hi All, thanks for the help.
> I found
> http://search.cpan.org/doc/JHI/perl-5.7.2/lib/Exporter.pm
> and it had a lot of good stuff.
> I found that $temp = $Site::Config::config{'key'}; works only when there
> only one package by that name.
> I inherited two files, "config.pm" and "site_config.pm.".  Both were titled
> "package Site::Config;".  Once I realized that and commented out the
> site_config.pm's package name, I was able to call variables.
> 
> 
> >

Exporter is a nice module that offers the allows classes to share
methods, but in most cases I think it reduces maintainabilty and makes
it more difficult to trace execution. If you full quality your
objects, it's easier to go back later and figure out what's calling
what. Exporter gives you the freedom to NOT name the class in an
object reference, which can lead to ambiguity you may later regret.

Just an opinion.

-GX


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

Date: Fri, 23 Nov 2001 07:47:11 +0200
From: "CGL" <newsg1@cglcomputer.com>
Subject: HTML::TreeBuilder  and HTML conversion to XHTML
Message-Id: <3bfe45ce$1@ermis.spidernet.net>

Hello,

I am using HTML::TreeBuilder to parse HTML documents and (hopefully) convert
them to XHTML.
I am having trouble "fixing" bad nested tags (ie <p><b>here</p></b>). Is
there a way to identify
these tags using the above module?

Any help is much appreciated.
CGL




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

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


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