[22843] in Perl-Users-Digest
Perl-Users Digest, Issue: 5064 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 30 18:06:10 2003
Date: Fri, 30 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 Fri, 30 May 2003 Volume: 10 Number: 5064
Today's topics:
Re: 32 bits checksum calculation <nobull@mail.com>
ANNOUNCE: Cisco::Reconfig 0.3 muir@idiom.com
ANNOUNCE: Config::Vars, v0.01 <sdn@comcast.net>
ANNOUNCE: Net::Netmask version 1.9003 muir@idiom.com
ANNOUNCE: Sub::Assert v1.10 <sv99oya02@sneakemail.com>
Re: APP: perl script editor <nntp@cannabiscoffeeshops.co.uk.INVALID>
Hard text file to parse (K Bouton)
make.pl 0.5 released <occitan@esperanto.org>
Re: Makefile corrupted after running perl Makefile.PL. (Dan Grazier)
Re: Recursion and Filehandles <ThomasKratz@REMOVEwebCAPS.de>
regex-new line when using /s NEW ?? <lance-news@augustmail.com>
Re: regex-new line when using /s NEW ?? <nobull@mail.com>
Re: scanning logfiles <ian@WINDOZEdigiserv.net>
Re: scanning logfiles (Tad McClellan)
Re: scanning logfiles <w.koenig@acm.org>
To get rid of a trailing empty line in the output... (Jim Carter)
Re: variable for current line number (of script) <emschwar@pobox.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 May 2003 18:32:08 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: 32 bits checksum calculation
Message-Id: <u9smqwtk6f.fsf@wcl-l.bham.ac.uk>
"Darek N" <dmn@box43.pl> writes:
> >Well if you've already decided that you are going to slurp the file
> >then your question not how to calculate the checksum of a file but
> >rather the checksum of a string.
>
> What is the difference ? I thought that calculating checksum of some
> file you do it on the data that that file contains ?
The checksum _alorithm_ is the same. But this is comp.lang.* so we are
talking about programming languages not algorithms.
The statements you'd use to read 4 bytes at a time from a file are
different from those you'd use to read a string 4 bytes at a time.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 27 May 2003 09:09:58 -0000
From: muir@idiom.com
Subject: ANNOUNCE: Cisco::Reconfig 0.3
Message-Id: <iupkq-o6e.ln1@red.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
You can find this in CPAN at
http://www.cpan.org/authors/id/MUIR/modules/Cisco-Reconfig-0.3.tar.gz
or (if the announcement beats CPAN's mirror) at
ftp:://ftp.idiom.com/users/muir/CPAN/modules/Cisco-Reconfig-0.3.tar.gz
-Dave
..CHANGELOG...................................................
Replaced destroy() with Scalar::Util::weaken at the suggestion and
with the much assistance of Martin Lorensen <martin@lorensen.dk>.
Thank you Martin!
->destroy() is now deprecated.
Also Bugfix to get() from Martin Lorensen.
Added a special case for banners to fix a bug pointed out by
Mike Drons <mdrons@ins.com>.
..POD.........................................................
NAME
Cisco::Reconfig - Parse and generate Cisco configuration files
SYNOPSIS
use Cisco::Reconfig;
my $config = readconfig("/my/cisco/config");
DESCRIPTION
Cisco::Reconfig makes it easier to write programs to generate changes to
Cisco configuration files.
Cisco::Reconfig is a module that parses Cisco router configuration
files. It doesn't have any real understanding of Cisco configurations so
it might be useful for other similar configuration languages. It knows
that nesting is shown by indentation. It knows that "!" means a comment.
It knows that "no" may proceed a line without changing where that line
exists in the hierarchy. It doesn't know much else.
Cisco::Reconfig can be used to modify configurations. The "set()" method
will check the current configruation and return commands to change it if
it is other than what is wanted (as passed to the "set()" method).
DETAILS
Some of the accessor methods return a special "undef" object instead of
a proper undef. This is so that code that uses accessors doesn't have to
be paranoid about undefined values. This "undef" object tests as false
in boolean context however it is "defined()"ed.
Methods that return configuration items can return items that represent
any particular word in the configruation file. For example, with the
following configuration & code, the return value for the "get()" method
would represent the word "access-list" in both of the lines:
ip as-path access-list 111 deny _10993_
ip as-path access-list 111 permit .*
$config->get('ip as-path access-list');
Most of the time you don't need to worry about the fact that the object
represents a word. Another way to look at it is that the object
represents a selection of lines from the configuration file. Sometimes
that selection is a single line. Sometimes it is a block. Sometimes it
is a few lines that start with the same tokens.
To look at all the different as-path access lists, the following would
work:
$config->get('ip as-path access-list')->all;
FUNCTIONS
There is just one function provided: "readconfig()". Readconfig takes a
single argument: a filename or file handle. It parses the file and
returns an Cisco::Reconfig object.
MAIN METHODS
->get(@designators)
The "get()" method is the key to looking up items in a configuration
file. It takes an array of designators as an argument. A designator
is simply something that identifies a portion of a configuration
file. For example "('interface')" is a designator for all the
interfaces and "('ip route')" is a designator for all the static
routes.
When multiple designators are specified, they are used for nested
configuration items. For example, "('router bgp', 'neighbor')" would
be a designator for all the BGP neighbors. This assumes that there
is only one "router bgp" defined.
In array context, "get()" will follow multiple paths to find
configuration items that match the specification. For example
"('interface', 'ip address')" would return a list of ip address
items across multiple interfaces.
Designators must exactly match words in the configuration. You may
not abbr anythng.
->set(@designators, $newvalue)
The "set()" method will generate Cisco configuration snippets that
will modify the configuration of an item. For example, the following
code:
my $ser0 = $config->get('interface Serial0');
print $ser0->set('ip address',
'ip address 207.181.198.194 255.255.255.252');
Will print:
interface Serial0
ip address 207.181.198.194 255.255.255.252
exit
If the configuration already matches the $newvalue then nothing
would be printed.
The designator(s) say what will be modified. This should either be
represent a line or an entire block. When multiple designators are
needed, pass them as an anonymous array. The above example could
also have been written as:
print $config->set('interface Serial0', 'ip address',
'ip address 207.181.198.194 255.255.255.252');
If no designators are needed, don't pass any. The following is
nearly the same as the preceeding;
my $ipaddr = $config->get('interface Serial0', 'ip address');
print $ipaddr->set( 'ip address 207.181.198.194 255.255.255.252');
When providing code snippets to "set()", indent blocks just like
Ciscos do when they display their configuration. For example, the
following:
print $config->set("ip access-list extended all-addresses", <<END);
ip access-list extended all-addresses
permit ip any any
!
END
Will print the following if the access list ins't already set as
listed:
ip access-list extended all-addresses
permit ip any any
exit
When modifying a block, include the configruation line that starts
the block in the replacement text. For example, when setting an
entire interface, provide the entire block:
print $config->set('interface Serial0',<<END);
interface Serial0 point-to-point
ip address 219.22.221.3 255.255.255.252
bandwidth 3022
!
END
->all($regex)
The "all()" method can be used to expand and select configuration
items.
For example, to make sure that all loopback interfaces use a netmask
of 255.255.255.255, use the following:
for my $loop ($config->get('interface')->all(qr{^Loop})) {
my $ip = $loop->get('ip address');
next unless $ip->text =~ /\A\s*ip address (\S+) \S+\s*\Z/;
print $ip->set(undef, "ip address $1 255.255.255.255");
}
The $regex paramater is optional.
ACCESSOR METHODS
->single()
Cisco::Reconfig objects may represent any word in a configruation
file. For example the word "address" in the following is represented
by an object that would be returned by the code that follows.
interface Loopback0
ip access-group 151 in
ip address 218.28.41.38 255.255.255.255
!
my $address_word = $config->get('interface Loopback0', 'ip')
->all(qr{^address});
"single()" answers the question: does this Cisco::Reconfig object
uniquely specify a single line? In the example above, the object for
word "ip" (above) does not but the object for the word "address"
does.
"single()" returns an object (representing the last word on the
line) or undef.
->zoom()
"zoom()" is the same as to "single()" except that it will always
return a valid Cisco::Reconfig object.
->endpt()
Returns an Cisco::Reconfig object representing the last word on a
configuration line that could follow from the current ZYZ object.
When there are multiple possibilities the object picked is nearly
random.
->next()
"next()" returns an Cisco::Reconfig object representing the last
word on the suceeding line of the current configuration block.
When used at the beginning of a block, it returns the last word of
the first line in the block.
->context()
Returns the configuration object that represents the surounding
context.
# returns the "undefined" object
$config->context
# returns $config
$config->get('interface Loopback0')->context
# returns $config->get('interface Loopback0')
$config->get('interface Loopback0', 'ip address')->context
"context()" always returns a configuration object.
->subs()
For Cisco::Reconfig objects that represent a word in a line that
introduces a block of configuration items (such as most "interface"
lines), the "subs()" function returns an Cisco::Reconfig object that
represents the contents of the block.
If the Cisco::Reconfig object in question does not represent the
start of a configuration block, the
->kids()
For Cisco::Reconfig objects that do not uniquely specify a single
line (ie: "! -"single()>), the ->kids() method will return an array
of objects representing the possible following words.
If there is only one possibility, that one possibility is returned.
If the Cisco::Reconfig object represents the last word on a
configuration line then that word is returned.
MISCELLANEOUS METHODS
->text()
Returns the text from the original configuration file (in original
order) of all of the lines that could follow from the current
Cisco::Reconfig object.
When the invoking Cisco::Reconfig object represents a single line
"text()" returns that line. When the invoking Cisco::Reconfig object
represents a block "text()" returns the entire block. When the
Cisco::Reconfig object represents a word with multiple possible
completions, "text()" returns all the completions.
->setcontext()
Returns an array of configuration lines that define the block
surrounding the invoking object.
->unsetcontext()
Returns an array of the word "exit" repeated as many times as
nessasary to undo a "setcontext()".
->block()
Returns true if the object represents a whole configuration block.
OVERLOADING
Two operators are overloaded: boolean tests and stringification.
Cisco::Reconfig objects booleanify as true if they are the special
undefined objects. Cisco::Reconfig objects stringify as their text
lines.
CAVEATS
Since Cisco::Reconfig doesn't really understand Cisco configuration
files it can't know things that you might think it should.
For example, it doesn't know that "interface Serial0" is the same as
"int ser 0" nor even "interface Serial 0". Be very careful about where
Cisco's actually put spaces and where they don't.
No attempt has been made to make this module particularly fast or
efficient for the computer.
Cisco::Reconfig objects don't automatically garbage collect themselves
because they are highly self-referrential.
LICENSE
Copyright (C) 2002 David Muir Sharnoff <muir@idiom.com> This module may
be licensed on the same terms as Perl itself.
--
--
Notice: Your mouse has been moved. Windows will now restart so this
change can take effect.
-----= 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: Mon, 26 May 2003 21:33:27 -0500
From: "Eric J. Roode" <sdn@comcast.net>
Subject: ANNOUNCE: Config::Vars, v0.01
Message-Id: <nspkq-qkk.ln1@red.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
I have just uploaded a new module, Config::Vars, to CPAN. It
eliminates some tedious repetition when writing perl configuration
variable modules.
>From the README:
Config/Vars version 0.01
========================
Config::Vars makes it easier to declare and initialize configuration
variables in a central perl module. Without Config::Vars, you have
to
list each variable name three times in order for it to be usable
from
every module in your program. You have to list it on a "use vars"
or
"our" declaration, you have to add it to @EXPORT or @EXPORT_OK, and
you have to initalize the variable.
With Config::Vars, instead of:
use strict;
package MyVars;
use Exporter;
use vars qw(@ISA @EXPORT_OK $foo @bar %fred);
@ISA = qw(Exporter);
@EXPORT_OK = qw($foo @bar %fred);
$foo = 42;
@bar = (1, 2, 3, 4, 5);
%fred = map {$_=>1} @bar;
You can do:
use strict;
package MyVars;
use Config::Vars;
var $foo = 7;
var @bar = (1, 2, 3, 4, 5);
var %fred = map {$_=>1} @bar;
@ISA, "use Exporter", @EXPORT_OK, and "use vars" are all taken care
of
for you. Note that your module must still end with a true value.
--
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----= 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: Tue, 27 May 2003 07:26:29 -0000
From: muir@idiom.com
Subject: ANNOUNCE: Net::Netmask version 1.9003
Message-Id: <htpkq-dhn.ln1@red.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
You can find this in CPAN at
http://www.cpan.org/authors/id/MUIR/modules/Net-Netmask-1.9003.tar.gz
or (if the announcement beats CPAN's mirror) at
ftp:://ftp.idiom.com/users/muir/CPAN/modules/Net-Netmask-1.9003.tar.gz
-Dave
...CHANGELOG...................................................
Roman Shishkin <roman@rt.mipt.ru> provided several (public exported)
functions for looking at network tables:
dumpNetworkTable()
checkNetblock()
Inspired: changing findOuterNetblock() so it can take a block
as it's IP address.
Bugfix: notice that '218.0.0.0 - 221.255.255.255' isn't a valid
netmask. Reported by Dan Wright <wright@smx.pair.com>.
Bugfix: could not specify network '0.0.0.0-255.255.255.255'. Fix
from Dominic Mitchell <dom@semantico.com>.
Added ->sameblock() from Martin Lorensen <martin@lorensen.dk>
Added ->cmpblocks().
Added overloaded stringification so that blocks stringify to their
description.
Added overloaded block comparision so that blocks can be compared and
sorted.
Added hostmask syntax a.b.c.d#hostmask - Martin Lorensen <martin@lorensen.dk>
Bugfix: t/badnets.t was missing from the MANIFEST.
Some spelling and typo mistakes fixed in the documentation.
Change the license to make the Debian folks happy. Interface through
Jonas Smedegaard <dr@jones.dk>.
...POD.........................................................
NAME
Net::Netmask - parse, manipulate and lookup IP network blocks
SYNOPSIS
use Net::Netmask;
$block = new Net::Netmask (network block)
$block = new Net::Netmask (network block, netmask)
$block = new2 Net::Netmask (network block)
$block = new2 Net::Netmask (network block, netmask)
print $block; # a.b.c.d/bits
print $block->base()
print $block->mask()
print $block->hostmask()
print $block->bits()
print $block->size()
print $block->maxblock()
print $block->broadcast()
print $block->next()
print $block->match($ip);
print $block->nth(1, [$bitstep]);
if ($block->sameblock("network block")) ...
if ($block->cmpblocks("network block")) ...
for $ip ($block->enumerate([$bitstep])) { }
for $zone ($block->inaddr()) { }
my $table = {};
$block->storeNetblock([$table])
$block->deleteNetblock([$table])
$block = findNetblock(ip, [$table])
$block = findOuterNetblock(ip, [$table])
@blocks = findAllNetblock(ip, [$table])
if ($block->checkNetblock([$table]) ...
$block2 = $block1->findOuterNetblock([$table])
@blocks = range2cidrlist($beginip, $endip);
@listofblocks = cidrs2contiglists(@blocks);
@sorted_ip_addrs = sort_by_ip_address(@unsorted_ip_addrs)
DESCRIPTION
Net::Netmask parses and understands IPv4 CIDR blocks. It's built with an
object-oriented interface. Nearly all functions are methods that operate
on a Net::Netmask object.
There are methods that provide the nearly all bits of information about
a network block that you might want.
There are also functions to put a network block into a table and then
later lookup network blocks by IP address in that table. There are
functions to turn a IP address range into a list of CIDR blocks. There
are functions to turn a list of CIDR blocks into a list of IP addresses.
There is a function for sorting by text IP address.
CONSTRUCTING
Net::Netmask objects are created with an IP address and optionally a
mask. There are many forms that are recognized:
'216.240.32.0/24' The preferred form.
'216.240.32.0:255.255.255.0'
'216.240.32.0-255.255.255.0'
'216.240.32.0', '255.255.255.0'
'216.240.32.0', '0xffffff00'
'216.240.32.0 - 216.240.32.255'
'216.240.32.4' A /32 block.
'216.240.32' Always a /24 block.
'216.240' Always a /16 block.
'140' Always a /8 block.
'216.240.32/24'
'216.240/16'
'default' 0.0.0.0/0 (the default route)
'216.240.32.0#0.0.31.255' A hostmask (as used by Cisco
access-lists).
There are two constructor methods: "new" and "new2". The difference is
that "new2" will return undef for invalid netmasks and "new" will return
a netmask object even if the constructor could not figure out what the
network block should be.
With "new", the error string can be found as $block->{'ERROR'}. With
"new2" the error can be found as Net::Netmask::errstr or
$Net::Netmask::error.
METHODS
->desc() Returns a description of the network block. Eg:
216.240.32.0/19. This is also available as
overloaded stringification.
->base() Returns base address of the network block as a
string. Eg: 216.240.32.0. Base does not give an
indication of the size of the network block.
->mask() Returns the netmask as a string. Eg:
255.255.255.0.
->hostmask() Returns the host mask which is the opposite of
the netmask. Eg: 0.0.0.255.
->bits() Returns the netmask as a number of bits in the
network portion of the address for this block.
Eg: 24.
->size() Returns the number of IP addresses in a block.
Eg: 256.
->broadcast() The blocks broadcast address. (The last IP
address inside the block.) Eg: 192.168.1.0/24
=> 192.168.1.255
->next() The first IP address following the block. (The
IP address following the broadcast address.)
Eg: 192.168.1.0/24 => 192.168.2.0
->match($ip) Returns a true if the IP number $ip matches the
given network. That is, a true value is
returned if $ip is between base() amd
broadcast(). For example, if we have the
network 192.168.1.0/24, then
192.168.0.255 => 0
192.168.1.0 => "0 "
192.168.1.1 => 1
...
192.168.1.255 => 255
$ip should be a dotted-quad (eg:
"192.168.66.3")
It just happens that the return value is the
position within the block. Since zero is a
legal position, the true string "0 " is
returned in it's place. "0 " is numerically
zero though. When wanting to know the position
inside the block, a good idiom is:
$pos = $block->match($ip) || die;
$pos += 0;
->maxblock() Much of the time, it is not possible to
determine the size of a network block just from
it's base address. For example, with the
network block '216.240.32.0/27', if you only
had the '216.240.32.0' portion you wouldn't be
able to tell for certain the size of the block.
'216.240.32.0' could be anything from a '/23'
to a '/32'. The maxblock() method gives the
size of the largest block that the current
block's address would allow it to be. The size
is given in bits. Eg: 23.
->enumerate([$bitstep) Returns a list of all the IP addresses in the
block. Be very careful not to use this function
of large blocks. The IP addresses are returned
as strings. Eg: '216.240.32.0', '216.240.32.1',
... '216.240.32.255'.
If the optional argument is given, step through
the block in increments of a given network
size. To step by 4, use a bitstep of 30 (as in
a /30 network).
->nth($index, [$bitstep])
Returns the nth element of the array that
enumerate would return if it were called. So,
to get the first usable address in a block, use
nth(1). To get the broadcast address, use
nth(-1). To get the last usable adress, use
nth(-2).
->inaddr() Returns an inline list of tuples. There is a
tuple for each DNS zone name in the block. If
the block is smaller than a /24, then the zone
of the enclosing /24 is returned.
Each tuple contains: the DNS zone name, the
last component of the first IP address in the
block in that zone, the last component of the
last IP address in the block in that zone.
Examples: the list returned for the block
'216.240.32.0/23' would be:
'32.240.216.in-addr.arpa', 0, 255,
'33.240.216.in-addr.arpa', 0, 255. The list
returned for the block '216.240.32.64/27' would
be: '32.240.216.in-addr.arpa', 64, 95.
->sameblock($block) Compares two blocks. The second block will be
auto-converted from a string if it isn't
already a Net::Netmask object. Returns 1 if
they are identical.
->cmpblocks($block) Compares two blocks. The second block will be
auto-converted from a string if it isn't
already a Net::Netmask object. Returns -1, 0,
or 1 depending on how they compare.
->storeNetblock([$t]) Adds the current block to an table of network
blocks. The table can be used to query which
network block a given IP address is in.
The optional argument allows there to be more
than one table. By default, an internal table
is used. If more than one table is needed, then
supply a reference to a HASH to store the data
in.
->deleteNetblock([$t]) Deletes the current block from a table of
network blocks.
The optional argument allows there to be more
than one table. By default, an internal table
is used. If more than one table is needed, then
supply a reference to a HASH to store the data
in.
->checkNetblock([$t]) Returns true of the netblock is already in the
network table.
METHOD/FUNCTION COMBOS
findOuterNetblock(ip, [$t])
Search the table of network blocks (created
with storeNetBlock) to find if any of them
contain the given IP address. The IP address
can either be a string or a Net::Netmask object
(method invocation). If more than one block in
the table contains the IP address or block, the
largest network block will be the one returned.
The return value is either a Net::Netmask
object or undef.
OVERLOADING
"" Strinification is overloaded to be the ->desc()
method.
cmp Numerical and string comparisions have been
overloaded to the ->cmpblocks() method. This
allows blocks to be sorted without specifying a
sort function.
FUNCTIONS
sort_by_ip_address This function is included in "Net::Netmask"
simply because there doesn't seem to be a
better place to put it on CPAN. It turns out
that there is one method for sorting
dotted-quads ("a.b.c.d") that is faster than
all the rest. This is that way. Use it as
"sort_by_ip_address(@list_of_ips)".
findNetblock(ip, [$t]) Search the table of network blocks (created
with storeNetBlock) to find if any of them
contain the given IP address. The IP address is
expected to be a string. If more than one block
in the table contains the IP address, the
smallest network block will be the one
returned.
The return value is either a Net::Netmask
object or undef.
findAllNetblock(ip, [$t])
Search the table of network blocks (created
with storeNetBlock) to find if any of them
contain the given IP address. The IP address is
expected to be a string. All network blocks in
the table that contain the IP address will be
returned.
The return value is a list of Net::Netmask
objects.
dumpNetworkTable([$t]) Returns a list of the networks in a network
table (as created by ->storeNetblock()).
range2cidrlist($startip, $endip)
Given a range of IP addresses, return a list of
blocks that span that range.
For example, range2cidrlist('216.240.32.128',
'216.240.36.127'), will return a list of
Net::Netmask objects that corrospond to:
216.240.32.128/25
216.240.33.0/24
216.240.34.0/23
216.240.36.0/25
cidrs2contiglists(@listOfBlocks)
"cidrs2contiglists" will rearrange a list of
Net::Netmask objects such that contiguous sets
are in sublists and each sublist is
discontigeous with the next.
For example, given a list of Net::Netmask
objects corresponding to the following blocks:
216.240.32.128/25
216.240.33.0/24
216.240.36.0/25
"cidrs2contiglists" will return a list with two
sublists:
216.240.32.128/25 216.240.33.0/24
216.240.36.0/25
The behavior for overlapping blocks is not
currently defined.
LICENSE
Copyright (C) 1998, 2001 David Muir Sharnoff. License hereby granted for
anyone to use, modify or redistribute this module at their own risk.
Please feed useful changes back to muir@idiom.com.
--
--
Notice: Your mouse has been moved. Windows will now restart so this
change can take effect.
-----= 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: Wed, 28 May 2003 23:05:21 +0200
From: Steffen Mller <sv99oya02@sneakemail.com>
Subject: ANNOUNCE: Sub::Assert v1.10
Message-Id: <ovpkq-7nm.ln1@red.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
Sub::Assert v1.10 has been released to CPAN.
Sub::Assert adds to Perl's repertoire a feature that has previously only
been availlable through Damian Conway's Class::Contract module which
requires you to adopt a specific coding style.
The Sub::Assert module aims at providing design-by-contract like
subroutine pre- and postconditions. Furthermore, it allows restricting
the subroutine's calling context. This is meant to prevent some of the
debugging hassle before you get in the questionable pleasure of dealing
with it.
You may find this module on CPAN or at http://steffen-mueller.net
Steffen
--
*_=*DATA;seek+_,0,0;print<_>;
__DATA__
What's a quine?
-----= 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: Fri, 30 May 2003 18:38:32 +0100
From: Cannabis Coffee Shops <nntp@cannabiscoffeeshops.co.uk.INVALID>
Subject: Re: APP: perl script editor
Message-Id: <MPG.1941a76ee235a67a98adda@news.newshosting.com>
<comp.lang.perl.misc , AcCeSsDeNiEd ,
dillon@SpamMinuSaccessdenied.darktech.org>
> I've been using EditPlus for 3 years now.
> It runs on M$ Windoze.
>
Thanks will have a look later .
SSeditor seems the most likable from the ones i've looked at so far .
--
http://www.cannabiscoffeeshops.co.uk
------------------------------
Date: 30 May 2003 08:51:57 -0700
From: bouton@udel.edu (K Bouton)
Subject: Hard text file to parse
Message-Id: <41985753.0305300751.ad44dc9@posting.google.com>
I need to parse this text file and am lost on how to do it.
Any help? I've tried looping, substitution ... and...
I want to get these into a text file so I can insert them into a
database
example FILE>>
DESCRIPTION
Multiple linear regression of y on x
REQUIRED ARGUMENTS
y dependent variable: n x 1 vector
x independent variables: n x p array (p < n)
OPTIONAL ARGUMENT
alpha significance level. Default value is 5%
OUTPUT
a = (a_1, .., a_p, a_(p+1)) p+1-element vector of regression
coefficients. The last element is the constant term.
stderr standard error on the elements of a
res the residual vector
COMMENTS The columns of the array x should not be dependent.
BACKGROUND/REFERENCES
EXAMPLE x = randn (10, 1); y = randn (10, 1) + 2.;
[a, stderr] = myregress (x, y);
AUTHOR/CONTACT J. Doe@here.ac.uk,
DATE March 2003.
<< end example file
The output I want is
DESCRIPTION:Multiple linear regression of y on x
REQUIRED ARGUMENTS_1:y
REQUIRED ARGUMENTS_DESCRIPTION_1:dependent variable: n x 1 vector
REQUIRED ARGUMENTS_2:x
REQUIRED ARGUMENTS_DESCRIPTION_2:independent variables: n x p array
(p < n)
..etc can have many
OPTIONAL ARGUMENTS_1:alpha
OPTIONAL ARGUMENTS_DESCRIPTION_1:significance level. Default value is
5%
... etc - can have many
OUTPUT_1: a = (a_1, .., a_p, a_(p+1))
OUTPUT_description_1:p+1-element vector of regression coefficients.
The last element is the constant term.
OUTPUT_2:stderr
OUTPUT_description_3:standard error on the elements of a
OUTPUT_3:res
OUTPUT_description_3:the residual vector
COMMENTS:The columns of the array x should not be dependent.
BACKGROUND/REFERENCES: list if any
EXAMPLE:x = randn (10, 1); y = randn (10, 1) + 2.;\nl[a, stderr] =
myregress (x, y);
AUTHOR/CONTACT:J. Doe@here.ac.uk,
DATE:March 2003.
-----
Thanks
K
------------------------------
Date: Tue, 27 May 2003 10:26:50 +0200
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: make.pl 0.5 released
Message-Id: <stpkq-mht.ln1@red.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
Here comes a make in everybody's favourite programming language, Perl, giving you the best of both worlds. You can use it to write a plain makefile, though in Perl syntax. Or, at the other extreme, you can write a program, that among others does a few file-dependency driven things.
New in this version:
- Small beginning towards classical make environment variables made, with $CC, $CFLAGS, $CXX and $CXXFLAGS.
- New arguments --first and --last of function sh.
- New functions shellparse (shell-compatible where shellwords.pl is not) and determine.
- once code now performed in list context.
- Greatly optimized deferred variables processing.
http://dapfy.bei.t-online.de/make.pl/
http://www.cpan.org/scripts/
coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer
-- GPL 3: take the wind out of Palladium's sails! --
------
-- My other stuff here too, sawfish, make.pl...: --
------
-- http://dapfy.bei.t-online.de/ --
-----= 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: 30 May 2003 10:00:52 -0700
From: dangrazier@hotmail.com (Dan Grazier)
Subject: Re: Makefile corrupted after running perl Makefile.PL.
Message-Id: <e376fb98.0305300900.3c094d09@posting.google.com>
zorans@kekec2.e5.ijs.si (ZorroFree) wrote in message news:<52f6973c.0305280357.5830a13e@posting.google.com>...
> randy@theoryx5.uwinnipeg.ca (Randy Kobes) wrote in message news:<slrnbd6vbv.3ra.randy@theoryx5.uwinnipeg.ca>...
> > On 27 May 2003 06:56:48 -0700, ZorroFree <zorans@kekec2.e5.ijs.si> wrote:
> > >Good day there.
> > >
> > >Although I am certaintly very new to anythink concerning Perl,
> > >I think I've got a very essential Makefile corruption problem.
> > >The problem allready occured to me when trying to build two
> > >distinct products (actualy Time:HiRes module and SpamAssasin
> > >anti spam utility).
> > >When I commit perl Makefile.PL, as a result I get Makefile
> > >which is very odd: single quotes are placed incorrectly arround
> > >values to variables, some variables are set strange (most probably
> > >vandalized) directory values (for example /u or ib/perl5) and
> > >lines with suspicious meaning are inserted between other lines
> > >that makes sense according to Makefile syntax.
> >
> > There was another post recently that reported a similar
> > problem. It may be due to a corrupt rpm. What happens if
> > you do, for example,
> > bash$ perl -V:cc
> > Does it report an error? If you look through Perl's Config.pm
> > (under something like /usr/lib/perl5/5.x.x/i686-linux/), can
> > you see if there's any unmatched quotes? The ultimate solution
> > may be to rebuild Perl yourself.
>
>
> Randy,
>
> thank you very much for your reply. For the sake of resolving this
> problem I have to answer questions you set.
>
> Everythink is O.K. Statement perl -V:cc doesn't return errors and all
> Config.pm files I could find in /usr/lib/perl5 tree are fine, at least
> what concerns quotes.
>
> I assume it is realy the best practice to rebuild perl from source.
>
> Zoran
Zoran,
I had experienced this problem as well with RH 9 and Net::SSLeay. In
short the solution was to change the LANG env variable to be
non-utf8... specifically I "set LANG=en_US" to change it from
en_US.utf8(if memory serves me). Once that was done, the Makefile
issues were resolved. Hope this helps.
Dan
------------------------------
Date: Fri, 30 May 2003 17:41:33 +0200
From: "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Recursion and Filehandles
Message-Id: <3ed77b7e.0@juno.wiesbaden.netsurf.de>
DQoiTWljaGVsZSBEb25kaSIgPGJpay5taWRvQHRpc2NhbGluZXQuaXQ+IHdyb3RlLi4uDQo+IE9u
IFdlZCwgMjEgTWF5IDIwMDMgMTk6MDc6MjMgKzAyMDAsICJUaG9tYXMgS3JhdHoiDQo+IDxUaG9t
YXNLcmF0ekBSRU1PVkV3ZWJDQVBTLmRlPiB3cm90ZToNCj4gDQo+ID5JIGRvbid0IHRoaW5rIGxv
Y2FsaXppbmcgYSBmaWxlaGFuZGxlIHRvIGJlIHVuZWxlZ2FudCwgYnV0IEkgd291bGQgcHJvYmFi
bHkgdXNlIHRoZSBGaWxlSGFuZGxlIG1vZHVsZSB0byBnZXQgcHJvcGVyIGxleGljYWwNCj4gDQo+
IF5eXl5eXl5eXl4NCj4gPmZpbGVoYW5kbGVzIGFzIGluOg0KPiANCj4gRXhjZXB0IHRoYXQgaXQg
aXMgbm90IG5lY2Vzc2FyeSBhbnltb3JlLCBhbmQgYXMgc29tZW9uZSBlbHNlDQo+IG1lbnRpb25l
ZCwgaXQgaXMgZXZlbiBpbiB0aGUgZmFxOiAiSG93IGNhbiBJIG1ha2UgYSBmaWxlaGFuZGxlIGxv
Y2FsDQo+IHRvIGEgc3Vicm91dGluZT9bLi4uXSIuDQoNClllcyBJIGtub3csIGJ1dCBmb3IgdGhv
c2Ugc3RpbGwgaGF2aW5nIHRvIGNvZGUgZm9yIHByZSA1LjYuMCB2ZXJzaW9ucywNCkZpbGVIYW5k
bGUgaXMgdGhlIHBvcnRhYmxlIHdheS4gU2luY2UgSSBoYXZlIHRvIGRvIHRoYXQgZnJlcXVlbnRs
eSwNCml0IGlzIHN0aWxsIHRoZSBmaXJzdCB3YXkgdGhhdCBzcHJpbmdzIHRvIG1pbmQuIA0KDQpB
bmQgY2hhbmdlcyBsaWtlIHRoaXMgb25lIHNlZW0gdG8gZW50ZXIgbXkgbWluZCBvbiBhIG1vcmUg
Z2VvbG9naWNhbA0KdGltZSBzY2FsZSA6LSkNCg0KQUZBSUsgdGhlIGZhcSB3YXMgY2hhbmdlZCBu
b3QgdW50aWwgNS44LjAuDQoNClRob21hcw==
------------------------------
Date: Fri, 30 May 2003 12:25:27 -0500
From: Lance Hoffmeyer <lance-news@augustmail.com>
Subject: regex-new line when using /s NEW ??
Message-Id: <hNicnSXb7amICUqjXTWcoA@august.net>
I have another questions regarding \n. I am trying to grab the first
percentage (the numbers with ??.?). The regex below will work but I am
looking for something more global.
$file2 =~ /TABLE\s+39.*?FINE JEWELRY.*?TOP 2
BOX.*?\s\s\s\s\s\s\s\s\s\s.*?(?:(\d{1,3}\.\d|\- )[A-T\s]+){1}/s;my
$P07A079=Round($1,0)/100;
I would rather say something like:
$file2 =~ /TABLE\s+37.*?FINE JEWELRY.*?\n.*?\n.*?(?:(\d{1,3}\.\d|\-
)[A-T\s]+){1}/s;my $P07A079=Round($1,0)/100;
So that the regex finds the line with FINE JEWELRY and then basically
finds two newlines (or one newline in some cases but I will leave that
for another time) and then starts the search for a number. The above
line does not work though. The regex either does not recognize the \n
or the .*? is causing a problem in the search? I basically don't care
about the line with TOP 2 BOX and the numbers on that line. I want to
get to the line with the percentages. Any ideas on how I might rewrite
the regex to do the above mentioned instead of the hack I have above?
Lance
TABLE 37
A PLACE TO BUY SHOES
TOP 2 BOX (NET) 11 3 4 8 15 17 29 17
34.5 18.7 23.4 56.0 46.7 48.0 51.6 33.8
A PLACE TO BUY FINE JEWELRY
TOP 2 BOX (NET) 36 4 32 32 5 4 - 1
43.0 36.5 30.8T 44.0 36.2 29.2 - 33.6
------------------------------
Date: 30 May 2003 18:46:34 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: regex-new line when using /s NEW ??
Message-Id: <u9of1ktjid.fsf@wcl-l.bham.ac.uk>
Lance Hoffmeyer <lance-news@augustmail.com> writes:
> The above line does not work though.
Show us!
Produce a _minimal_ but _complete_ script that illustrates your point
and post it _unaltered_.
Just to be kind I cut the line in question into a test script, fed it
your specimen input data. It worked exactly as you wanted.
So not only did you waste the time of anyone who wants to help them by
making each of them construct the test script that you should have
posted in the first place but you further wasted our time because
having done so the script does not reproduce the problem you describe.
Please see the posting guidelines.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 30 May 2003 15:10:52 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: scanning logfiles
Message-Id: <pqsedv8u0l18qhv0mq4j67oablegvb5gbr@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Whilst lounging around on 30 May 2003 07:53:25 -0700,
the_second_shadow@yahoo.com (shadow) amazingly managed to produce the
following with their Etch-A-Sketch:
> Hi
> I'm pretty new to perl and have to write a script which scans the
> new entries (since the last scan)in logfiles for a provided
> pattern. If this pattern is found it should alert a user via email.
>
> It would be great if anyone has an already existing script which
> can do the job so i could have a look at it and learn something. If
> not can anyone give me some advice on how I should solve this ?
>
> thanks a lot in advance.
tss,
I have a script you could probably use as a base for what you're
after.
I use it to generate http://tk.digiserv.net/webana-output.txt.
It scans my Apache access_log for certain patterns (in this case,
worms) and I get it to output as a "patterned graph" as such. You
could more than likely use what's there and then work out the piping
(|) through sendmail or the likes to alert you rather than plotting a
symbol on a graph as I have done. You'd also need to include a method
of noting where a start & finish mark would be (perhaps record the
last line number in a "config file" and start from that line on the
next run).
The script's pretty small, and not complex.
Feel free to drop me a mail if you'd like a copy =)
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0
iQA/AwUBPtd0eWfqtj251CDhEQJsaACg9YS9P3z1tVEEkLOeOo8EMo0DWt8An1q1
fcSawxMRud6zNfyy5JZtAxXd
=nUZ6
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
------------------------------
Date: Fri, 30 May 2003 10:11:07 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: scanning logfiles
Message-Id: <slrnbdet4b.35s.tadmc@magna.augustmail.com>
shadow <the_second_shadow@yahoo.com> wrote:
> I'm pretty new to perl and have to write a script which scans the new
> entries (since the last scan)in logfiles
How can you determine the age of the entries?
What is the format of the logfile?
> for a provided pattern.
What kind of pattern?
Can the pattern span multiple lines?
Can the pattern include regex metacharacters?
> If
> this pattern is found it should alert a user via email.
perldoc -q mail
"How do I send mail?"
> can anyone give me some advice on how I should solve this ?
No, because we do not have enough information to be able to help you.
The value of the answers you get will be directly proportional to
the quality of the problem specification that you provide.
No spec, no code.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 May 2003 17:34:32 +0200
From: Winfried Koenig <w.koenig@acm.org>
Subject: Re: scanning logfiles
Message-Id: <3ED77A08.2050607@acm.org>
shadow wrote:
> Hi
> I'm pretty new to perl and have to write a script which scans the new
> entries (since the last scan)in logfiles for a provided pattern. If
> this pattern is found it should alert a user via email.
>
> It would be great if anyone has an already existing script which can
> do the job so i could have a look at it and learn something. If not
> can anyone give me some advice on how I should solve this ?
>
> thanks a lot in advance.
perldoc -q tail
perldoc perlre
perldoc perlretut
perldoc -q 'send mail'
Winfried
--
Winfried Koenig +49 69 868707 w.koenig@acm.org
Perl - Beratung und Programmierung in Unixumgebung
------------------------------
Date: 30 May 2003 11:00:59 -0700
From: carterave@yahoo.com (Jim Carter)
Subject: To get rid of a trailing empty line in the output...
Message-Id: <9c2a26b6.0305301000.2d56d725@posting.google.com>
Hi all I have the below little script on Windows:
------------------------------------------------------------------
#! C:/perl/bin/perl
open (OUT, ">file2.txt") || die "Can not write ot the file:$!";
foreach (<DATA>)
{
s/^\s+$//g; ## delete empty lines
print OUT if 1 == ++$seen{$_}; ## delete duplicate lines
}
__DATA__
hi htere
hekko
hello
are yo uthere
how are you
I am there
hello
hekko
## an empty line here
## an empty line here
## an empty line here
--------------------------
The output I get is:
-------------------
hi htere
hekko
hello
are yo uthere
how are you
I am there
## an empty line here
-----------------
In the output, after the last line, "I am there", it has an empty
line.
Withoout parsing the output one more time, how can I get rid of this
empty line with just above loop?
Thanks,
Jim
------------------------------
Date: 30 May 2003 10:23:39 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: variable for current line number (of script)
Message-Id: <etok7c8xv1w.fsf@wormtongue.emschwar>
Eric Wilhelm <ericw@nospam.ku.edu> writes:
> except that warn() prints to stderr, which breaks any logging of the
> output with a > redirect.
*shrug* so log with 2>&1 or 2> if you like.
> It might be that warn() is what you want in some instances, but that
> __LINE__ is what you want in others.
I'm not saying you're wrong, just that I've never felt the need to use
it.
> Funny, what got me looking for this was that I was putting a \n in my
> warns and not getting the line number. Now I know more about warn and
> Perl and have some new tricks to use when the need comes along. Maybe a
> self-modifying script?
Eek. My motto with Perl (well, anything really) is, "What happens to
the poor bastard who has to maintain this when I get hit by a bus?"
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
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 5064
***************************************