[21969] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4191 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 27 21:06:03 2002

Date: Wed, 27 Nov 2002 18:05:11 -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, 27 Nov 2002     Volume: 10 Number: 4191

Today's topics:
        .cpan dir <darkage@freeshellzzzz.org>
    Re: .cpan dir <nospam@nospam.com>
        ANNOUNCE: DBD::Pg 1.20 (David Wheeler)
        ANNOUNCE: Games::Object v0.05 <p.stewart@attNOSPAMbi.com>
    Re: beginner in perl <regus_nospam@pandora.be>
    Re: beginner in perl <jurgenex@hotmail.com>
    Re: CGI.pm table question <nobody@dev.null>
    Re: Getopt::Std - more info. <krahnj@acm.org>
        grepmail 4.90 released <david@coppit.org>
        help with regexp: exclude \. from the \w group? <khowe@perfnet.ca>
    Re: help with regexp: exclude \. from the \w group? <khowe@perfnet.ca>
    Re: help with regexp: exclude \. from the \w group? <perl-dvd@ldschat.com>
    Re: help with regexp: exclude \. from the \w group? (Tad McClellan)
    Re: how to call an external script and using the env-de <mgjv@tradingpost.com.au>
    Re: instantiating HTML::TokeParser with scalar from LWP <tassilo.parseval@post.rwth-aachen.de>
        Modules Hurting My Head, Help Please. (Bryon Black)
        numbering forms (flinky)
    Re: numbering forms <cpryce@pryce.net>
    Re: numbering forms (Walter Roberson)
        perl module path problem (Urmi)
    Re: perl module path problem <gaverth@comcast.net>
    Re: Question about IO::Socket Usage... <goldbb2@earthlink.net>
        reg expression question <nlilly@slis.kent.edu>
    Re: reg expression question <holland@origo.phys.au.dk>
    Re: reg expression question (Malcolm Dew-Jones)
    Re: scripts run by cron.sh script can't open files <mgjv@tradingpost.com.au>
    Re: scripts run by cron.sh script can't open files <tomweeks@charter.net>
    Re: split binary data <nojima@taito.co.jp>
        strange glob error (Scott Stark)
    Re: strange glob error <krahnj@acm.org>
    Re: strange glob error (Tad McClellan)
    Re: Windows multiple process questions with either Win3 <Graham.T.Wood@oracle.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 28 Nov 2002 10:32:46 +1100
From: "^darkage" <darkage@freeshellzzzz.org>
Subject: .cpan dir
Message-Id: <as3kmu$2f5$1@perki.connect.com.au>

Is is safe to delete the ~/.cpan dir under ones home directory?  or does it
require that dir as a library of some sort?





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

Date: Wed, 27 Nov 2002 16:02:47 -0800
From: "Tan D Nguyen" <nospam@nospam.com>
Subject: Re: .cpan dir
Message-Id: <as3mcj$ni3v1$1@ID-161864.news.dfncis.de>


"^darkage" <darkage@freeshellzzzz.org> wrote in message
news:as3kmu$2f5$1@perki.connect.com.au...
> Is is safe to delete the ~/.cpan dir under ones home directory?  or does
it
> require that dir as a library of some sort?
The directory is created when you install CPAN modules via CPAN module (ie.
installing directly from the internet). You can remove it but it'll be
created next time to install modules directly from CPAN site. It serves as a
placer holder for packages , build directory etc. so Perl doesn't need it.




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

Date: 27 Nov 2002 12:34:30 -0800
From: david@wheeler.net (David Wheeler)
Subject: ANNOUNCE: DBD::Pg 1.20
Message-Id: <3de56f85$1_5@news.teranews.com>

The uploaded file

    DBD-Pg-1.20.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/D/DW/DWHEELER/DBD-Pg-1.20.tar.gz
  size: 75821 bytes
   md5: ea9e217321fb62515b3723a86ecbfcdf


This is the first release under new management at GBorg. Here's a list
of changes in the new version, along with attributions:

1.20  Wed Nov 27 16:19:26 2002
      - Maintenance transferred to GBorg,
        http://gborg.postgresql.org/project/dbdpg/projdisplay.php.
Incremented
        version number to reflect new management. [Bruce Momjian]
      - README cleaned up. [Bruce Momjian]
      - Added t/15funct.t, a series of tests that determine if the
meta data
        is working. [Thomas Lowery]
      - Added implementations of column_info() and table_info(), and
        primary_key_info(). [Thomas Lowery]
      - The POD formatting was cleaned up. [David Wheeler]
      - The preparser was updated to better handle escaped characters.
[Rudy
        Lippan]
      - Removed redundant use of strlen() in pg_error() (Jason E.
Stewart).
      - Test suite cleaned up, converted to use Test::More, and
updated to use
        standard DBI environment variables for connecting to a test
database.
        [Jason E. Stewart]
      - Added eg/lotest.pl as a demonstration of using large objects
in buffers
        rather than files. Contributed by Garth Webb.
      - Added LISTEN/NOTIFY functionality. Congributed by Alex
Pilosov.
      - Added constants for common PostgreSQL data types, plus simple
tests to
	make sure that they work. These are exportable via "use DBD::Pg
	qw(:pg_types);". [David Wheeler]
      - Deprecatated the undocumented (and invalid) use of SQL_BINARY
in
	bind_param() and documented the correct approach: "bind_param($num,
	$val { pg_type => PG_BYTEA });". Use of SQL_BINARY in bind_param()
will
        now issue a warning if $h->{Warn} is true. [David Wheeler]
      - Removed invalid (and broken) support for SQL_BINARY in
quote(). [David
	Wheeler]
      - Added App::Info::RDBMS::PostgreSQL to the distribution (but it
won't
        be installed) to help Makefile.PL find the PostgreSQL include
and
        library files. [David Wheeler]
      - Fixed compile-time warnings. [David Wheeler and Jason E.
Stewart]

Enjoy!

David

-- 
David Wheeler                                     AIM: dwTheory
david@wheeler.net                                 ICQ: 15726394
http://david.wheeler.net/                      Yahoo!: dew7e
                                               Jabber:
Theory@jabber.org




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

Date: Thu, 28 Nov 2002 01:21:50 GMT
From: "Peter J. Stewart" <p.stewart@attNOSPAMbi.com>
Subject: ANNOUNCE: Games::Object v0.05
Message-Id: <3de56f9e$1_4@news.teranews.com>

This is to announce the next version of Games::Object. Below is a
snippet from the manpage describing the module. Those familiar with
the module already can jump down to the CHANGES section for info
relevant to this release.

Games::Object can be found on search.cpan.org

Pete


NAME
        Games::Object - Provide a base class for game objects

SYNOPSIS
            package YourGameObject;
            use Games::Object;
            use vars qw(@ISA);
            @ISA = qw(Games::Object);

            sub new {
                # Create object
                my $proto = shift;
                my $class = ref($proto) || $proto;
                my $self = $class->SUPER::new(@_);
                bless $self, $class;

                # Add attributes
                $self->new_attr(-name => "hit_points",
                                -type => 'int',
                                -value => 20,
                                -tend_to_rate => 1);
                $self->new_attr(-name => "strength",
                                -type => 'int',
                                -value => 12,
                                -minimum => 3,
                                -maximum => 18);
                ...

                return $self;
            }

            ...

            1;

ABSTRACT
        The purpose of this module is to allow a programmer to
        write a game in Perl easily by providing a basic framework
        in the form of a module that can be either subclassed to a
        module of your own or used directly as its own object
        class. The most important items in this framework are:

        Attributes
            You can define arbitrary attributes on objects with
            rules on how they may be updated, as well as set up
            automatic update of attributes whenever the object's
            "process()" method is invoked. For example, you could
            set an attribute on an object such that:

            -   It ranges from 0 to 100.

            -   Internally it tracks fractional changes to the
                value but accessing the attribute will always
                round the result to an integer.

            -   It will automatically tend towards the maximum by
                1 every time "process()" is called on the object.

            -   A method in your subclass will be invoked automat­
                ically if the value falls to 0.

            This is just one example of what you can do with
            attributes.

        Flags
            You can define any number of arbitrarily-named flags
            on an object. A flag is a little like a boolean
            attribute, in that it can have a value of either true
            or false. Flags can be added to the overall "universe"
            in which your objects exist such that new objects cre­
            ated automatically get certain flags set.

        Load/Save functionality
            Basic functionality is provided for saving data from
            an object to a file, and for loading data back into an
            object. This handles the bulk of load game / save game
            processing, freeing the programmer to worry about the
            mechanics of the game itself.

            The load functionality can also be used to create
            objects from object templates.  An object template
            would be a save file that contains a single object.

        It should be noted that many of the features of this mod­
        ule have definitely been geared more towards RPG, strat­
        egy, and D&D-like games. However, there is enough generic
        functionality for use in many other genres. Suggestions at
        ways to add more generalized functionality are always wel­
        come.

CHANGES
        The current version is 0.05 (alpha). The following are the
        changes from last version:

        -   A new option has been added to force processing of
            objects in a more deterministic fashion when the pri­
            orities are the same.

        -   Fixed an incorrect assumption in the event.t module
            that was causing bogus test failures under Perl 5.8.0.
            Thanks to the diligent CPAN testers for finding this.

        -   Persistent modifiers can now be forced to take effect
            immediately rather than the next time the object is
            processed. This change helps alleviate the timing
            issue that arises in the process() call.

        -   Fixed a few errors in some of the code examples in the
            POD doc. Thanks to Bryce Harrington for pointing these
            out.

        -   The track option is now implemented (it actually was
            implemented all along, but ... well, it's a long
            story).

        -   What was previously indicated as a bug with regards to
            persistent modifiers and self-limited attributes is
            simply a consequence of the options used on the
            attributes. An extra subsection has been added to bet­
            ter explain the interaction.

        -   Objects can be parented to one another to allow inher­
            itance of attribute values not explicitly set on child
            object. This allows a game programmer to create object
            classes and reduce memory consumption for shared
            attributes.

        -   The author's email address has changed. Please make a
            note of it at the end of this document

[new email same as one in header of this post, sans anti-spam text]




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

Date: Wed, 27 Nov 2002 20:44:12 GMT
From: "regus" <regus_nospam@pandora.be>
Subject: Re: beginner in perl
Message-Id: <w8aF9.23414$Ti2.4767@afrodite.telenet-ops.be>

Ok, thanks a lot for the response

Bart

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnaua2tb.3c7.tadmc@magna.augustmail.com...
> regus <regus_nospam@pandora.be> wrote:
>
> > I'm a beginner in Perl. I have written a simple script. Now i want it to
run
> > each day once, for example each morning How can i do that in perl ?
>
>
> Get up each morning and type the name of the program at
> a command prompt.   :-)
>
>
>
> What you are asking for is the job of the Operating System,
> not the job of a programming language.
>
> You have an OS question, not a Perl question.
>
> Ask in an OS newsgroup such as:
>
>    comp.os.linux.*
>    comp.os.ms-windows.*
>    comp.os.apple
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Thu, 28 Nov 2002 00:29:11 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: beginner in perl
Message-Id: <rrdF9.49826$mL2.5347@nwrddc01.gnilink.net>

regus wrote:
> I'm a beginner in Perl. I have written a simple script. Now i want it
> to run each day once, for example each morning How can i do that in
> perl ?

While there are ways to do this in Perl all of them are more of less
awkward.
Why can't you simply use the scheduler from your operating system? The
scheduler is designed to do scheduling, Perl is not.

jue




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

Date: Wed, 27 Nov 2002 21:18:36 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: CGI.pm table question
Message-Id: <3DE53652.3020103@dev.null>



Art Werschulz wrote:

> Hi.
> 
> How can one use CGI.pm to produce the tag "<table border>"?
> Printing $cgi->start_table(-border->undef) only produces "<table>".


print $cgi->start_table({-border=>undef});

will produce

<table border>, which, let me point out, is bogus HTML.




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

Date: Wed, 27 Nov 2002 19:13:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Getopt::Std - more info.
Message-Id: <3DE51942.34D7A9E3@acm.org>

qanda wrote:
> 
> Thanks for all the replies but I'm still confused.
> I thought of using @ARGV but still don't see how I can KNOW when I
> have the extra argument, ARGV seems to change after getopts.

Yes it does.  getopts removes all valid arguments from @ARGV.


> Here's a sample script. (critism appreciated - come from C background
> - still learning perl).  Sorry for the length, I've cut out most of
> the comments and body to keep it shorter.
> 
> *** START OF SCRIPT ***
> 
> #!/usr/bin/perl -w
> 
> use warnings;
> use strict;
> 
> use vars qw( $arg_a $arg_b $ec );

Ick.  Would you use global variables in your C programs?


> init();
> parse_args();
> 
> # Use end block to set exit value for program.
> END
> {
>     $? = $ec;
> }

Is there any reason that you can't just use "exit $ec" in the
appropriate places?


> # Initialise global exit code.
> sub init
> {
>     $ec = 0;
> }
> 
> sub usage($)
> {
>     $ec = $_[0];

[snip]

> EOF
>     }
> }
> 
> sub parse_args
> {
>     use Getopt::Std;
>     our( $opt_a, $opt_b, $opt_h, $opt_m );
> 
>     # Print usage if we have no arguments.
>     if( @ARGV == 0 )
>     {
>         print STDERR "Arguments are mandatory.\n";
>         usage(1);
>     }
> 
>     # Print usage if we have invalid options.
>     getopts('a:b:hm') or usage(2);

getopts() has now removed all valid options from @ARGV.

      if ( @ARGV ) { # or @ARGV != 0
          print STDERR "Extra arguments found.\n";
          usage( 7 );
      }


>     # Print usage if we have help option.
>     if( defined $opt_h )
>     {
>         usage(3);
>     }

[snip]



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 28 Nov 2002 00:32:51 GMT
From: David Coppit <david@coppit.org>
Subject: grepmail 4.90 released
Message-Id: <3de56f91$1_1@news.teranews.com>

Description:
- grepmail is a Perl program that searches a normal or compressed mailbox
  (gzip, bzip2, or tzip) for a given regular expression and returns those
  emails that match the query. It also supports searches constrained by date
  and size.

Download:
- You can download grepmail 4.90 from CPAN:
  http://www.cpan.org/authors/id/D/DC/DCOPPIT/grepmail-4.90.tar.gz
- Until the file propagates to the mirrors, you can use the following URL:
  http://prdownloads.sourceforge.net/grepmail/grepmail-4.90.tar.gz

Changes:
- Made Mail::Folder::SlowReader object-oriented
- Removed FastReader from distribution. (It's no longer faster! Also, I
  couldn't integrate it easily with the new object-oriented reader
  design.)
- Fixed a bug where in some cases emails were not being converted to mbox
  format before being printed
- Made searches involving header-related constraints a bit faster
- Added missing documentation for -F flag
- Added -f flag to search based on message status. (Feature suggestion by
  Richard D Alloway)
- Fixed a bug where -X and -Y flags after a pattern would not be processed
- Added experimental caching capability, which is perhaps 5% slower the
  first time you run grepmail on a mail folder, and 10-20% faster on
  subsequent runs. The cache is stored in ~/.grepmail-cache. You must edit
  the grepmail file and set $USE_CACHING to true to use this feature.
  (Idea and initial patch by terry jones)

See the README for additional notes on caching, complex queries, and
generation of message IDs.

A complete change log is at:
- http://grepmail.sourceforge.net/CHANGES

Thanks,
David

_____________________________________________________________________
David Coppit                           david@coppit.org
The College of William and Mary        http://coppit.org/

One thing the blues ain't... is funny. Stephen Stills, "Black Queen"




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

Date: Wed, 27 Nov 2002 20:49:16 GMT
From: "Kevin Howe" <khowe@perfnet.ca>
Subject: help with regexp: exclude \. from the \w group?
Message-Id: <gdaF9.172929$oRV.154156@news04.bloor.is.net.cable.rogers.com>

I have a regexp that parses out variable names of a particular format:

Format: VAR.x
Example string: My name is VAR.firstname VAR.lastname.
Result: My name is Kevin Howe

The regexp used to match VAR.x is: (^|.)(VAR)\.(\w*)(\W|$)

However, I would like to allow a nested variable format, i.e. VAR.x.x (or
VAR.x.x.x.x etc.).

This introduces a problem when trying to identify where the match ends. \W
won't work anymore because the period \. is a non-word, so it stops at the
first period. I need it to be able to "see past" or exclude the periods. I
attempted this:

(^|.)(LISTS)\.(\.|\w)*(\W?\.|$)

Which I though would tell it to match \w OR \., and end when it hit a noword
character \W that was not equal to \.

However, there is something I'm missing. Is it possible to exclude the \.
from the \w set of characters, or is there a regexp I can use that would do
what I am looking for?

- Kevin




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

Date: Wed, 27 Nov 2002 20:52:37 GMT
From: "Kevin Howe" <khowe@perfnet.ca>
Subject: Re: help with regexp: exclude \. from the \w group?
Message-Id: <pgaF9.172932$oRV.157146@news04.bloor.is.net.cable.rogers.com>

> exclude \. from the \w group

That should have been exclude \. from the \W group, sorry.
The idea is to have it stop when it hits any \W character, *with the
exception* of \.

- Kevin




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

Date: Wed, 27 Nov 2002 14:13:33 -0700
From: "David" <perl-dvd@ldschat.com>
Subject: Re: help with regexp: exclude \. from the \w group?
Message-Id: <5taF9.13734$EY.11181@fe01>

"Kevin Howe" <khowe@perfnet.ca> wrote in message
news:gdaF9.172929$oRV.154156@news04.bloor.is.net.cable.rogers.com...
> I have a regexp that parses out variable names of a particular format:
>
> Format: VAR.x
> Example string: My name is VAR.firstname VAR.lastname.
> Result: My name is Kevin Howe
>
> The regexp used to match VAR.x is: (^|.)(VAR)\.(\w*)(\W|$)
>
> However, I would like to allow a nested variable format, i.e. VAR.x.x
(or
> VAR.x.x.x.x etc.).
>
> This introduces a problem when trying to identify where the match
ends. \W
> won't work anymore because the period \. is a non-word, so it stops at
the
> first period. I need it to be able to "see past" or exclude the
periods. I
> attempted this:
>
> (^|.)(LISTS)\.(\.|\w)*(\W?\.|$)
>
> Which I though would tell it to match \w OR \., and end when it hit a
noword
> character \W that was not equal to \.
>
> However, there is something I'm missing. Is it possible to exclude the
\.
> from the \w set of characters, or is there a regexp I can use that
would do
> what I am looking for?


Well, if your looking to say allow periods, but not any other non word
character, perhaps you should put something like this:

/VAR\.([\w\.]+)/

What your saying with this is find a "VAR." then give my any word or .
characters until we come a cross a character that does not match this
criteria.  You don't have to specify a \W because by default regular
expressions are greedy, so it will take as much as it possibly can.

Did this answer your question to the full, or did you need more info?

Regards,
David







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

Date: Wed, 27 Nov 2002 17:19:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: help with regexp: exclude \. from the \w group?
Message-Id: <slrnauaknf.45n.tadmc@magna.augustmail.com>

Kevin Howe <khowe@perfnet.ca> wrote:

> I have a regexp that parses out variable names of a particular format:


There are many templating systems already invented.

You should give serious consideration to using an existing
one rather than develop yet another templating system...


> Format: VAR.x
> Example string: My name is VAR.firstname VAR.lastname.
                                                       ^
                                                       ^
> Result: My name is Kevin Howe
                              ^^
                              ^^ what happened to that last dot?

> The regexp used to match VAR.x is: (^|.)(VAR)\.(\w*)(\W|$)
                                     ^^^^^            ^^^^^^

You don't need either of those parts. They will not change
what is matched (unless you have newlines in the middle
of your string).

The first one requires that there be a character before VAR
or that there be no characters before VAR. That will always
be true.

The last one is not needed because the greedy \w* will keep
going until it hits a \W char or hits end of string.

You probably don't want to match "VAR." in "VAR. stuff",
so change the \w* to \w+.

What is the point of remembering the (VAR) constant?


> However, I would like to allow a nested variable format, i.e. VAR.x.x (or
> VAR.x.x.x.x etc.).


That isn't really "nested".


> This introduces a problem when trying to identify where the match ends.


Why do you need to indentify where the match ends?

Just let it end "naturally", no need to check for any particular
condition after the part that you are interested in.


> is there a regexp I can use that would do
> what I am looking for?


   /(VAR)\.(\w+(?:\.\w+)*)/g


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


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

Date: Wed, 27 Nov 2002 21:57:49 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: how to call an external script and using the env-definitions?
Message-Id: <slrnauag3d.mmn.mgjv@verbruggen.comdyn.com.au>

On Wed, 27 Nov 2002 09:54:42 +0100,
	Michael Kirchner <michael.kirchner@unibw-muenchen.de> wrote:

> Up to now I used for automatic processing via crontab a shell-script 
> which calls the start-script with the command ". $HOME/foo_start". Due 
> to the dot ". " no new (child) shell has been started for execution the 
> start-script and it was possible to use the new defined 
> environment-variables afterwards in my own script for automatic 
> processing. Fine.
> Now the problem:
> It is necessary to rewrite my script for automatic processing in perl 
> but it is not possible to rewrite the start-script. How can I call the 
> start-script form perl without starting a child-shell, so that I can use 
> the environment-definitions afterwards?

Also see the other replies.

\begin{offtopic}

The way this is often solved in situations where you cannot easily
rewrite the scripts that set up the environment (as in third party
software that could get updated frequently), is by writing a little
wrapper shell script that sources the environment and then executes
your shell program:

#!/usr/bin/ksh

 . /path/to/setup_environment/script
/path/to/your/perl_program


and call that from cron.

\end{offtopic}

Although, in your case, the shell script seems to be under your
control (it's in your home directory), so why not rewrite it as a
Perl source?

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | What's another word for Thesaurus?
                        | 


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

Date: 27 Nov 2002 19:39:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: instantiating HTML::TokeParser with scalar from LWP
Message-Id: <as3714$9s4$1@nets3.rz.RWTH-Aachen.DE>

Also sprach George Matthew:

> Config is ActivePerl 5.6.1 Build 633 on Windows XP Home. LWP version is 5.64
> as recommended in Burke's book "Perl and LWP". Chapter 2, Section 7 of said
> tome states:
> 
> "Create a token stream object using one of these two constructors:
> my $stream = HTML::TokeParser->new($filename)
>|| die "Couldn't read HTML file $filename: $!";
> or:
> my $stream = HTML::TokeParser->new( \$string_of_html );"
> 
> My code uses the second form of constructor:
> 
> use strict;
> use LWP;
> use HTML::TokeParser;
> use constant BATCH_SIZE => 1;
> my $names_url = http://www.kleimo.com/random/name.cfm;
> my $scraper = LWP::UserAgent->new;
> for (my $i=0; $i < BATCH_SIZE; $i++)
> {
>   my $names_html = $scraper->post($names_url,
>   [
>   "type" => "3",
>   "obscurity" => "1",
>   "number" => "30",
>   "GO" => "Generate Random Name(s)"
>   ]);
>   die "Error: ", $names_html->status_line, "\n"
>     unless $names_html->is_success;
>   my $parser = HTML::TokeParser->new( \$names_html ) || die $!;
>   while(my $token = $parser->get_token)
>   {
>   ; #results in error regardless of being NOOP or not
>   }
> }
> 
> This results in the message "Not a GLOB reference at
> C:/Perl/site/lib/HTML/PullParser.pm line 71", but does not die if I entirely
> get rid of the while block, which, however, is the whole point ;) Regarding
> the second form of TokeParser constructor, the docs say:
> 
> "If the argument is a reference to a plain scalar, then this scalar is taken
> to be the literal document to parse. The value of this scalar should not be
> changed before all tokens have been extracted."

"Literal document to parse" means it is the html-source as a plain
string. In your example $names_html is actually a HTTP::Response object.
That means, you first need to extract the html from the response (I
think calling the content() method on $names_html should do that) and
pass this as reference to the HTML::TokeParser constructor.

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: 27 Nov 2002 17:02:30 -0800
From: bryon@blacklambrocks.com (Bryon Black)
Subject: Modules Hurting My Head, Help Please.
Message-Id: <1de7ee90.0211271702.16f861ae@posting.google.com>

Hi,

Well, I'm trying my hand at building modules and getting very
confused. I could use some help with answering these questions: A.)
True or not true; a module need not be in the @INC array if the module
is in either the same directory or sub-directories of the script using
them. For instance, if in my script I have:

use ShowTime::ShowTimeDB::Connection;

Then in the directory containing my script I have a directory named
ShowTime, a sub-directory of that named ShowTimeDB containing a file
named Connection.pm. In my Connection.pm file I have:

package ShowTimeDB::Connection;

My problem is that from my windows machine this structure seems to
work fine. When I upload this structure to a UNIX machine, it works
fine but only assuming that I execute the the script from the
directory of the script. If I try to execute the script from another
directory (or from the web, which is really where the script will be
used) I get an error stating:

BEGIN failed--compilation aborted at ../cgi-bin/email_list_join.pl
line 3.

which is where the statement use ShowTime::ShowTimeDB... occurs, or
from the web I simply get a 500 error.

If anyone can help to explain what I'm doing wrong I would sincerely
appreciate it.

Thanks,
Bryon Black


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

Date: 27 Nov 2002 11:32:06 -0800
From: alanluc@rogers.com (flinky)
Subject: numbering forms
Message-Id: <9b921b8d.0211271132.1c7732f5@posting.google.com>

I would like to have forms submitted from the web site
that have sequential tracking numbers. I can easily create the forms that
will post the data that they want, but how can I increment and post a number
with each submitted form?


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

Date: Wed, 27 Nov 2002 13:37:18 -0600
From: cp <cpryce@pryce.net>
Subject: Re: numbering forms
Message-Id: <BA0A7B0E.12838%cpryce@pryce.net>

in article 9b921b8d.0211271132.1c7732f5@posting.google.com, flinky at
alanluc@rogers.com wrote on 11/27/02 1:32 PM:

> I would like to have forms submitted from the web site
> that have sequential tracking numbers. I can easily create the forms that
> will post the data that they want, but how can I increment and post a number
> with each submitted form?

Maybe the answer in perldoc -q increment will help. Alternatively, view it
online at: 
http://www.perldoc.com/perl5.6.1/pod/perlfaq5.html#I-still-don't-get-locking
 .--I-just-want-to-increment-the-number-in-the-file.--How-can-I-do-this-

cp



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

Date: 27 Nov 2002 22:05:17 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: numbering forms
Message-Id: <as3fit$nl9$1@canopus.cc.umanitoba.ca>

In article <9b921b8d.0211271132.1c7732f5@posting.google.com>,
flinky <alanluc@rogers.com> wrote:
:I would like to have forms submitted from the web site
:that have sequential tracking numbers. I can easily create the forms that
:will post the data that they want, but how can I increment and post a number
:with each submitted form?

I don't mean to sound rude, but this is essentially the same question
you asked yesterday, and you don't appear to have taken into account
the several replies that were posted, some of which gave explicit
answers. Please review the previous replies and either use the
solutions contained there, or answer the requests for clarifications
already posted. 

If your site has lost the replies, you can review them at
http://groups.google.ca/groups?hl=en&lr=&ie=UTF-8&threadm=9b921b8d.0211261238.2f3bd33c%40posting.google.com

--
   Sub-millibarn resolution bio-hyperdimensional plasmatic space
   polyimaging is just around the corner.   -- Corry Lee Smith



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

Date: 27 Nov 2002 15:09:40 -0800
From: ugupta@uiuc.edu (Urmi)
Subject: perl module path problem
Message-Id: <6336f590.0211271509.35789e2d@posting.google.com>

Hi,
I'm new to the use of perl modules.  
I want to run a perl module called NetGeoClient.pm .  More precisely,
I want to call the method: getRecord provided in this module.  The
sysadmins at my university has installed the Perl API for me since I
don't have access to certain library directories it uses.

Now, The README documentation for NetGeo instructs:
*********************************************************
Perl Usage 
-----
$recordRef = $netgeo->getRecord( $identifier );
*********************************************************

So I create a test file inside the directory that NetGeoClient.pm is
in.
The contents of test are as follow:
********************************
#!/usr/bin/perl -w
use strict;
use NetGeoClient;

my $recordRef = $netgeo->getRecord("192.172.226.30");
print "$recordRef\n";
*********************************************************

But when I run the test file, it doesn't seem to be able to locate
NetGeoClient.pm . It keeps giving me the error message:

Global symbol "$netgeo" requires explicit package name at ./test line
5.
Execution of ./test aborted due to compilation errors.

I figure something is wrong with the path variable.
Can I fix this from within test?
Thanks in advance for any help!
Urmi


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

Date: Wed, 27 Nov 2002 18:43:34 -0500
From: "Tim Gaverth" <gaverth@comcast.net>
Subject: Re: perl module path problem
Message-Id: <CyidnX2HdYYAxXigXTWc3w@comcast.com>


"Urmi" <ugupta@uiuc.edu> wrote in message
news:6336f590.0211271509.35789e2d@posting.google.com...
> Hi,
> I'm new to the use of perl modules.
> I want to run a perl module called NetGeoClient.pm .  More precisely,
> I want to call the method: getRecord provided in this module.  The
> sysadmins at my university has installed the Perl API for me since I
> don't have access to certain library directories it uses.
>
> Now, The README documentation for NetGeo instructs:
> *********************************************************
> Perl Usage
> -----
> $recordRef = $netgeo->getRecord( $identifier );
> *********************************************************
>
> So I create a test file inside the directory that NetGeoClient.pm is
> in.
> The contents of test are as follow:
> ********************************
> #!/usr/bin/perl -w
> use strict;
> use NetGeoClient;
>
> my $recordRef = $netgeo->getRecord("192.172.226.30");
> print "$recordRef\n";
> *********************************************************
>
> But when I run the test file, it doesn't seem to be able to locate
> NetGeoClient.pm . It keeps giving me the error message:
>
> Global symbol "$netgeo" requires explicit package name at ./test line
> 5.
> Execution of ./test aborted due to compilation errors.
>
> I figure something is wrong with the path variable.
> Can I fix this from within test?
> Thanks in advance for any help!
> Urmi

You're using strict, so you have to declare $netgeo before you can call it,
and you probably have to run the NetGeoClient object creator. Something
like:
my $netgeo = NetGeoClient->new('with any required or desired parameters');
my $recordRef = $netgeo->getRecord("yadayadayada");
 ...and so on.




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

Date: Wed, 27 Nov 2002 20:30:43 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Question about IO::Socket Usage...
Message-Id: <3DE571C3.852A759A@earthlink.net>

Extended Partition wrote:
> 
> Hello Everyone,
> 
> I am writing a socket based program and have run into a small problem.
> I will be cycling through a list and sending the contents over a
> socket. The problem is, the server will only accept 3-5 sends at a
> time. So I need a way to know when the server disconnects my socket so
> I can force a reconnect.

You can test whether the socket is readable with select/IO::Select -- if
the socket is readable at a time that you are not expecting a response
to your data, then that is probably an indication of EOF.

Or, you could simply keep writing until print/syswrite fails (with $!
equal to Errno::EPIPE()), or until you get a SIGPIPE on the socket.

   my ($socket, $select);
   my $connect = sub {
      $socket = IO::Socket->new(....);
      $select = IO::Select->new($socket);
      ($| = 1), select $_ for select $socket;
   };
   &$connect();
   SEND_DATA: foreach my $datum (@data) {
      my $reconnect = sub { &$connect(); redo SEND_DATA; }
      () = $sel->can_read(0) or &$reconnect;
      local $SIG{PIPE} = $reconnect;
      print $socket $datum or &$reconnect;
   }

[untested]
I'm not sure how well 'redo LABEL' will work from within a signal
handler.

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


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

Date: Wed, 27 Nov 2002 16:33:31 -0500
From: North Lilly <nlilly@slis.kent.edu>
Subject: reg expression question
Message-Id: <3DE53A2B.2080901@slis.kent.edu>

Can a regular expression be used to take a variable string and add a 
character to it (ie 1234 -> 12:34)?  If so what is the syntax?





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

Date: 27 Nov 2002 22:56:30 +0100
From: Steve Holland <holland@origo.phys.au.dk>
Subject: Re: reg expression question
Message-Id: <w47smxmfzht.fsf@origo.phys.au.dk>

North Lilly <nlilly@slis.kent.edu> writes:

> Can a regular expression be used to take a variable string and add a
> character to it (ie 1234 -> 12:34)?  If so what is the syntax?

     Yes, it can.  The details of how to do it depend on exactly what
you want to do.  Here is some code (with-out proper error checking)
that does your example.  That is, it inserts a ":" immediately before
the last two characters of a string.

#! /usr/local/bin/perl 
use strict;
use warnings;
print "@ARGV\n";
$_ = shift(@ARGV);
s/(.{2})$/:$1/;
print "$_\n";

fred 766> test.pl 1234
1234
12:34
fred 767>     

==========================================================================
                 To find out who and where I am look at:
                 http://www.nd.edu/~sholland/index.html
"Only so many songs can be sung with two lips, two lungs, and one tounge."
==========================================================================


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

Date: 27 Nov 2002 14:49:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: reg expression question
Message-Id: <3de54bf8@news.victoria.tc.ca>

North Lilly (nlilly@slis.kent.edu) wrote:
: Can a regular expression be used to take a variable string and add a 
: character to it (ie 1234 -> 12:34)?  If so what is the syntax?


	my $string = "1234";

	$string =~ s/(\d\d)(\d\d)/$1:$2/;

or
	my $string = "1234";
	$string =~ s/(..)/$1:/;


or many others, but that's the general idea



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

Date: Wed, 27 Nov 2002 22:05:26 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: scripts run by cron.sh script can't open files
Message-Id: <slrnauaghm.mmn.mgjv@verbruggen.comdyn.com.au>

On Wed, 27 Nov 2002 12:47:51 -0800,
	Tom Weeks <tomweeks@charter.net> wrote:
> 
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnau9trl.2vv.tadmc@magna.augustmail.com...
>> Tom Weeks <tomweeks@charter.net> wrote:

>> > open W, "$ENV{DOCUMENT_ROOT}/artwork_database/workorders/artindex.dat";
[snip]

>> Be careful! $ENV{DOCUMENT_ROOT} is tainted...
>>
>>
>> Does your cron daemon even set the value of that env var?
>>
>> It is "normally" added by a web server.
>>
>> There is no web server involved in your cron job, is there?

[snip]

> All of your advice is, of course, on the money. I was not using all the
> tools at my disposal. I will now. However, since the problem is most likely
> caused by file permissions, I wonder if the only solution will be to make
> the files in question "world" writable (chmod 666). This carries its own
> security issues.

I have the vague feeling that the environment variable DOCUMENT_ROOT,
as Tad points out, most likely isn't set. That is also most likely the
major reason why things are going wrong for you.

Once you fix that, and you still have permission issues, I wouldn't
just blindly go and change all permissions to world writable. 

\begin{offtopic}

Set up your directory structure in such a way that they are owned by a
group that you are part of, and hopefully not too many other people,
make them writable by whoever the httpd runs as, and group writable as
well. Set the gid bit on the directory. You should no end up with
files that that group can write. 

But you should probably find out what's most appropriate by asking
this question in a WWW group. It's not a Perl issue.

\end{offtopic}

Martien
-- 
                        | 
Martien Verbruggen      | Little girls, like butterflies, need no
Trading Post Australia  | excuse - Lazarus Long
                        | 


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

Date: Wed, 27 Nov 2002 19:38:46 -0800
From: "Tom Weeks" <tomweeks@charter.net>
Subject: Re: scripts run by cron.sh script can't open files
Message-Id: <uuapamrlr6j801@corp.supernews.com>


"Gary E. Ansok" <ansok@alumni.caltech.edu> wrote in message
news:as32a5$d2r$1@naig.caltech.edu...
> In article <uu9prap3qu0kf0@corp.supernews.com>,
>
> I always write my open statements like this:
>
> open W, $file or die "Cannot open '$file': $!";
>
> which (assuming you redirect the output or let cron email it to you)
> might have given you a clue as to what file it was trying to open
> (and why it couldn't).
>
> Alternatively, it could be a permissions problem or a current-directory
> problem (though those look like absolute paths, which is good).
>
> My next steps towards debugging a process like this would be to start
> artwork_daily_backup.pl off with lines like
>
> my $log_file = '/tmp/artwork_daily_backup.out';
> open LOG, ">$log_file" or die "Cannot open '$log_file': $!";
> print LOG "Starting artwork daily backup\n";
> print LOG "DOCUMENT_ROOT is '$ENV{DOCUMENT_ROOT}'\n";
>
> This will help verify a) that artwork_daily_backup.pl is in fact
> started properly; and b) what the value we're seeing for the
> environment variable is.
>
More good advice. Thank you!

TLW




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

Date: 28 Nov 2002 09:44:40 +0900
From: Takahide Nojima <nojima@taito.co.jp>
Subject: Re: split binary data
Message-Id: <m3znrufrpj.fsf@nightmare.hm.taito.co.jp>

Bob Walton <bwalton@rochester.rr.com> writes:

> Here is one way:
> 
> for(1..600*1024){$a.=chr(rand(96)+32)} #generate 600K bytes
> @a=($a=~m/(.{10240})/g);push @a,$' if length($')>0; #10K pieces
> print "size of a=".@a."\n"; #how many pieces
> print join ', ',map {length} @a; #size of each piece
> 
> HTH.

 If $a have utf-8 string in that code with perl 5.6 ,
 I think the size of $a[0] is not equal 10240 bytes.

 I think the solution is like this,

 1. In Perl 5.6 above:

   Someone tell me to add 'use bytes' within the code like this,

      { use bytes;
        for(1..600*1024){$a.=chr(rand(96)+32)} #generate 600K bytes
        @a=($a=~m/(.{10240})/g);push @a,$' if length($')>0; #10K pieces
        print "size of a=".@a."\n"; #how many pieces
        print join ', ',map {length} @a; #size of each piece
      }    

 2. In less than 5.6:

     Perl doesn't treat multi-byte charactors in any string manipulation,so
   any binary data always treat in the unit of bytes.

nojima@taito.co.jp





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

Date: 27 Nov 2002 12:29:42 -0800
From: sstark@us.ibm.com (Scott Stark)
Subject: strange glob error
Message-Id: <ce94ec71.0211271229.22c70620@posting.google.com>

Hi, 

I'm experiencing a glob error I don't understand. My perl script has
the following fragment in a subroutine:

 my($dir) = @_;
 my(@files) = glob("$dir/*");
 ...;

When the script runs, on some directories I get this error:

 checking library/dbdk/dapi....                                     
 internal error: glob failed at ./fh.pl line 32, <_GEN_0> chunk 224.

On most of the directories it runs fine, but on a few it produces an
error similar to that. There is nothing unique about those directories
that I can see.

Can anyone explain what's happening?

thank you,
Scott Stark


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

Date: Wed, 27 Nov 2002 21:23:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: strange glob error
Message-Id: <3DE537A6.253C7691@acm.org>

Scott Stark wrote:
> 
> I'm experiencing a glob error I don't understand. My perl script has
> the following fragment in a subroutine:
> 
>  my($dir) = @_;
>  my(@files) = glob("$dir/*");
>  ...;
> 
> When the script runs, on some directories I get this error:
> 
>  checking library/dbdk/dapi....
>  internal error: glob failed at ./fh.pl line 32, <_GEN_0> chunk 224.
> 
> On most of the directories it runs fine, but on a few it produces an
> error similar to that. There is nothing unique about those directories
> that I can see.


Which OS is this running on?  What is the Perl version number?



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 27 Nov 2002 17:21:51 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: strange glob error
Message-Id: <slrnauaksf.45n.tadmc@magna.augustmail.com>

Scott Stark <sstark@us.ibm.com> wrote:

> I'm experiencing a glob error I don't understand.


Have you looked up the error message yet?

   perldoc perldiag

That is always the first step to take when you get an
error or warning message.


> When the script runs, on some directories I get this error:
> 
>  checking library/dbdk/dapi....                                     
>  internal error: glob failed at ./fh.pl line 32, <_GEN_0> chunk 224.


-------------------------------------
=item glob failed (%s)

(W glob) Something went wrong with the external program(s) used for
C<glob> and C<< <*.c> >>.  Usually, this means that you supplied a
C<glob> pattern that caused the external program to fail and exit with a
nonzero status.  If the message indicates that the abnormal exit
resulted in a coredump, this may also mean that your csh (C shell) is
broken.  If so, you should change all of the csh-related variables in
config.sh:  If you have tcsh, make the variables refer to it as if it
were csh (e.g.  C<full_csh='/usr/bin/tcsh'>); otherwise, make them all
empty (except that C<d_csh> should be C<'undef'>) so that Perl will
think csh is missing.  In either case, after editing config.sh, run
C<./Configure -S> and rebuild Perl.
-------------------------------------


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


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

Date: Wed, 27 Nov 2002 20:53:30 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Windows multiple process questions with either Win32:Process or  "Start"
Message-Id: <3DE530CA.7A18FDEE@oracle.com>

Mark wrote:

> <snip>

> I have looked at Win32::Process, but I am not sure that it will make the
> rest of my script wait until my files are downloaded.  Thanks for any
> help anyone could give.

Win32::Process can be made to do this.

for $this_process (0..$number_you_want){
    Win32::Process::Create($proc,"path to program",
    "full command line",0,CREATE_NEW_CONSOLE,"working directory")
    || die ErrorReport();
    $launched_pid[$this_process]=$proc->GetProcessID();
}

GetProcessID returns the ID of the process you just launched with
Win32::Process::Create so for each process you launch, you can save the
PID into an array.

You can then loop until Win32::Process::Open returns 0 for all the pids
you launched, meaning they have finished processing.

if(Win32::Process::Open($openobj,$launched_pid[$your_index],0)==0){
        # it is dead because you couldn't open it
}
else{
      # keep waiting as it is still alive
}

You might also want to check the file size of the things you are
downloading to make sure you got all of them before proceeding.

Hope this helps

Graham



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

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


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