[22816] in Perl-Users-Digest
Perl-Users Digest, Issue: 5037 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 25 18:05:48 2003
Date: Sun, 25 May 2003 15:05:07 -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 Sun, 25 May 2003 Volume: 10 Number: 5037
Today's topics:
ANNOUNCE: Getopt::Long 2.33 <jvromans@squirrel.nl>
Re: counter <REMOVEsdnCAPS@comcast.net>
Crypt::CBC, Crypt::Rijndael - "almost" working <karlmarx@fastmail.fm>
From a script to another one invalid@no.address
Re: From a script to another one (Tad McClellan)
Re: From a script to another one <wksmith@optonline.net>
Help with errors. <mail@annuna.com>
Re: Help with errors. <ndronen@io.frii.com>
Re: Help with errors. <tassilo.parseval@rwth-aachen.de>
Re: Help: Delete Element From Array? ctcgag@hotmail.com
Re: How do I make a graph with this module? <jkeen@concentric.net>
Re: How do I make a graph with this module? (entropy123)
Re: How do I make a graph with this module? (entropy123)
Re: How do I make a graph with this module? (entropy123)
Re: How do I tell if an element of an array exists? <nobody@dev.null>
How to get picture file in web which involve redirectio (Antonio Lam)
Re: html tables <mpapec@yahoo.com>
Re: incorrect "uninitialised value" error in array <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
Re: incorrect "uninitialised value" error in array <abigail@abigail.nl>
Re: Lookahead: find empty line(s) or $ <krahnj@acm.org>
Re: Parsing and replacing html then putting it all back <Use-Author-Address-Header@[127.1]>
Re: Parsing and replacing html then putting it all back <Use-Author-Address-Header@[127.1]>
parsing text <no.spam@this.addy.ta>
Re: Perl Nightmare on OS X (Nick)
Re: permissions mnemonic <krahnj@acm.org>
RobotUA & LWP::Authen::Ntlm <jkatz@sk.sympatico.ca>
Re: RobotUA & LWP::Authen::Ntlm <karabot@canada.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 May 2003 14:10:56 +0200
From: Johan Vromans <jvromans@squirrel.nl>
Subject: ANNOUNCE: Getopt::Long 2.33
Message-Id: <k8p6q-aq9.ln1@red.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
*** post for FREE via your newsreader at post.newsfeed.com ***
Version 2.33 of module Getopt::Long has been released to CPAN. It will
be standard part of Perl 5.8.1 and 5.9.
Module Getopt::Long implements an extended getopt function called
GetOptions(). This function implements the POSIX standard for command
line options, with GNU extensions, while still capable of handling
the traditional one-letter options (including option bundling).
It adds a lot of features like automatic abbreviation of option names,
aliases and callback functions.
The README document is attached to this message.
The easiest way to get it is by using the CPAN shell:
perl -MCPAN -e 'install("Getopt::Long")'
Alternatively, use a Web browser and point it to the CPAN search engine:
http://search.cpan.org/search?module=Getopt::Long
Changes in this version
-----------------------
**************** WARNING -- EXPERIMENTAL CODE AHEAD ****************
The following new features are marked experimental. This means that if
you are going to use them you _must_ watch out for the next release of
Getopt::Long to see if the API has changed.
* Getopt::Long can automatically handle --version and --help options
if the calling program did not specify a handler explicitly.
Two configuration parameters have been added: 'auto_help' (or
'help') and 'auto_version' (or 'version'). If set, Getopt::Long will
itself take care of --help and --version options. Otherwise,
everything is exactly as it was before.
The new features will be enabled by default for programs that
explicitly require version 2.3203 or later.
Getopt::Long uses module Pod::Usage to produce the help message from
the SYNOPSIS section of the program's POD.
Using a --help (or -?) command line option will write the SYNOPSIS
section of the program's POD to STDOUT, and exit with status 0.
However, an illegal option will produce the help text to STDERR,
and exit with status 2. This is in accordance with current
conventions.
* Two subroutines can be exported on demand:
- VersionMessage
This subroutine prints the standard version message.
- HelpMessage
This subroutine prints the standard help message.
Both subroutines take the same arguments as Pod::Usage::pod2usage,
see its documentation for details.
Example:
use Getopt::Long 2.33 qw(GetOptions HelpMessage);
GetOptions(...) or HelpMessage(2);
**************** END EXPERIMENTAL CODE ****************
* Subroutine Configure can now be exported on demand.
* Negatable options (with "!") now also support the "no-" prefix.
On request of Ed Avis.
* Some fixes with hashes and bundling.
Thanks to Anders Johnson and Andrei Gnepp.
Mandatory/optional status for hash values is now effective.
String valued options with no value now default to the empty string
instead of 1 (one).
NOTE: The hash options still remain more or less experimental.
* Fix a pass_through bug where the options terminator (normally "--")
was not passed through in @ARGV.
Thanks to Philippe Verdret.
* Add FAQ: I "use GetOpt::Long;" (Windows) and now it doesn't work.
Previous released version was 2.32.
---- README ----
Module Getopt::Long - extended processing of command line options
=================================================================
Module Getopt::Long implements an extended getopt function called
GetOptions(). This function implements the POSIX standard for command
line options, with GNU extensions, while still capable of handling
the traditional one-letter options.
In general, this means that command line options can have long names
instead of single letters, and are introduced with a double dash `--'.
Optionally, Getopt::Long can support the traditional bundling of
single-letter command line options.
Getopt::Long::GetOptions() is part of the Perl 5 distribution. It is
the successor of newgetopt.pl that came with Perl 4. It is fully
upward compatible. In fact, the Perl 5 version of newgetopt.pl is just
a wrapper around the module.
For complete documentation, see the Getopt::Long POD document or use
the command
perldoc Getopt::Long
FEATURES
========
* Long option names
Major advantage of using long option names is that it is much easier
to memorize the option names. Using single-letter names one quickly
runs into the problem that there is no logical relationship between
the semantics of the selected option and its option letter.
Disadvantage is that it requires more typing. Getopt::Long provides
for option name abbreviation, so option names may be abbreviated to
uniqueness. Also, modern shells like Cornell's tcsh support option
name completion. As a rule of thumb, you can use abbreviations freely
while running commands interactively but always use the full names in
scripts.
Examples (POSIX):
--long --width=80 --height=24
Extensions:
-long (convenience) +width=80 (deprecated) -height 24 (traditional)
By default, long option names are case insensitive.
* Single-letter options and bundling
When single-letter options are requested, Getopt::Long allows the
option names to be bundled, e.g. "-abc" is equivalent to "-a -b -c".
In this case, long option names must be introduced with the POSIX "--"
introducer.
Examples:
-lgAd (bundle) -xw 80 (bundle, w takes a value) -xw80 (same)
even -l24w80 (l = 24 and w = 80)
By default, single-letter option names are case sensitive.
* Flexibility:
- options can have alternative names, using an alternative name
will behave as if the primary name was used;
- options can be negatable, e.g. "debug" will switch it on, while
"nodebug" will switch it off.
- options can set values, but also add values producing an array
of values instead of a single scalar value, or set values in a hash.
* Options linkage
Using Getopt::Long gives the programmer ultimate control over the
command line options and how they must be handled:
- by setting a global variable in the calling program;
- by setting a specified variable;
- by entering the option name and the value in an associative array
(hash) or object (if it is a blessed hash);
- by calling a user-specified subroutine with the option name and
the value as arguments (for hash options: the name, key and value);
- combinations of the above.
* Customization:
The module can be customized by specifying settings in the 'use'
directive, or by calling a special method, Getopt::Long::Configure.
For example, the following two cases are functionally equal:
use Getopt::Long qw(:config bundling no_ignore_case);
and
use Getopt::Long;
Getopt::Long::Configure qw(bundling no_ignore_case);
Some of the possible customizations. Most of them take a "no_" prefix
to reverse the effect:
- default
Restore default settings.
- auto_abbrev
Allow option names to be abbreviated to uniqueness.
- getopt_compat
Allow '+' to start options.
- gnu_compat
Compatibility with GNU getopt_long().
- permute
- require_order
Whether non-options are allowed to be mixed with options.
permute means that
-foo arg1 -bar arg2 arg3
is equivalent to
-foo -bar arg1 arg2 arg3
(provided -foo does not take an argument value).
require_order means that options processing
terminates when the first non-option is encountered.
-foo arg1 -bar arg2 arg3
is equivalent to
-foo -- arg1 -bar arg2 arg3
- bundling
Setting this variable to a non-zero value will allow
single-character options to be bundled. To distinguish bundles
from long option names, long options must be introduced with
"--" and single-character options (and bundles) with "-".
- ignore_case
Ignore case when matching options.
- pass_through
Do not issue error messages for unknown options, but leave
them (pass-through) in @ARGV.
- prefix
The string that starts options. See also prefix_pattern.
- prefix_pattern
A Perl pattern that identifies the strings that introduce
options. Default is (--|-|\+) unless environment variable
POSIXLY_CORRECT has been set, in which case it is (--|-).
- debug
Enable copious debugging output.
* Object oriented interface:
Using the object oriented interface, multiple parser objects can be
instantiated, each having their own configuration settings:
$p1 = new Getopt::Long::Parser (config => ["bundling"]);
$p2 = new Getopt::Long::Parser (config => ["posix"]);
if ($p1->getoptions(...options descriptions...)) ...
AVAILABILITY
============
The official version for module Getopt::Long comes with the Perl 5
distribution.
Newer versions will be made available on the Comprehensive Perl Archive
Network (CPAN), see "http://www.perl.com/CPAN/authors/Johan_Vromans".
Or use the CPAN search engine:
http://search.cpan.org/search?mode=module&query=Getopt::Long
http://search.cpan.org/search?module=Getopt::Long
COPYRIGHT AND DISCLAIMER
========================
Module Getopt::Long is Copyright 2003,1990 by Johan Vromans.
This program is free software; you can redistribute it and/or
modify it under the terms of the Perl Artistic License or the
GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
-------------------------------------------------------------------
Johan Vromans jvromans@squirrel.nl
Squirrel Consultancy Haarlem, the Netherlands
http://www.squirrel.nl http://www.squirrel.nl/people/jvromans
------------------ "Arms are made for hugging" --------------------
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
------------------------------
Date: Sun, 25 May 2003 09:00:18 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: counter
Message-Id: <Xns938665DE76436sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Andras Malatinszky <nobody@dev.null> wrote in news:3ECF71A1.9050705
@dev.null:
>> open( F, $ARGV[0] );
>
>
> Don't do that! Don't blindly open files without checking to make sure
> it's OK. Suppose you have the code above in program.pl, and then someone
> comes along and types
>
> perl program.pl >/data/irreplaceable/precious.dat
How can one code around that in perl? What would you do to "check to make
sure it's OK"?
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPtDMkWPeouIeTNHoEQI9NgCfYb3TTpO++YiVezdV/A1OK2HYEbcAoO2x
hGoMbTYLgihalNuMMaObTlE6
=RHQL
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 25 May 2003 12:17:33 +0200
From: Frederic <karlmarx@fastmail.fm>
Subject: Crypt::CBC, Crypt::Rijndael - "almost" working
Message-Id: <baq5ih$nis$1@reader10.wxs.nl>
Hi,
I wrote a script using Crypt::CBC to encrypt a file with Rijndael. The
script is "almost" working. I can encrypt and decrypt, however, in the
decrypted text, I always get two or three words "corrupted". You will find
the script here under, and an example of a decrypted text, so that you can
see what I mean by "corrupted" (the original plaintext contains lines of
0123456789).
Thanks for your help.
#!/usr/bin/perl
use strict;
use warnings;
use Crypt::Rijndael;
use Crypt::CBC;
my $my_key = $ARGV[0];
my $plainfile="test2.txt";
my $cipher;
my $buffer;
my $decrypted="$plainfile.cry.txt";
# this sub makes all keysize of 32 bytes, in case the key you give is
# smaller. However, remember to use a strong key !!!
sub get32 {
my $data = shift;
return "\0" x ( 32 - length($data)%32 ) . $data;
}
#----------------------------------------------------------------------
# Parameters
#----------------------------------------------------------------------
$cipher = Crypt::CBC->new( {'key' => get32($my_key),
'cipher' => 'Rijndael',
'iv' => '§%(Ml7!B',
'regenerate_key' => 1,
'padding' => 'standard',
'prepend_iv' => 0
});
#----------------------------------------------------------------------
# Encryption
#----------------------------------------------------------------------
open(FH_plain,"./$plainfile");
open(FH_crypted, ">$plainfile.cry");
while (read(FH_plain,$buffer,1024)) {
print FH_crypted $cipher->encrypt($buffer);
}
close FH_plain;
close FH_crypted;
#----------------------------------------------------------------------
# Decryption
#----------------------------------------------------------------------
open(FH_crypted, "<$plainfile.cry");
open(FH_decrypted, ">$decrypted");
while (read(FH_crypted,$buffer,1024)) {
print FH_decrypted $cipher->decrypt($buffer);
}
close FH_crypted;
close FH_decrypted;
===================================================
Exemple de texte décrypté
===================================================
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012HüÐ3ùÇI5SËLó±¾ïr g²Ï®Æ›5678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
0123456789012345678901234567890123456789012345678901234567890123456789
01234567890123456789012345¹¨°ê6t¤Á¤&hOÁ*¦F%¼ö8O>¶f
Ë3456789012345678901234567890123456789012345678901234567890123456789
------------------------------
Date: Sun, 25 May 2003 23:34:50 +0400
From: invalid@no.address
Subject: From a script to another one
Message-Id: <6e62dv4ru9o0shk86ck7ogfr75709ikbee@4ax.com>
Hi,
Inside script1.pl, I need to call script2.pl, with passing parameters.
Then I need to look at the result of the call, staying in script1.pl
the call to script2.pl COULD be done by something like
http://domain/path/script2.pl?param1=1¶m2=2
param1 and param2 are of course in script1.pl
What is the best way for that ?
Thank you,
Paul
------------------------------
Date: Sun, 25 May 2003 16:49:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: From a script to another one
Message-Id: <slrnbd2eju.e04.tadmc@magna.augustmail.com>
invalid@no.address <invalid@no.address> wrote:
> Inside script1.pl, I need to call script2.pl, with passing parameters.
> Then I need to look at the result of the call, staying in script1.pl
Use backticks to run external programs and capture its output.
> the call to script2.pl COULD be done by something like
> http://domain/path/script2.pl?param1=1¶m2=2
That is not how programs are invoked, that is how CGI programs are invoked.
You do not want to call one script from another script.
You want to call one CGI program from a script (whether CGI or not).
That is an entirely different question, with a correspondingly
different answer.
You can make a GET request using the LWP::Simple module, as
mentioned in the Perl FAQ:
How do I fetch an HTML file?
You can make a POST request using the LWP::UserAgent module, as
mentioned in the Perl FAQ:
How do I automate an HTML form submission?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 May 2003 21:53:30 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: From a script to another one
Message-Id: <uXaAa.36802$Pz3.14687322@news4.srv.hcvlny.cv.net>
<invalid@no.address> wrote in message
news:6e62dv4ru9o0shk86ck7ogfr75709ikbee@4ax.com...
> Hi,
>
> Inside script1.pl, I need to call script2.pl, with passing parameters.
> Then I need to look at the result of the call, staying in script1.pl
>
> the call to script2.pl COULD be done by something like
> http://domain/path/script2.pl?param1=1¶m2=2
>
> param1 and param2 are of course in script1.pl
>
> What is the best way for that ?
I am not sure what you mean by the "result".
refer to perldoc -f system if you want the "return value" of
script2.pl.
refer to qx/STRING/ section of perldoc perlop if you want the STDOUT of
script2.pl
Details of quoting your arguments are highly dependent on you operating
system (and shell). If you still need help, tell us more about your
system and what exactly you have tried.
Good Luck,
Bill
------------------------------
Date: Sun, 25 May 2003 16:02:34 -0500
From: Joe Creaney <mail@annuna.com>
Subject: Help with errors.
Message-Id: <3ED12F6A.3010602@annuna.com>
I have been working on my role playing game and I am getting errors I
can't explain. My two that are really stumping me are first why some
values won't print in certain packages the other why it won't perform an
if then operation. The first error I wrote a function to generate. The
is I have an array and I want to check for the first open space defined
by a space " " or the space being undef. If so I want to something
there. The first time I use the block it works but if I come back to it
it doesn't. I have use all the debugging tricks I know and I can find
no reason why I am getting these errors. The program is long nearly
1,000 lines. I am beginning to believe there is a problem with the
compiler.
The game is at my site www.annuna.com/perl5 and it is under simple RPG
1.2 error.
If I can't figure out why the program doesn't work I will have to drop
it and focus on learning C++. Once I get proficient enough I will try
to write this game in another language.
------------------------------
Date: 25 May 2003 21:07:22 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: Help with errors.
Message-Id: <3ed1308a$0$202$75868355@news.frii.net>
Joe Creaney <mail@annuna.com> wrote:
JC> I have been working on my role playing game and I am getting errors I
JC> can't explain. My two that are really stumping me are first why some
JC> values won't print in certain packages the other why it won't perform an
JC> if then operation. The first error I wrote a function to generate. The
JC> is I have an array and I want to check for the first open space defined
JC> by a space " " or the space being undef. If so I want to something
JC> there. The first time I use the block it works but if I come back to it
JC> it doesn't. I have use all the debugging tricks I know and I can find
JC> no reason why I am getting these errors. The program is long nearly
JC> 1,000 lines.
Why don't you post a *small* program that reproduces each problem?
JC> I am beginning to believe there is a problem with the compiler.
I doubt it.
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: 25 May 2003 21:32:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Help with errors.
Message-Id: <barcpm$kul$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Joe Creaney:
> I have been working on my role playing game and I am getting errors I
> can't explain. My two that are really stumping me are first why some
> values won't print in certain packages the other why it won't perform an
> if then operation. The first error I wrote a function to generate. The
> is I have an array and I want to check for the first open space defined
> by a space " " or the space being undef. If so I want to something
> there. The first time I use the block it works but if I come back to it
> it doesn't. I have use all the debugging tricks I know and I can find
> no reason why I am getting these errors. The program is long nearly
> 1,000 lines. I am beginning to believe there is a problem with the
> compiler.
Don't do that. It may be convenient to blame it on some external factor
but most often the reason lies within your code. If it is really the
Perl interpreter, there'd soon be some bugreport about it since the
behaviour you describe can hardly pass unnoticed by thousands of users.
First rule is: try to reduce the code, throw obviously unnecessary piece
of code out till a) either the misbehaviour disappears (and you thusly
know why it did not initially work) or b) you can pin it down to an
actual bug.
> The game is at my site www.annuna.com/perl5 and it is under simple RPG
> 1.2 error.
Really, it is too long for us to give you any specific help. The code
however is a little messy (which is just natural for someone learning
Perl). It's not yet the most readable code. With a little more of some
idiomatic constructs you'd be able to save a good number of lines of
code. The overall structure would thus become more obvious and errors in
the code could more easily be spotted. Why not focus a little on this
for a couple of days before you continue with hunting down the bug?
> If I can't figure out why the program doesn't work I will have to drop
> it and focus on learning C++. Once I get proficient enough I will try
> to write this game in another language.
Dropping Perl in favour of C++ (because it might be easier) is beyond
words. C++ is an extremely complex language...and the first fragile
steps will usually not result in instant gratification (as they normally
do in Perl). Instead they'll end in compiler-errors or segfaults. I bet
that you're more likely to find your happiness with Perl (for the
moment).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 25 May 2003 22:03:20 GMT
From: ctcgag@hotmail.com
Subject: Re: Help: Delete Element From Array?
Message-Id: <20030525180320.374$7H@newsreader.com>
email_entropy123@yahoo.com (entropy123) wrote:
> Hey all,
>
> How do I quickly and easily delete an element from an array?
You don't. You turn the array into a hash, then quickly and easily
delete elements from that.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: 25 May 2003 14:03:17 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: How do I make a graph with this module?
Message-Id: <baqif5$fbv@dispatch.concentric.net>
"entropy123" <email_entropy123@yahoo.com> wrote in message
news:90cdce37.0305241555.446a0598@posting.google.com...
> Hey all,
>
> Any advice on how to use the Graph::Base module? I can't seem to get
> started creating verticies, edges, etc...
>
> The code starts like this:
>
> package Graph::Base
> use vars qw(@ISA);
> require Exporter;
> @ISA = qw(Exporter);
>
> # new
> #
> # $G=Graph->new(@V)
> #
> #
> sub new {
> my $class = shift;
> my $G= { };
> bless $G, $class;
> $G->add_verticies(@_) if @_;
> return $G;
> )
>
> What kind of argument do I send to this thing? I have a list of
> 'verticies' say
> a-b, b-c, c-d, c-e and so on but have no idea how to send them to this
> subroutine/module.
>
What don't you understand about the Graph::Base documentation:
http://search.cpan.org/author/JHI/Graph-0.20101/lib/Graph/Base.pm#DESCRIPTIO
N
------------------------------
Date: 25 May 2003 13:36:30 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: How do I make a graph with this module?
Message-Id: <90cdce37.0305251236.7c6667b8@posting.google.com>
James,
Thanks man, didn't know that resource was there....
entropy
------------------------------
Date: 25 May 2003 13:42:06 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: How do I make a graph with this module?
Message-Id: <90cdce37.0305251242.13d2eed0@posting.google.com>
James,
Ok, what I don't understand about this article...what is the very
first step? I have a bunch of connections, say (a b b c c d c e e f)
but no idea how to get them into the process...I'm trying to write a
program which will detect cycles for me....
Thanks man,
entropy
------------------------------
Date: 25 May 2003 13:52:06 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: How do I make a graph with this module?
Message-Id: <90cdce37.0305251252.16333c46@posting.google.com>
James,
I guess I'm looking for some sort of sandbox so I can get used to
inputting, outputting to this module....
I read through the code and I see what it is doing, but have no idea
how to actually take my data and produce a graph....
entropy
------------------------------
Date: Sun, 25 May 2003 11:23:14 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: How do I tell if an element of an array exists?
Message-Id: <3ED0A787.4080803@dev.null>
newguy wrote:
> Hello Folks,
>
> Given that I have two arrays with the following defined:
>
> @a1 = ( 10.1.0.1, 10.1.0.2, 10.1.0.3, 10.1.0.14, 10.1.0.10 );
> @a2 = ( 10.1.0.1, 10.1.0.2 );
>
> How can I tell if an element in @a2 exists in @a1?
>
> Thanks
>
Are you expecting different answers today than the ones you got yesterday?
This is a frequently asked question answered in perlfaq4. Look it up.
Also, note that there is a difference between 10.1.0.1 and '10.1.0.1'
------------------------------
Date: 25 May 2003 11:23:18 -0700
From: alam@netscape.com (Antonio Lam)
Subject: How to get picture file in web which involve redirection using LWP
Message-Id: <e6e46c65.0305251023.34644f14@posting.google.com>
I tried to get some images from the web using LWP, and find out some
sites won't allow me to do it directly with absolute URL address (eg.
http://www.hostname.com/dir/pic.jpg). Even from the browser, if I type
the absolute URL address, it will redirect me to other page insted
retrieve the image. So I need to go to their main page (eg.
http://www.hostname.com) and click its link within the page to
retrieve the image. I think there are some sort of file protection in
the site which force the user to navigate through their pages to get
those files.
So if I do the following code in Perl:
---------------------
use LWP::Simple;
if (is_success($rtrcode =
getstore("http://www.hostname.com/dir/pic.jpg", "pic.jpg"))) {
print "Got file.\n";
} else {
print "Can not find file\n";
}
print "rtrcode is: $rtrcode\n";
----------------------
the return code still '200' but i am not getting the right file.
(instead, it is a redirected index file).
Any idea on how to solve this problem?
Thanks,
Antonio.
------------------------------
Date: Sun, 25 May 2003 15:57:09 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: html tables
Message-Id: <4ti1dvs7nor9ktcsrd3sgh6r1ftsnmv695@4ax.com>
X-Ftn-To: Andras Malatinszky
Andras Malatinszky <nobody@dev.null> wrote:
>> $1 =~ /$filter/ ? '' : $1;
>> }iges;
>>
>> Is there more efficiant way to do the same thing and using perl only?(don't
>> like idea of capturing $1 and doing substitution with same content)
>
>
>Would
>
>$simpletable=~s[<tr.+?$filter.+?</tr>][]iges;
>
>work?
Not quite; it would always start matching from first '<tr' in $simpletable.
>There are modules on CPAN for parsing HTML, and I've often seen the
>advice here to use those modules rather than roll your own.
I'm not in position to use additional modules, but I'll take a look at CPAN.
Do you have some favorite module?
--
Matija
------------------------------
Date: 25 May 2003 16:09:46 GMT
From: Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
Subject: Re: incorrect "uninitialised value" error in array
Message-Id: <baqpsa$hnj$1@reader08.wxs.nl>
In article <slrnbcv6gv.kuj.abigail@alexandra.abigail.nl>, Abigail wrote:
> Rene van Leeuwen (r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl) wrote on
> MMMDLIII September MCMXCIII in <URL:news:banuiq$b6d$1@reader11.wxs.nl>:
><> In the following code I get the following errors:
><> arr[$k]= 2
><> Use of uninitialized value in numeric lt (<) at ./erathos7.pl line 16.
><> Use of uninitialized value in modulus (%) at ./erathos7.pl line 18.
><> Illegal modulus zero at ./erathos7.pl line 18.
><>
><> As far as I can see both @arr and $j are initialised, also the output
><> for 'arr[$k]= 2' proves that the array is filled. So I think the error is
><> incorrect. Can anyone advise me on this, please?
>
> That @arr and $j are initialized doesn't mean that $arr [$j] is.
> The first time you are getting a problem is when $j equals 2, but
> @arr only has 2 elements. So, $arr [2] is "out of bounds", for
> which Perl will use an undefined value.
>
Thanks Abigail,
so I have to pre-declare the array with enough elements for this code to
works (as you would in C) to avoid "out of bounds" error?
> Furthermore, you are using a slow algorithm, using lots of space.
> Here's a program that finds primes, which uses not so much memory,
> about 1 Mb for every 25 million numbers to be tested.
>
>
Your programs works real fast indeed!! Cheers.
___ _
| _ \___ _ _ ___//
| / -_) ' \/ -_)
|_|_\___|_||_\___|
------------------------------
Date: 25 May 2003 18:00:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: incorrect "uninitialised value" error in array
Message-Id: <slrnbd215a.kuj.abigail@alexandra.abigail.nl>
Rene van Leeuwen (r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl) wrote on
MMMDLIV September MCMXCIII in <URL:news:baqpsa$hnj$1@reader08.wxs.nl>:
@@ In article <slrnbcv6gv.kuj.abigail@alexandra.abigail.nl>, Abigail wrote:
@@ > Rene van Leeuwen (r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl) wrote on
@@ > MMMDLIII September MCMXCIII in <URL:news:banuiq$b6d$1@reader11.wxs.nl>:
@@ ><> In the following code I get the following errors:
@@ ><> arr[$k]= 2
@@ ><> Use of uninitialized value in numeric lt (<) at ./erathos7.pl line 16.
@@ ><> Use of uninitialized value in modulus (%) at ./erathos7.pl line 18.
@@ ><> Illegal modulus zero at ./erathos7.pl line 18.
@@ ><>
@@ ><> As far as I can see both @arr and $j are initialised, also the output
@@ ><> for 'arr[$k]= 2' proves that the array is filled. So I think the error i
@@ ><> incorrect. Can anyone advise me on this, please?
@@ >
@@ > That @arr and $j are initialized doesn't mean that $arr [$j] is.
@@ > The first time you are getting a problem is when $j equals 2, but
@@ > @arr only has 2 elements. So, $arr [2] is "out of bounds", for
@@ > which Perl will use an undefined value.
@@ >
@@
@@ Thanks Abigail,
@@
@@ so I have to pre-declare the array with enough elements for this code to
@@ works (as you would in C) to avoid "out of bounds" error?
Uhm, no, that would not be the right way to do it. How would you know
how much to pre-declare? All of them? The right way would be to use
a different condition to determine how far the index should go.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
Date: Sun, 25 May 2003 10:50:29 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Lookahead: find empty line(s) or $
Message-Id: <3ED09FDC.27564946@acm.org>
Winfried Koenig wrote:
>
> you don't need any lookahead. Try this:
>
> use strict;
> undef $/;
> open(TEXT, 'foo.txt') or die "could not open 'foo.txt' $!";
> $_ = <TEXT>;
Or you could do:
$_ = do { local $/; <TEXT> };
Which confines the effects on $/ to the block.
> while (m!\$(\d+)/(\d+)\$([^\$\n]*(?:\n[^\$\n]+)*)!gs) {
You don't need the /s option as you aren't using the . metacharacter in
your regular expression.
> my($l, $r, $v) = ($1, $2, $3);
> $v =~ s/\s+/ /g;
> $v =~ s/^ //;
> $v =~ s/ $//;
Or even:
my ( $l, $r, $v ) = ( $1, $2, join '', split ' ', $3 );
> print "$l-$r: $v\n";
> }
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 25 May 2003 06:53:53 -0700
From: Robert Brooks <Use-Author-Address-Header@[127.1]>
Subject: Re: Parsing and replacing html then putting it all back
Message-Id: <200305251353.h4PDrrD9019623@www.aarg.net>
together
References: <1d3311d7.0305230915.3f6083e2@posting.google.com>
<N2vza.3386$c6.3234@bos-service2.ext.raytheon.com>
In article <N2vza.3386$c6.3234@bos-service2.ext.raytheon.com>
Chris Olive <nospam@raytheon.com> wrote:
>
> Shaun wrote:
> > Ok so here's the issue:
> >
> > I have a script that transforms xml data with it's xsl counter part, to
> > create my html ($html).
> >
> > I need to parse $html for the first block, middle block and last block
> > of data. The begining of the middle block of data is seperated by
> > <!--\(--> (simply trying to find a unique set of characters for perl to
> > find) and ends with <!--\)--> ofcourse marking the begining of the last
> > block.
> >
> > So I need to be able to take the middle block of data, and replace it
> > with a new block of data, then combine the first, new middle, and last
> > block of data to produce a new $html =)
> >
> > Any modules out there with this type of functionality built in? Be
> > gentle, I'm a novice.
>
> Randall Schwartz deals almost exactly with this kind of issue (if not
> exactly) in the June 2003 edition (I believe) of _Linux Magazine_ in his
> "Perls of Wisdom" column. I don't have the article here, but he used
> HTML::Parser and some XML components to accomplish this. Was quite nice
> and straight forward. It may be worth having a look at the newstands for
> it. I see the issue isn't on their web site yet.
>
> Chris
Well, the column in question may not be on THEIR web site yet, but
it looks like the following URL has it:
http://www.stonehenge.com/merlyn/LinuxMag/col49.html
------------------------------
Date: Sun, 25 May 2003 07:03:07 -0700
From: Robert Brooks <Use-Author-Address-Header@[127.1]>
Subject: Re: Parsing and replacing html then putting it all back
Message-Id: <200305251403.h4PE37Q8020146@www.aarg.net>
together again?
References: <1d3311d7.0305230915.3f6083e2@posting.google.com>
<N2vza.3386$c6.3234@bos-service2.ext.raytheon.com>
In article <N2vza.3386$c6.3234@bos-service2.ext.raytheon.com>
Chris Olive <nospam@raytheon.com> wrote:
>
> Shaun wrote:
> > Ok so here's the issue:
> >
> > I have a script that transforms xml data with it's xsl counter part, to
> > create my html ($html).
> >
> > I need to parse $html for the first block, middle block and last block
> > of data. The begining of the middle block of data is seperated by
> > <!--\(--> (simply trying to find a unique set of characters for perl to
> > find) and ends with <!--\)--> ofcourse marking the begining of the last
> > block.
> >
> > So I need to be able to take the middle block of data, and replace it
> > with a new block of data, then combine the first, new middle, and last
> > block of data to produce a new $html =)
> >
> > Any modules out there with this type of functionality built in? Be
> > gentle, I'm a novice.
>
> Randall Schwartz deals almost exactly with this kind of issue (if not
> exactly) in the June 2003 edition (I believe) of _Linux Magazine_ in his
> "Perls of Wisdom" column. I don't have the article here, but he used
> HTML::Parser and some XML components to accomplish this. Was quite nice
> and straight forward. It may be worth having a look at the newstands for
> it. I see the issue isn't on their web site yet.
>
> Chris
Well, the column in question may not be on THEIR web site yet, but
it looks like the following URL has it:
http://www.stonehenge.com/merlyn/LinuxMag/col49.html
------------------------------
Date: Sun, 25 May 2003 22:36:28 +0100
From: "Brian H¹©" <no.spam@this.addy.ta>
Subject: parsing text
Message-Id: <rHaAa.12504$sJ4.2368@newsfep4-winn.server.ntli.net>
Following on from my counter query the other day.
I have created some more scripts that treat the list in various ways and give me
a final list containing just one word.
e.g. a text file "blahblah.txt" containing just the word "fred".
I would like to be able to parse/echo the word "fred" to a DOS edit command.
Can I call upon someone again to come to my rescue please?
I know that this may not require a perl script, and may only require a couple of
DOS commands, but the help section of my DOS book is about as useless as boobs
on a stallion.
TIA (again)
Brian
------------------------------
Date: 25 May 2003 11:49:46 -0700
From: nick@tiger-marmalade.com (Nick)
Subject: Re: Perl Nightmare on OS X
Message-Id: <6a6938d0.0305251049.6a7309bc@posting.google.com>
I believe I've found the answer. The problem lay in
/sw/lib/perl5/darwin/Storable.pm. Moving that to /tmp and rebuilding
via fink seems to have fixed the problem. One odd things, still --
why to package variables have to be declared as belonging to a
specific package, even if you want the to belong to main? For example,
the following results in compilation errors:
$foo = 'bar';
while this works:
$main::foo = bar;
nick@tiger-marmalade.com (Nick) wrote in message news:<6a6938d0.0305242131.3a8ec6bf@posting.google.com>...
> I'm a new to Perl and OS X, but I recently tried to install Perl 5.8.0
> on my iMac for the primary reason that I wasn't able to download
> anything from CPAN without it trying to install Perl 5.8.0 as well. I
> followed the directions posted at
> http://developer.apple.com/internet/macosx/perl.html, configuring
> things to use apple's perl 5.6.0 setup as closely as possible (i.e.
> install prefix of /usr), I've been getting undefined symbol errors
> ever since. I moved libperl.dylib to a new file libperlold.dylib in
> /System/Library/Perl/darwin/CORE and reissuing make install, but to no
> avail). I then tried removing any and all .bundle files I could find
> in /Library/Perl and rerunning make install, also to no avail. So now
> I'm dead in the water and fresh out of ideas. Like I said, I'm new to
> Perl and to OS X, so I'm a little worried -- Is this likely to cause
> any problems with my system overall (don't many OS X apps rely on perl
> to some extent?). Is there a way to fix this? Please be gentle . . .
------------------------------
Date: Sun, 25 May 2003 11:07:20 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: permissions mnemonic
Message-Id: <3ED0A3CF.26E95B9F@acm.org>
Eric Wilhelm wrote:
>
> foreach $r (0,r) {
> foreach $w (0,w) {
> foreach $x (0,x) {
> $h=($r||"-").($w||"-").($x||"-");
> print "$h -> ",($r&&1).($w&&1).($x&&1),
> " -> ",($r&&1)*4+($w&&1)*2+($x&&1),"\n";
> }
> }
> }
>
> Lots of fun with the short-circuit operators and it even does something
> useful.
>
> I imagine it can be "golfed" down a bit but I'll leave that to the crazy
> cryptographers here:)
Well, you don't need nested loops.
for$n(0..7){
$_=$x=sprintf"%03b",$n;
s/^1/r/;s/1$/x/;s/1/w/;y/0/-/;
print"$_ -> $x -> $n\n"
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 25 May 2003 07:15:33 -0600
From: "Syl" <jkatz@sk.sympatico.ca>
Subject: RobotUA & LWP::Authen::Ntlm
Message-Id: <vd1gg0lsnjh989@corp.supernews.com>
I built a simple crawler using LWP::RobotUA.
When I encounter particular pages I get the error "Can't locate object
method "authenticate" via package LWP::Authen::Ntlm" at
/usr/lib/perl5/site_perl/5.8.0/LWP/UserAgent.pm line 545." and my program
crashes. I would like to ignore these pages and continue my crawl.
How do I trap this error or avoid it?
Syl
------------------------------
Date: Sun, 25 May 2003 11:51:14 -0400
From: "George Karabotsos" <karabot@canada.com>
Subject: Re: RobotUA & LWP::Authen::Ntlm
Message-Id: <UD5Aa.168$y77.29817@news20.bellglobal.com>
Enclose your code withing eval {};, something like this should do it:
use English;
...
...
...
eval
{
LWP::Authen::Ntlm calls
};
if($EVAL_ERROR)
{
Code that Manage the errors
}
...
...
...
Hope it helps
George
"Syl" <jkatz@sk.sympatico.ca> wrote in message
news:vd1gg0lsnjh989@corp.supernews.com...
> I built a simple crawler using LWP::RobotUA.
>
> When I encounter particular pages I get the error "Can't locate object
> method "authenticate" via package LWP::Authen::Ntlm" at
> /usr/lib/perl5/site_perl/5.8.0/LWP/UserAgent.pm line 545." and my program
> crashes. I would like to ignore these pages and continue my crawl.
>
> How do I trap this error or avoid it?
>
> Syl
>
>
------------------------------
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 5037
***************************************