[24179] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6371 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 11:05:41 2004

Date: Wed, 7 Apr 2004 08:05:09 -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           Wed, 7 Apr 2004     Volume: 10 Number: 6371

Today's topics:
        [VERY OT] a linguistic question (.sig-related, xposted) <bik.mido@tiscalinet.it>
        ANNOUNCE: DBIx::MSAccess::Convert2Db V 1.03 <ron@savage.net.au>
        ANNOUNCE: Net::Netmask version 1.9008 <muir@idiom.com>
        arrays of parameters in CGI.pm (another one)
    Re: arrays of parameters in CGI.pm <ittyspam@yahoo.com>
    Re: arrays of parameters in CGI.pm (another one)
        Autoflush for DB_FILE to share a hash among cooperating (Axel Boldt)
    Re: change meta tag description in all htm documents in <bik.mido@tiscalinet.it>
    Re: Extract data using Curl Unix Command & Perl Script  (Fiaz Idris)
    Re: Extract data using Curl Unix Command & Perl Script  (Fiaz Idris)
    Re: Filehandles Referenced with a Variable <mikeflan@earthlink.net>
    Re: Help needed:: Openldap issue - -  LDAP_OPERATIONS_E (Durairaj Avasi)
    Re: Open GUI transcript window <zentara@highstream.net>
        Optimizing using precompiled Perl program? (Yash)
    Re: Optimizing using precompiled Perl program? (Anno Siegel)
    Re: Optimizing using precompiled Perl program? (Randal L. Schwartz)
    Re: Regular expression question <tadmc@augustmail.com>
    Re: Regular expression question (Kapil Khosla)
    Re: Regular expression question <tore@aursand.no>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 07 Apr 2004 15:15:40 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <90o770tpk731n8dev5rg1ihto441dlsbuv@4ax.com>

I'm sorry for this OT, but these seemed to me the best NGs, amongst
those that I subscribe, to ask this question, and I don't know where
else I could do it.

I like to gather witty cmts or otherwise interesting sentences from
USENET posts to quote in .sigs: now I have a doubt about the
preposition to use when citing the author, i.e. should I use

  > utterly stupid claim
  witty cmt
  - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
                     ^^

or

  > utterly stupid claim
  witty cmt
  - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
                     ^^
                     
Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Wed, 7 Apr 2004 07:07:05 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::MSAccess::Convert2Db V 1.03
Message-Id: <Hvsq9A.pvD@zorch.sf-bay.org>

The pure Perl module DBIx::MSAccess::Convert2Db V 1.03
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:

1.02  Wed Apr  7 11:46:41 2004
	- Recent changes to DBIx::SQLEngine resulted in the following SQL being generated to
		determine the names of the columns in the Access database:
			select * from `$table_name` limit 1
		but the limit clause does not work with Access. I have replaced that SQL with:
			select top 1 * from `$table_name`
	- To build this module, you will now need Module::Build
--
Cheers
Ron Savage, ron@savage.net.au on 7/04/2004
http://savage.net.au/index.html




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

Date: Tue, 6 Apr 2004 22:17:08 GMT
From: David Muir Sharnoff <muir@idiom.com>
Subject: ANNOUNCE: Net::Netmask version 1.9008
Message-Id: <Hvsq8n.HF2@zorch.sf-bay.org>


You can find this in CPAN at 

http://www.cpan.org/authors/id/MUIR/modules/Net-Netmask-1.9008.tar.gz

or (until CPAN picks it up) at

ftp:://ftp.idiom.com/users/muir/CPAN/modules/Net-Netmask-1.9008.tar.gz

-Dave


 ...CHANGELOG...................................................

Added cidrs2inverse() which will find the gaps in a list of blocks.

Based on a request from Howard Jones <howard.jones at network-i.net>
the tag() method was added.  It allows you to store your own data in
a Net::Netmask object.  (Of course, you could have anyway as long as you
didn't use the keys 'IBASE' or 'BITS')

Long ago, Alexandros M Manoussakis <amm2 at ini.cmu.edu> reported a bug
that findAllNetblock would often return the same block multiple times.  
Fixed.

Based on requests from Alexandros M Manoussakis <amm2 at ini.cmu.edu>
and Lamprecht Andreas <andreas.a.lamprecht at siemens.com> the
undefined behavior for overlapping blocks with cidrs2contiglists
is no longer.  Such blocks will be in the same sublist.

Based on a requests from Tom Rudnick <trudnick at itc.nrcs.usda.gov>
and Anthony Pardini <tony at pardini.org> new function was added:
cidrs2cidrs().  cidrs2cidrs will condense a set of netblocks by
combining blocks together that make up larger blocks.

Anthony Pardini <tony at pardini.org>, Frank Tegtmeyer <fte @ fte.to>
and George Walker <gwalker at irish-times.com> pointed me to a bug
with the contains() method.  Fixed.


 ...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])
            @missingblocks = $block->cidrs2inverse(@blocks)

            $block = findNetblock(ip, [$table])
            $block = findOuterNetblock(ip, [$table])
            @blocks = findAllNetblock(ip, [$table])
            if ($block->checkNetblock([$table]) ...
            $block2 = $block1->findOuterNetblock([$table])
            @blocks = dumpNetworkTable([$table])

            @blocks = range2cidrlist($beginip, $endip);
            @blocks = cidrs2cidrs(@blocks_with_dups)

            @listofblocks = cidrs2contiglists(@blocks);

            @blocks = sort @blocks
            @blocks = sort_network_blocks(@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

    ->first() & ->last()     Synonyms for ->base() and ->broadcast()

    ->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 which one has the lower base
                             address or which one is larger if they have the
                             same base address.

    ->contains($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 the
                             second block fits inside the first block.
                             Returns 0 otherwise.

    ->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.

    ->tag($name [, $value])  Tag network blocks with your own data. The
                             first argument is the name of your tag (hash
                             key) and the second argument (if present) is
                             the new value. The old value is returned.

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.

    cidrs2inverse(block, @listOfBlocks)
                             Given a block and a list of blocks,
                             cidrs2inverse() will return a list of blocks
                             representing the IP addresses that are in the
                             block but not in the list of blocks. It finds
                             the gaps.

                             The block will be auto-converted from a string
                             if it isn't already a Net::Netmask object. The
                             list of blocks should be Net::Netmask objects.

                             The return value is a list of Net::Netmask
                             objects.

OVERLOADING
    Overloading doesn't seem to work completeley on perl before version
    5.6.1. The test suite doesn't test overloading before that. At least for
    sort.

    ""                       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)". That was
                             the theory anyway. Someone sent a faster
                             version ...

    sort_network_blocks      This function is a function to sort
                             Net::Netmask objects. It's faster than the
                             simpler "sort @blocks" that also works.

    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

                             Overlapping blocks will be placed in the same
                             sublist.

    cidrs2cidrs(@listOfBlocks)
                             "cidrs2cidrs" will collapse a list of
                             Net::Netmask objects by combining adjacent
                             blocks into larger blocks. It returns a list of
                             blocks that covers exactly the same IP space.
                             Overlapping blocks will be collapsed.

LICENSE
    Copyright (C) 1998-2003 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.

-- 




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

Date: Wed, 07 Apr 2004 13:04:56 +0100
From: "Steve (another one)" <y66y@56yu4b6.com>
Subject: arrays of parameters in CGI.pm
Message-Id: <c50qp9$e57$1@news.liv.ac.uk>

Dear all

I have a script which writes an html form using CGI.pm. It is very 
convenient to have multiple fields with the same name from which I can 
extract values by treating them as an array. The problem is that on 
subsequent submissions of the form, all values default to the first. The 
only way I can reset them to the value that they previously had is to 
use javascript to assign their values to those found in the parameters 
array. This is very ugly, there must be a better way, does anyone have 
any suggestions ?

Thanks

Below is a minimal example, enter different values in the boxes and 
submit - values are sucessfully recovered but defaults revert to the 
value on box 0.

#!/usr/bin/perl

use strict;
use warnings;
use CGI;

my $q = new CGI;

my @param_names = $q->param;
my %myparams;

foreach (@param_names){
      (@{$myparams{$_}}=$q->param($_))=~ s/[^a..z,A..Z]/_/g;
                        }

print $q->header(-type =>"text/html", -expires=>"-1d"),
       $q->start_html(),
       $q->start_form(-method=>'post');

for my $cnt (0..5) {print "box $cnt ",
      $q->textfield(-name=>'text'),'<br>'}

print '<br><br>',
       $q->submit(-name=>'submitbutton', -value=>'Submit'),
       $q->endform;

foreach (@{$myparams{text}}) {print "<br>$_\n"}

print $q->end_html;




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

Date: Wed, 7 Apr 2004 09:52:30 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: arrays of parameters in CGI.pm
Message-Id: <20040407094933.S14622@dishwasher.cs.rpi.edu>

On Wed, 7 Apr 2004, Steve (another one) wrote:

> Dear all
>
> I have a script which writes an html form using CGI.pm. It is very
> convenient to have multiple fields with the same name from which I can
> extract values by treating them as an array. The problem is that on
> subsequent submissions of the form, all values default to the first. The
> only way I can reset them to the value that they previously had is to
> use javascript to assign their values to those found in the parameters
> array. This is very ugly, there must be a better way, does anyone have
> any suggestions ?
>
> Thanks
>
> Below is a minimal example, enter different values in the boxes and
> submit - values are sucessfully recovered but defaults revert to the
> value on box 0.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use CGI;
>
> my $q = new CGI;
>
> my @param_names = $q->param;
> my %myparams;
>
> foreach (@param_names){
>       (@{$myparams{$_}}=$q->param($_))=~ s/[^a..z,A..Z]/_/g;
>                         }
>
> print $q->header(-type =>"text/html", -expires=>"-1d"),
>        $q->start_html(),
>        $q->start_form(-method=>'post');
>
> for my $cnt (0..5) {print "box $cnt ",
>       $q->textfield(-name=>'text'),'<br>'}

$q->textfield(-name=>'text', -override=>1, -value=>$myparams{text}[$cnt])

Because all the text fields are named the same, CGI.pm doesn't know which
value from the parameter list you want to go into any particular field
with that name.  The above code will force the value of the boxes to be
equal to the correct position in the @{myparams{text}} array.  The
-override parameter is necessary to force the text boxes to use the values
you've assigned, rather than the defaults.

>
> print '<br><br>',
>        $q->submit(-name=>'submitbutton', -value=>'Submit'),
>        $q->endform;
>
> foreach (@{$myparams{text}}) {print "<br>$_\n"}
>
> print $q->end_html;


Paul Lalli>


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

Date: Wed, 07 Apr 2004 15:40:48 +0100
From: "Steve (another one)" <y66y@56yu4b6.com>
Subject: Re: arrays of parameters in CGI.pm
Message-Id: <c513tg$gqm$1@news.liv.ac.uk>

> 
> $q->textfield(-name=>'text', -override=>1, -value=>$myparams{text}[$cnt])
> 

Thanks



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

Date: 7 Apr 2004 07:28:16 -0700
From: axelboldt@yahoo.com (Axel Boldt)
Subject: Autoflush for DB_FILE to share a hash among cooperating processes?
Message-Id: <40200384.0404070628.7c720d3b@posting.google.com>

Hello,

I want to share a hash variable among several forked processes.
Ideally I would use threads and threads::shared, but I need LWP which
is not thread-safe. So I thought about using DB_FILE and a hash
variable tied to the same file in each of the processes. If one
process changes the hash variable, all others should see the change
immediately. I.e. I want that the change is immediately flushed to
disk, and that every access to the hash variable takes its value
directly from disk, not from some internal cache. Is that possible? I
have tried the O_SYNC flag for db_open and also the $db->sync() method
to no avail.

If it's not possible, what do people usually do to keep a set of
cooperating processes informed about the results that the other
processes have already computed?

Thanks,
  Axel


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

Date: Wed, 07 Apr 2004 15:15:10 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: change meta tag description in all htm documents including all files in subdirectories
Message-Id: <l6f770h1nom965ind2510fi3k7en91gnhh@4ax.com>

On Tue, 6 Apr 2004 22:30:13 +0200, "Tamara" <tamara@agencija.com>
wrote:

>How can I change meta tag description in all htm documents including all
>files in subdirectories, with using perl on Windows XP?
>E.g. new meta tag is "New meta tag", and I want change it in all htm file
>including htm files in subdirectories.

It is not clear at all what you want to do, but in any case File::Find
seems the way to go, as another poster already suggested. OTOH this is
not an help desk, however please see if you can adapt the following
minimal example to your needs:

  #!/usr/bin/perl
  
  use strict;
  use warnings;
  use File::Find;
  
  my @dirs=grep { -d or !warn "`$_': no such directory!\n" } @ARGV;
  die "Usage: $0 <dir> [<dirs>]\n" unless @dirs;
  
  @ARGV=();
  
  find { no_chdir => 1,
         wanted => sub {
  	   push @ARGV, $_ 
  	     if /\.html?$/ and -f;
         } }, @dirs;
  
  $^I = '.bak';
  s|(</?)meta-tag>|$1actual-tag>|g, print while <>;
  
  __END__


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 7 Apr 2004 06:12:37 -0700
From: ifiaz@hotmail.com (Fiaz Idris)
Subject: Re: Extract data using Curl Unix Command & Perl Script from Webpage
Message-Id: <93c1947c.0404070512.59a6c5c3@posting.google.com>

> a cursory look at the html show that the input field is actually not
> RegistraitonNumber , but rather Exam_Registration_Number
> in addition to that there is a hidden field Codeid set to 'BA'.
> and to be sure, maybe you should also include the button field,
> btn_display=Results
> 
> try that, preferably with a POST
> if it still fails try to set the Referer HTTP header
> 
> gnari

I have tried various different combinations of the following URL
encoded query.

(1)
http://www.chennaionline.com/msuniversity/result.asp?code=BA&Codeid=BA&Exam_Registration_Number=2225765&btn_display=Results

You may try on this page
"http://www.chennaionline.com/msuniversity/result.asp"

I have been successful for example on this page in getting the arrival
flights of airport.

(2)
http://www.hongkongairport.com/eng/flightinfo/real_depinfo.jsp?SearchDestination=All&SearchAirline=All&SearchFrom=2004-4-8

So, could someone please guide me and show what is the expected URL to
get the results returned for (1) above. Thanks.


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

Date: 7 Apr 2004 06:16:24 -0700
From: ifiaz@hotmail.com (Fiaz Idris)
Subject: Re: Extract data using Curl Unix Command & Perl Script from Webpage
Message-Id: <93c1947c.0404070516.3d8d2f4f@posting.google.com>

Sorry!

On the you may try on this page line, I have given the wrong URL.
The correct one is

http://www.chennaionline.com/msuniversity/submit.asp?code=BA


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

Date: Wed, 07 Apr 2004 12:45:40 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <4073F814.25E7BFDC@earthlink.net>


Eric Schwartz wrote:

> Nope.  By "extract $fh from the hash" he means
>
> my $fh = $handles{$state}
>
> You had the handle in the hash, now you have extracted it into $fh.
> Comprende?

Well, that would make a whole lot more sense to me, but I
don't think that is what I did.  Correct me if I'm wrong, but
I don't see that in this code:

use strict;
use warnings;

my @states = qw(AK AL AR AS AZ CA CN CO CT DC DE FL FM GA GU HI IA ID IL IN KS
KY LA MA MD ME MH MI MN MO MP MS MT MX NC ND NE NH NJ NM NV NY OH OK OR PA PR
PW RI SC SD TN TX UM UT VA VI VT WA WI WV WY);
my %handles;

foreach (@states) {
    my $fh; # Start with a scalar variable whose value is undef
    open $fh, '>', "$_.txt" or die "Cannot open $_.txt: $!";
    $handles{$_} = $fh; # open() magically makes $fh into a filehandle!
}



That perldoc perldata documentation posted by Myron
kinda makes sense, but I still don't have a good grasp of
anonymous filehandle or anonymous anything.  I've
accepted it as magic for the moment.


Mike



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

Date: 7 Apr 2004 06:46:40 -0700
From: dash@webdurai.com (Durairaj Avasi)
Subject: Re: Help needed:: Openldap issue - -  LDAP_OPERATIONS_ERROR Server encountered
Message-Id: <2f872516.0404070546.159ca1ab@posting.google.com>

Vetle:::

Binded i found the same bug..

after using ::

$ldap->debug(15);

found the following log:::


Net::LDAP=HASH(0x16d4fa4) sending:

30 0C 02 01 01 60 07 02 01 03 04 00 80 00 __ __ 0....`........

0000   12: SEQUENCE {
0002    1:   INTEGER = 1
0005    7:   [APPLICATION 0] {
0007    1:     INTEGER = 3
000A    0:     STRING = ''
000C    0:     [CONTEXT 0]
000E     :   }
000E     : }
Net::LDAP=HASH(0x16d4fa4) received:

30 84 00 00 00 10 02 01 01 61 84 00 00 00 07 0A 0........a......
01 00 04 00 04 00 __ __ __ __ __ __ __ __ __ __ ......

0000   16: SEQUENCE {
0006    1:   INTEGER = 1
0009    7:   [APPLICATION 1] {
000F    1:     ENUM = 0
0012    0:     STRING = ''
0014    0:     STRING = ''
0016     :   }
0016     : }
Net::LDAP=HASH(0x16d4fa4) sending:

30 81 90 02 01 02 63 66 04 1A 44 43 3D 66 72 2C 0.....cf..DC=fr,
44 43 3D 65 75 72 77 2C 44 43 3D 65 79 2C 44 43 DC=eurw,DC=ey,DC
3D 6E 65 74 0A 01 02 0A 01 02 02 01 00 02 01 00 =net............
01 01 00 A0 2F A3 13 04 0B 6F 62 6A 65 63 74 43 ..../....objectC
6C 61 73 73 04 04 75 73 65 72 A3 18 04 0E 6F 62 lass..user....ob
6A 65 63 74 43 61 74 65 67 6F 72 79 04 06 50 65 jectCategory..Pe
72 73 6F 6E 30 08 04 06 6D 65 6D 62 65 72 A0 23 rson0...member.#
30 21 04 16 31 2E 32 2E 38 34 30 2E 31 31 33 35 0!..1.2.840.1135
35 36 2E 31 2E 34 2E 33 31 39 04 07 30 05 02 01 56.1.4.319..0...
64 04 00 __ __ __ __ __ __ __ __ __ __ __ __ __ d..

0000  144: SEQUENCE {
0003    1:   INTEGER = 2
0006  102:   [APPLICATION 3] {
0008   26:     STRING = 'DC=fr,DC=eurw,DC=ey,DC=net'
0024    1:     ENUM = 2
0027    1:     ENUM = 2
002A    1:     INTEGER = 0
002D    1:     INTEGER = 0
0030    1:     BOOLEAN = FALSE
0033   47:     [CONTEXT 0] {
0035   19:       [CONTEXT 3] {
0037   11:         STRING = 'objectClass'
0044    4:         STRING = 'user'
004A     :       }
004A   24:       [CONTEXT 3] {
004C   14:         STRING = 'objectCategory'
005C    6:         STRING = 'Person'
0064     :       }
0064     :     }
0064    8:     SEQUENCE {
0066    6:       STRING = 'member'
006E     :     }
006E     :   }
006E   35:   [CONTEXT 0] {
0070   33:     SEQUENCE {
0072   22:       STRING = '1.2.840.113556.1.4.319'
008A    7:       STRING
008C     :         30 05 02 01 64 04 00 __ __ __ __ __ __ __ __ __ 0...d..
0093     :     }
0093     :   }
0093     : }
Net::LDAP=HASH(0x16d4fa4) received:

30 84 00 00 00 A7 02 01 02 65 84 00 00 00 9E 0A 0........e......
01 01 04 00 04 84 00 00 00 93 30 30 30 30 30 30 ..........000000
30 30 3A 20 4C 64 61 70 45 72 72 3A 20 44 53 49 00: LdapErr: DSI
44 2D 30 43 30 39 30 35 46 46 2C 20 63 6F 6D 6D D-0C0905FF, comm
65 6E 74 3A 20 49 6E 20 6F 72 64 65 72 20 74 6F ent: In order to
20 70 65 72 66 6F 72 6D 20 74 68 69 73 20 6F 70  perform this op
65 72 61 74 69 6F 6E 20 61 20 73 75 63 63 65 73 eration a succes
73 66 75 6C 20 62 69 6E 64 20 6D 75 73 74 20 62 sful bind must b
65 20 63 6F 6D 70 6C 65 74 65 64 20 6F 6E 20 74 e completed on t
68 65 20 63 6F 6E 6E 65 63 74 69 6F 6E 2E 2C 20 he connection.,
64 61 74 61 20 30 2C 20 76 65 63 65 00 __ __ __ data 0, vece.

0000  167: SEQUENCE {
0006    1:   INTEGER = 2
0009  158:   [APPLICATION 5] {
000F    1:     ENUM = 1
0012    0:     STRING = ''
0014  147:     STRING
001A     :       30 30 30 30 30 30 30 30 3A 20 4C 64 61 70 45 72 00000000: LdapEr
002A     :       72 3A 20 44 53 49 44 2D 30 43 30 39 30 35 46 46 r: DSID-0C0905FF
003A     :       2C 20 63 6F 6D 6D 65 6E 74 3A 20 49 6E 20 6F 72 , comment: In
004A     :       64 65 72 20 74 6F 20 70 65 72 66 6F 72 6D 20 74 order to perform
005A     :       68 69 73 20 6F 70 65 72 61 74 69 6F 6E 20 61 20 this operation a
006A     :       73 75 63 63 65 73 73 66 75 6C 20 62 69 6E 64 20 successful bind
007A     :       6D 75 73 74 20 62 65 20 63 6F 6D 70 6C 65 74 65 must be completed
008A     :       64 20 6F 6E 20 74 68 65 20 63 6F 6E 6E 65 63 74 on the connection
009A     :       69 6F 6E 2E 2C 20 64 61 74 61 20 30 2C 20 76 65 ., data 0, v
00AA     :       63 65 00 __ __ __ __ __ __ __ __ __ __ __ __ __ ce.
00AD     :   }
00AD     : }
ERROR detected: -> LDAP_OPERATIONS_ERROR Server encountered an internal error
ERROR - not LDAP_SUCCESS at userCount.pl line 71, <DATA> line 655.
Net::LDAP=HASH(0x16d4fa4) sending:

30 05 02 01 03 42 00 __ __ __ __ __ __ __ __ __ 0....B.

0000    5: SEQUENCE {
0002    1:   INTEGER = 3
0005    0:   [APPLICATION 2]
0007     : }






dash@webdurai.com (Durairaj Avasi) wrote in message news:<2f872516.0404060736.2151cad1@posting.google.com>...
> #!/usr/bin/perl -w
> use Net::LDAP;
> use Net::LDAP::Util qw(ldap_error_name ldap_error_text);
> my $ldap = Net::LDAP->new('xy.webdurai.net', port=> 389) or die "$@";
> 
>         my @args  = (
>             base     => 'DC=xy',
>             scope    => "subtree",
>             filter   =>
> '(&(objectClass=user)(objectCategory=Person))',
>             attrs    => ["distinguishedName", "Home-MDB",
> "postalAddress", "l","st", "postalcode"]
>         );
>         my $mesg = $ldap->search( @args );
>         if ($mesg->code) {
>                         print "ERROR detected: -> ",
> ldap_error_name($mesg->code), " ",
> ldap_error_text($mesg->code);
>                         warn  "ERROR - not LDAP_SUCCESS";
>                          #last;
>                 }
>         my $total = $mesg->count;
>         print " the total is $total";
> 
> OUTPUT IS:
> ==========
> ERROR detected: -> LDAP_OPERATIONS_ERROR Server encountered
> ERROR - not LDAP_SUCCESS at u.pl line 15, <DATA> line 424.
> 
> NOTE::
> =======
> 
> why i am getting LDAP_OPERATIONS_ERROR?
> 
> i am running under activeperl/perl-ldap/windows 2000
> 
> this is just simple search...  do i have to bind it?
> 
> i thought i don't need to bind for search!!
> 
> thanks in advance.
> 
> Durairaj K. Avasi


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

Date: Wed, 07 Apr 2004 09:11:03 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Open GUI transcript window
Message-Id: <deu7709b6lo7upfluqgfr1kiibgntbccr6@4ax.com>

On Tue, 6 Apr 2004 19:01:50 GMT, "bxb7668" <bxb7668@somewhere.nocom>
wrote:

>I have been given a requirement for a perl script that runs on both
>Windows and UNIX (AIX) from both the command line (UNIX) and the
>Windows Start menu. It can take a long time to run, so they also want
>it to write intermediate status messages. For the command line I just
>write to STDOUT. No problem. But in the Windows GUI environment they
>want a text window to open and the status message dynamically written
>to it and show up as they are written, not when the entire process is
>complete.  Can this be done, and if so, how?  We're using Perl 5.6.1.
>Brian
>

Try this preferred method with fileevent. But sometimes you need to
use Tk::after widget to read the output, if the sender program is
having pipe buffering problems. Fileevent is a built-in IO::Select
fot Tk. Read it's perldoc. Filevent will hang sometimes with pipe-buffer
problems. 
########################################################
#!/usr/bin/perl
use warnings;
use strict;
use Tk;

open(CHILD, "./fileevent2piper 2>&1 |") or die "Can't open: $!";

my $mw = new MainWindow;

my $t = $mw->Scrolled("Text",-width => 80, -height => 25, -wrap =>
'none');
                                             $t->pack(-expand => 1);

$mw->fileevent(\*CHILD, 'readable', [\&fill_text_widget,$t]);
MainLoop;
       
sub fill_text_widget {
          my($widget) = @_;
          $_ = <CHILD>;
	  $widget->insert('end', $_);
          $widget->yview('end');
}
__END__
###########################################################

##HERE IS THE SENDER PROGRAM
##fileevent2piper

#!/usr/bin/perl

$|++;

for my $i ( 0 .. 10) {
        print $i, "\n";
        sleep 1;
    }

print "sleeping 5\n";
sleep 5;

for my $i ( 0 .. 10) {
        print $i, "\n";
        sleep 1;
    }

__END__
########################################################



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: 7 Apr 2004 03:52:58 -0700
From: yashgt@yahoo.com (Yash)
Subject: Optimizing using precompiled Perl program?
Message-Id: <5a373b1d.0404070252.507f619f@posting.google.com>

We have a compute-intensive Perl program that needs optimization. We
have done whatever we could on the algorithm front. Would it give any
performnace improvement if we convert the program to bytecode using:
perl -MO=Bytecode[,-H][,-oscript.plc] script.pl

We are looking for overall runtime performance improvement and not
just initial load-time improvement.

Can you suggest anything else for further optimization?

Thanks


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

Date: 7 Apr 2004 11:17:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Optimizing using precompiled Perl program?
Message-Id: <c50o0o$sqf$1@mamenchi.zrz.TU-Berlin.DE>

Yash <yashgt@yahoo.com> wrote in comp.lang.perl.misc:
> We have a compute-intensive Perl program that needs optimization. We
> have done whatever we could on the algorithm front. Would it give any
> performnace improvement if we convert the program to bytecode using:
> perl -MO=Bytecode[,-H][,-oscript.plc] script.pl
> 
> We are looking for overall runtime performance improvement and not
> just initial load-time improvement.
> 
> Can you suggest anything else for further optimization?

Profile it to find possible hot spots.  Devel::Dprof is the tool.

Anno


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

Date: Wed, 07 Apr 2004 11:10:31 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: yashgt@yahoo.com (Yash)
Subject: Re: Optimizing using precompiled Perl program?
Message-Id: <8865458623af4be23c368c7db6e02b9b@news.teranews.com>

>>>>> "Yash" == Yash  <yashgt@yahoo.com> writes:

Yash> We have a compute-intensive Perl program that needs optimization. We
Yash> have done whatever we could on the algorithm front. Would it give any
Yash> performnace improvement if we convert the program to bytecode using:
Yash> perl -MO=Bytecode[,-H][,-oscript.plc] script.pl

Yash> We are looking for overall runtime performance improvement and not
Yash> just initial load-time improvement.

No.  In fact, that might make your program run slower. :)  Perl's
already at full speed by the time it's running.

Yash> Can you suggest anything else for further optimization?

Have you *really* used the profiling tools?

Have you started to Inline::C the hotspots?

Have you considered using PDL (in the CPAN) for your complex
data structures?

print "Just another Perl hacker,"; # the first (or is it 0th?)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 7 Apr 2004 08:53:53 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular expression question
Message-Id: <slrnc781vg.5vh.tadmc@magna.augustmail.com>

Kapil Khosla <khoslakapil@yahoo.com> wrote:

> I am trying to match
                 ^^^^^
                 ^^^^^

Did you try executing this before posting?

   perldoc -q match


>     open I, "E:\\mycode\\perl\\brace.txt";


You should always, yes *always*, check the return value from open().

If you use single quotes you won't have to backslash the backslashes.

If you use sane slashes you won't even have any backslashes to backslash:

   open I, 'E:/mycode/perl/brace.txt' or
      die "could not open 'E:/mycode/perl/brace.txt'  $!";


>     while($line = <I>)
> 	{
> 		$line =~ s/int main\(\)\s*\{return\s*main\(\)\;\s*\}/matched/
                                           ^^
                                           ^^ need \s* here


> Where am I going wrong? 


By concentrating on the wrong half of the problem.

There are *two* things that might be causing a pattern match to misbehave,
the pattern and the string that you are attempting to match the
pattern against.

You have a problem with the string that you are trying to match 
against (it contains only a single line).

You also have a problem with your pattern, as noted above.


> Please help, 


See the answer to your FAQ:

   I'm having trouble matching over more than one line.  What's wrong?


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


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

Date: 7 Apr 2004 06:07:28 -0700
From: khoslakapil@yahoo.com (Kapil Khosla)
Subject: Re: Regular expression question
Message-Id: <919aa2da.0404070507.4bacc0e9@posting.google.com>

Great ! Thanks. I modified my script to 

    open I, "E:\\mycode\\perl\\brace.txt" or die"Could not open file";
    
    while($line = <I>)
	{
		$line =~ s/\s*int main\(.*\)\s*{?//g;
		$line =~ s/\s*\{.*//g;
		$line =~ s/\s*return main\(.*\)\;//g;
		$line =~ s/\}//g;
		print $line;
	}

 
    close I

This has one issue. The input file looks like
int main()
{
 // Do something 
}

int main()
{
  return main();
}

I only want to delete the second instance of the main block and not
the first instance. The code I wrote above deletes the main from the
first block too.
Is there a way to modify this script to just delete the second block.

Thanks,
Kapil


Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.04.07.05.16.23.198926@aursand.no>...
> On Tue, 06 Apr 2004 22:05:32 -0700, Kapil Khosla wrote:
> > I am trying to match the expression
> > 
> > #brace.txt
> > int main()
> > {
> > 	return main();
> > }
> > 
> > in a file but am getting stuck somewhere. This is the code I could write
> > till now.
> >  
> >     open I, "E:\\mycode\\perl\\brace.txt";
> 
> Always (!) check if open() succeeds, and drop the double quotes; they're
> not necessary here;
> 
>   open(I, '<', 'e:\mycode\perl\brace.txt') or die "$!\n";
> 
> >     while($line = <I>)
> > 	{
> > 		$line =~ s/int main\(\)\s*\{return\s*main\(\)\;\s*\}/matched/;
> > 		print $line;
> > 	}
> 
> You're trying to match multiple lines.  The code above will try to match
> only one line at a time.  You should consider reading your whole file into
> one string and _then_ do the matching.


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

Date: Wed, 07 Apr 2004 15:25:20 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Regular expression question
Message-Id: <pan.2004.04.07.13.24.04.911585@aursand.no>

On Wed, 07 Apr 2004 06:07:28 -0700, Kapil Khosla wrote:
> Great ! Thanks.

Don't top post, and read the posting guidelines posted in this newsgroup
regularly.

> I modified my script to 
> 
>     open I, "E:\\mycode\\perl\\brace.txt" or die"Could not open file";

You listened to something that I wrote in my previous message.  That's
good.  Why didn't you listen to everything I said?  You don't have to
worry about escaping the backslashes if you stay with single quote.  You
also want to know _what_ went wrong (which is stored in '$!').

>     while($line = <I>)
> 	{
> 		$line =~ s/\s*int main\(.*\)\s*{?//g;
> 		$line =~ s/\s*\{.*//g;
> 		$line =~ s/\s*return main\(.*\)\;//g;
> 		$line =~ s/\}//g;
> 		print $line;
> 	}

I think you misunderstood my previous post:  You need to _match_ on more
than one line in 'brace.txt'.  You don't need to do the match (or the
substitution) in more than one line.

> The input file looks like [...]

Why didn't you tell us this the first time you posted?

> int main()
> {
>  // Do something 
> }
> 
> int main()
> {
>   return main();
> }
> 
> I only want to delete the second instance of the main block and not
> the first instance. The code I wrote above deletes the main from the
> first block too.

First of all - you have to read the _entire_ as a string.  Then you need
to match on something _possibly_ followed by something similar.

Read the Perl documentation for matching nested structures;

  perldoc -q match


-- 
Tore Aursand <tore@aursand.no>
"Why shouldn't truth be stranger than fiction? Fiction, after all, has
 to make sense." -- Mark Twain


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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