[18802] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 970 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 23 18:05:46 2001

Date: Wed, 23 May 2001 15:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990655514-v10-i970@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 May 2001     Volume: 10 Number: 970

Today's topics:
    Re: about combining lines of a call record file... <barbr-en@online.no>
    Re: about combining lines of a call record file... <barbr-en@online.no>
    Re: Autosplit -a flag and trailing null fields <allenjo5@mail.northgrum.com>
    Re: columns <krahnj@acm.org>
    Re: columns <smitw1@hotmail.com>
        DBI and syntax with variables.vvp <vprasad@nortelnetworks.com>
    Re: DBI and syntax with variables.vvp <yanoff@yahoo.com>
    Re: DBI and syntax with variables.vvp <hillr@ugs.com>
    Re: DBI and syntax with variables.vvp ctcgag@hotmail.com
        Ending a parent CGI process <JC@MelroseCenter.com>
    Re: Ending a parent CGI process <gtoomey@usa.net>
    Re: Ending a parent CGI process <dwilga-MUNGE@mtholyoke.edu>
    Re: Handling JPEGs without modules <elijah@workspot.net>
        help: String Match  u518615722@spawnkill.ip-mobilphone.net
        how to get the array? <mario.lat@libero.it>
    Re: how to get the array? <carlos@plant.student.utwente.nl>
    Re: how to get the array? <JC@MelroseCenter.com>
    Re: library Files in Perl <todd@designsouth.net>
    Re: Mathematical Combinations (similar to "Permuting da <tom_mullenaux@agilent.com>
    Re: module for combinatorics? (partitions etc) (Dave Bailey)
    Re: module for combinatorics? (partitions etc) (Greg Bacon)
    Re: module for combinatorics? (partitions etc) <ilya@math.ohio-state.edu>
    Re: module for combinatorics? (partitions etc) <joe+usenet@sunstarsys.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 23 May 2001 22:56:51 +0200
From: =?iso-8859-1?Q?K=E5re_Olai_Lindbach?= <barbr-en@online.no>
Subject: Re: about combining lines of a call record file...
Message-Id: <ZqVO6.219$lM3.3111@news1.oke.nextra.no>


"Todd Nathan" <tnathan@midwayisland.net> skrev i melding
news:B730D6E6.26A6%tnathan@midwayisland.net...
> Oh, I should have figured that someone in the Perl community would do the
> RTFM thing, being offline from the Perl community for 5+ years now I kinda
> forgot why I left it in the first place.  Thanks for the not so sutle
> refresher
> course on how to be an asshole and get someone really disinterested in
> something quickly ;'P  You are a class act.
>
> \t
>
> on 5/23/01 7:28 AM, Joe Golfer at name@domain.com wrote:
>
> > How about buying a book on Perl and reading it?

[Some snipping around]

I also feel this is a good example to use when reading a Perl learning book
;)

My example (Dataset must end with a blank line, also at end of file, if not
is left to the user as an exercise):

#!/usr/bin/perl -w
use strict;

my($start,$line) = (0,"");
while (<DATA>) {
  chomp;
  # Regex must specify nesseccary start criteria
  # Here leftmost 'CR' 5digits and ':'
  if(/^CR \d{5}:/) {
    $start = 1;
    $line = "";
  }
  if($start) {
    # If you want to remove some spaces use next line, else uncomment
    $line =~ tr/  / /sd;
    $line .= $_ if $start;
  }
  if(/^\s*$/) {
    # Oh, we got the blank line
    $start = 0;
    print "$line\n\n";
  }
}
__END__
CR 16178: CallType  1 04-MAY-2001 Disc-202
  Seize 13:59:16 Ans 13:59:27 Disc 13:59:38 TS   0
     A Party:    MOBILE (11) 8084213370     Serial ed8283c4
        0013(51: 2)     13:59:16[ 1]--13:59:38[ 1]
     B Party:    MOBILE (11) 8084213400     Serial fc097b20
        0012(51: 1)     13:59:19[ 2]--13:59:38[ 1]

CR 16194: CallType  1 04-MAY-2001 Disc-202
  Seize 13:59:26 Ans 13:59:34 Disc 13:59:43 TS   0
     A Party:    MOBILE (11) 8084213456     Serial e0da83ea
        0024(51:11)     13:59:26[ 1]--13:59:43[ 1]
     B Party:    MOBILE (11) 8084213386     Serial 874a563a
        0021(51: 8)     13:59:28[ 2]--13:59:43[ 1]

CR 16162: CallType  1 04-MAY-2001 Disc-203
  Seize 13:59:12 Ans 13:59:53 Disc 13:59:53 TS  36
     A Party:    MOBILE (11) 8084213373     Serial 7713298a
        0023(51:10)     13:59:12[ 1]--13:59:53[ 1]
     B Party:      PSTN (31) 9337
        1091(36: 2)     13:59:14[ 4]--13:59:53[ 1]


-----------------------------------------------------------------
Regards Kåre Olai Lindbach




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

Date: Wed, 23 May 2001 23:24:51 +0200
From: =?iso-8859-1?Q?K=E5re_Olai_Lindbach?= <barbr-en@online.no>
Subject: Re: about combining lines of a call record file...
Message-Id: <2SVO6.242$lM3.3525@news1.oke.nextra.no>

> My example (Dataset must end with a blank line, also at end of file, if
not
> is left to the user as an exercise):

[A lot of snipping]

Sorry, I changed something on the fly. What I ment to send was:

#!/usr/bin/perl -w
use strict;

my($start,$line) = (0,"");
while (<DATA>) {
  chomp;
  #print "$_\n";
  # Regex must specify nesseccary start criteria
  # Here leftmost 'CR' 5digits and ':'
  if(/^CR \d{5}:/) {
 $start = 1;
 $line = "";
  }
  if(/^\s*$/) {
    $start = 0;
    print "$line\n\n";
    next;
  }
  if($start) {
    # If you want to remove some spaces
    tr/ / /sd;
    $line .= $_;
  }
}
__END__
CR 16178: CallType  1 04-MAY-2001 Disc-202
  Seize 13:59:16 Ans 13:59:27 Disc 13:59:38 TS   0
     A Party:    MOBILE (11) 8084213370     Serial ed8283c4
        0013(51: 2)     13:59:16[ 1]--13:59:38[ 1]
     B Party:    MOBILE (11) 8084213400     Serial fc097b20
        0012(51: 1)     13:59:19[ 2]--13:59:38[ 1]

CR 16194: CallType  1 04-MAY-2001 Disc-202
  Seize 13:59:26 Ans 13:59:34 Disc 13:59:43 TS   0
     A Party:    MOBILE (11) 8084213456     Serial e0da83ea
        0024(51:11)     13:59:26[ 1]--13:59:43[ 1]
     B Party:    MOBILE (11) 8084213386     Serial 874a563a
        0021(51: 8)     13:59:28[ 2]--13:59:43[ 1]

CR 16162: CallType  1 04-MAY-2001 Disc-203
  Seize 13:59:12 Ans 13:59:53 Disc 13:59:53 TS  36
     A Party:    MOBILE (11) 8084213373     Serial 7713298a
        0023(51:10)     13:59:12[ 1]--13:59:53[ 1]
     B Party:      PSTN (31) 9337
        1091(36: 2)     13:59:14[ 4]--13:59:53[ 1]





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

Date: Wed, 23 May 2001 17:53:18 GMT
From: "John L. Allen" <allenjo5@mail.northgrum.com>
Subject: Re: Autosplit -a flag and trailing null fields
Message-Id: <3B0BF90E.237A039C@mail.northgrum.com>

Charles DeRykus wrote:
> 
> In article <3B097380.46A5C9C4@mail.northgrum.com>,
> John L. Allen <allenjo5@mail.northgrum.com> wrote:
> >I find it annoying that the -a flag ignores trailing null fields.
> >It does this because it uses  split()  with no limit parameter.
> >As such, the -a flag is less awk-like than it could be.  If this
> >was deliberate, perhaps there should be a -A flag (or whatever)
> >to make autosplit use a -1 for the limit.
> >
> 
> Good idea.  Possible workaround on a Unix command line:
> 
> perl -F'(\s+|$)' -lane \
> 'for(0..$#F){print $F[$_] if $F[$_]=~/\S/ or $_==$#F}' yourfile
> 
> --
> Charles DeRykus

I'll now see if the perl5 porters like the idea of another flag.  But
I'm not holding my breath :-)

John.


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

Date: Wed, 23 May 2001 19:16:40 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: columns
Message-Id: <3B0C0C99.8F747F74@acm.org>

Willem wrote:
> 
> I want to split records of a file into colums, and with a space
> between the colums.
> 
> Input from file:
> 02X123593791Y103970930X123593791Y103970930X123593791Y103970930X123593791Y10397093000
> etc.
> 
> output to file:
> 02 X123593791 Y103970930 X123593791 Y103970930 X123593791 Y103970930
> X123593791 Y103970930 00

while ( <DATA> ) {
  print join( ' ', unpack( 'A2 A10 A10 A10 A10 A10 A10 A10 A10 A*', $_ )
);
  }


John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 23 May 2001 20:02:42 GMT
From: Willem <smitw1@hotmail.com>
Subject: Re: columns
Message-Id: <a76ogtsblhcttoharengnf623jbpdek89e@4ax.com>

John, thanks!!
This solution works perfect too!
Wim

On Wed, 23 May 2001 19:16:40 GMT, "John W. Krahn" <krahnj@acm.org>
wrote:

>Willem wrote:
>> 
>> I want to split records of a file into colums, and with a space
>> between the colums.
>> 
>> Input from file:
>> 02X123593791Y103970930X123593791Y103970930X123593791Y103970930X123593791Y10397093000
>> etc.
>> 
>> output to file:
>> 02 X123593791 Y103970930 X123593791 Y103970930 X123593791 Y103970930
>> X123593791 Y103970930 00
>
>while ( <DATA> ) {
>  print join( ' ', unpack( 'A2 A10 A10 A10 A10 A10 A10 A10 A10 A*', $_ )
>);
>  }
>
>
>John



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

Date: Wed, 23 May 2001 15:38:53 -0400
From: "Victor Prasad" <vprasad@nortelnetworks.com>
Subject: DBI and syntax with variables.vvp
Message-Id: <9eh3fq$pa0$1@bcarh8ab.ca.nortel.com>

Hello,

Is it possible to use a variable in a PERL sql statement?

ie

my $sth = $dbh->prepare( "SELECT * FROM names where age=4 and
mass=\$gid" )

I get a ' Can't prepare SQL statement: SQL: -202: An illegal character has
been found in the statement.'

When I try - any help?

Thanks,

V




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

Date: Wed, 23 May 2001 14:57:19 -0500
From: Scott Yanoff <yanoff@yahoo.com>
To: Victor Prasad <vprasad@nortelnetworks.com>
Subject: Re: DBI and syntax with variables.vvp
Message-Id: <3B0C161F.5553FAF@yahoo.com>

Victor Prasad wrote:
> my $sth = $dbh->prepare( "SELECT * FROM names where age=4 and
> mass=\$gid" )
> 
> I get a ' Can't prepare SQL statement: SQL: -202: An illegal character has
> been found in the statement.'

You don't need the backslash in front of $gid.

Good luck,
-- 
-Scott
yanoff@yahoo.com | http://www.yanoff.org | AOL IM: SAY KJY


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

Date: Wed, 23 May 2001 12:53:38 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: DBI and syntax with variables.vvp
Message-Id: <3B0C1542.9439BCE2@ugs.com>

Victor Prasad wrote:
> 
> Hello,
> 
> Is it possible to use a variable in a PERL sql statement?
> 
> ie
> 
> my $sth = $dbh->prepare( "SELECT * FROM names where age=4 and
> mass=\$gid" )
> 
> I get a ' Can't prepare SQL statement: SQL: -202: An illegal character has
> been found in the statement.'
> 
> When I try - any help?
> 
> Thanks,
> 
> V

Try

my $sth = $dbh->prepare( "SELECT * FROM names where age=4 and
mass='$gid'" )

Ron


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

Date: 23 May 2001 21:51:51 GMT
From: ctcgag@hotmail.com
Subject: Re: DBI and syntax with variables.vvp
Message-Id: <20010523175151.106$Uz@newsreader.com>

"Victor Prasad" <vprasad@nortelnetworks.com> wrote:
> Hello,
>
> Is it possible to use a variable in a PERL sql statement?
>
> ie
>
> my $sth = $dbh->prepare( "SELECT * FROM names where age=4 and
> mass=\$gid" )
>
> I get a ' Can't prepare SQL statement: SQL: -202: An illegal character
> has been found in the statement.'

I find that it almost invariably (for mysql) works better to use binding:

my $sth = $dbh->prepare( "SELECT * FROM names where age=4 and
mass=?" ) ;

Then pass the variable to replace the '?' upon execution:

$sth->execute($gid) ;

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                       Usenet for the Web


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

Date: Wed, 23 May 2001 13:37:42 -0700
From: "Justin Case" <JC@MelroseCenter.com>
Subject: Ending a parent CGI process
Message-Id: <9eh7ui$u1u$1@localhost.localdomain>

I have a CGI script that uploads a file, sends back a confirmation page, and
forks a child to process the upload.  The parent process then closes I/O and
exits.  However, the client browser shows the server connection to be active
until it times out or the child completes.  This isn't a big problem for the
user but is a little confusing.  Is there an easy way to shut down the
server's connection?

The script is running from an Apache server on Solaris with standard Perl
5.004_05 and CGI.pm.




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

Date: Thu, 24 May 2001 07:17:22 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Ending a parent CGI process
Message-Id: <XyVO6.11863$hV3.13863@newsfeeds.bigpond.com>


"Justin Case" <JC@MelroseCenter.com> wrote in message
news:9eh7ui$u1u$1@localhost.localdomain...
> I have a CGI script that uploads a file, sends back a confirmation page,
and
> forks a child to process the upload.  The parent process then closes I/O
and
> exits.  However, the client browser shows the server connection to be
active
> until it times out or the child completes.  This isn't a big problem for
the
> user but is a little confusing.  Is there an easy way to shut down the
> server's connection?
>
> The script is running from an Apache server on Solaris with standard Perl
> 5.004_05 and CGI.pm.
>
>

The easiest way is to call daemonize to dissociate the parent and child
http://www.perldoc.com/perl5.6/pod/perlipc.html

gtoomey




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

Date: Wed, 23 May 2001 21:21:58 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: Ending a parent CGI process
Message-Id: <dwilga-MUNGE-8875DF.17215423052001@nap.mtholyoke.edu>

In article <9eh7ui$u1u$1@localhost.localdomain>,
 "Justin Case" <JC@MelroseCenter.com> wrote:

> I have a CGI script that uploads a file, sends back a confirmation page, and
> forks a child to process the upload.  The parent process then closes I/O and
> exits.  However, the client browser shows the server connection to be active
> until it times out or the child completes.  This isn't a big problem for the
> user but is a little confusing.  Is there an easy way to shut down the
> server's connection?

Your problem may be that your child still has the STDOUT from the parent open 
(it is inherited). Just close it, and I think you'll find that the server 
returns whatever the parent sends without seeming to go on forever.

It's probably also a good idea to close STDIN and STDERR in the child, as well.

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: 23 May 2001 18:32:53 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Handling JPEGs without modules
Message-Id: <eli$0105231327@qz.little-neck.ny.us>

In comp.lang.perl.misc, Chris Stith  <mischief@velma.motion.net> wrote:
> Many ISPs and hosting companies use NetBSD, OpenBSD, Solaris, or
> some Linux distro on PC-based or on Sun hardware. Most of them
> either use the standard perl shipped with the OS or compile
> with either the native compiler on the platform or gcc. Most
> will be more than willing to tell you their hardware, OS, and
> compiler specs if you ask.

To make this more on-topic for clpm, you can often get perl to
tell you: 'perl -V'. Or for a CGI:

#!/path/to/perl -Tw
use Config qw( myconfig );

print "Content-Type: text/plain\n\n";
print myconfig;
__END__


> So, if you know that your hardware, compiler, and OS are the same
> as where your website is hosted, it's not that hard to setup the
> same thing at your own office or at home (unless of course you're

This can be a fair amount of work. It gets harder if you are a
site designer/coder working for multiple clients who don't all
host with you.

> a small shop and your site is hosted on an SGI box or a Sun
> UltraSparc or somesuch). Since there are plenty of hosting
> companies which offer PC or UltraSparc hosting on Solaris, BSD,
> or Linux, one should be able to find a host which will have a setup
> comparable to one you can build at home.

If changing hosting companies is an option, one can just change to
one that will install modules for you.

> If you simply can't have
> a PC-based box with NetBSD, OpenBSD, FreeBSD, or some form of Linux
> at home, then you may want to think about the state of your career
> as an IT professional.

"If you can't duplicate what your hosting site has, you must suck."

Sorry, but I just find that extremely naive.

> If one can't have SSH access, can't run make from CGI, and can't
> get one's hands on the same setup as the hosting company, perhaps
> it's time to look for a different hosting company, or to colocate
> your own box in a customer-managed colocation arrangement.

That's more reasonable.

You left out: "Can't learn to accept what your hosting site does
have".

Elijah
------
thinks the OP should recosider the necessity of 'jpeg' support


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

Date: Wed, 23 May 2001 20:59:12 GMT
From: u518615722@spawnkill.ip-mobilphone.net
Subject: help: String Match 
Message-Id: <l.990651552.1035034179@[198.138.198.252]>

we need to change a lot of email address
in our files, the target line is like this
string=user\@mailserver1.com

I issued
perl -pi.bak -e "s/user\\\@mailserver1.com/
user\@mailserver2/g" `find ----'

and 

perl -pi.bak -e "s/user\\@mailserver1.com/
user\@mailserver2/g" `find ----'

and 
perl -pi.bak -e "s/user\@mailserver1.com/
user\@mailserver2/g" `find ----'


None of them seems to work the trick.

What is wrong with my perl command?

thanks


 



-- 
Sent by dbadba62 from hotmail  part of com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new


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

Date: Wed, 23 May 2001 20:33:52 GMT
From: "_Mario Latens" <mario.lat@libero.it>
Subject: how to get the array?
Message-Id: <20010523.223247.1359512183.1718@localhost.localdomain>

I have this little program.
in the variable $node->{children} should be an array.
How can I get this array?
How can I print this array(the element of the array)?
I try whith 
   @lista=$node->{children};
    print"-@lista-";
but it don't works! it prints: "ARRAY(0x8175d3c)"
thank you in advance, Mario.

---------------------------------------------
program----------------------------------------
-----------------------------------------------
use SNMP;
$SNMP::save_descriptions = 1; # must be set prior to mib initialization
SNMP::initMib(); # parses default list of Mib modules from default dirs

# read dotted decimal oid or symbolic name to look up
# partial name will be searched and all matches returned
$val = shift || die "supply partial or complete object name or identifier\n";
$SNMP::use_long_names=1;

if ($node = $SNMP::MIB{$val}) {
    print "-$node:$node->{label} [$node->{objectID}]\n";
    while (($k,$v) = each %$node) {
	print "\t$k => $v\n";
    }
    @lista=$node->{children};
    print"-@lista-";
    print"------------- -\@node->{children} - --------------";
} else {
    while (($k,$v) = each %SNMP::MIB) {
	print "+$v->{label}-> [$v->{obj}]\n" #accepts unique partial key(objectID)
	    if $k =~ /$val/ or $v->{label} =~ /$val/;
    }
}


---------------------------------------------------
output-----------------------------------------------
---------------------------------------------------

-HASH(0x8175ce8):dod [.1.3.6]
	varbinds => ARRAY(0x8175d54)
	parent => HASH(0x8175d6c)
	description => 
	objectID => .1.3.6
	syntax => 
	nextNode => HASH(0x8175d9c)
	indexes => ARRAY(0x8175dcc)
	hint => 
	units => 
	textualConvention => 
	status => 
	children => ARRAY(0x8175de4)
	defaultValue => 
	access => 
	label => dod
	subID => 6
	enums => HASH(0x8175e2c)
	type => 
	ranges => ARRAY(0x8175e44)
	moduleID => SNMPv2-SMI
-ARRAY(0x8175d3c)-------------- -@node->{children} - -------------


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

Date: Wed, 23 May 2001 22:54:43 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: how to get the array?
Message-Id: <9eh7sp$j98$1@dinkel.civ.utwente.nl>

print @{$node->{children}};

"_Mario Latens" <mario.lat@libero.it> wrote in message
news:20010523.223247.1359512183.1718@localhost.localdomain...
> I have this little program.
> in the variable $node->{children} should be an array.
> How can I get this array?
> How can I print this array(the element of the array)?
> I try whith
>    @lista=$node->{children};
>     print"-@lista-";
> but it don't works! it prints: "ARRAY(0x8175d3c)"
> thank you in advance, Mario.
>
> ---------------------------------------------
> program----------------------------------------
> -----------------------------------------------
> use SNMP;
> $SNMP::save_descriptions = 1; # must be set prior to mib initialization
> SNMP::initMib(); # parses default list of Mib modules from default dirs
>
> # read dotted decimal oid or symbolic name to look up
> # partial name will be searched and all matches returned
> $val = shift || die "supply partial or complete object name or
identifier\n";
> $SNMP::use_long_names=1;
>
> if ($node = $SNMP::MIB{$val}) {
>     print "-$node:$node->{label} [$node->{objectID}]\n";
>     while (($k,$v) = each %$node) {
> print "\t$k => $v\n";
>     }
>     @lista=$node->{children};
>     print"-@lista-";
>     print"------------- -\@node->{children} - --------------";
> } else {
>     while (($k,$v) = each %SNMP::MIB) {
> print "+$v->{label}-> [$v->{obj}]\n" #accepts unique partial key(objectID)
>     if $k =~ /$val/ or $v->{label} =~ /$val/;
>     }
> }
>
>
> ---------------------------------------------------
> output-----------------------------------------------
> ---------------------------------------------------
>
> -HASH(0x8175ce8):dod [.1.3.6]
> varbinds => ARRAY(0x8175d54)
> parent => HASH(0x8175d6c)
> description =>
> objectID => .1.3.6
> syntax =>
> nextNode => HASH(0x8175d9c)
> indexes => ARRAY(0x8175dcc)
> hint =>
> units =>
> textualConvention =>
> status =>
> children => ARRAY(0x8175de4)
> defaultValue =>
> access =>
> label => dod
> subID => 6
> enums => HASH(0x8175e2c)
> type =>
> ranges => ARRAY(0x8175e44)
> moduleID => SNMPv2-SMI
> -ARRAY(0x8175d3c)-------------- -@node->{children} - -------------




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

Date: Wed, 23 May 2001 14:20:15 -0700
From: "Justin Case" <JC@MelroseCenter.com>
Subject: Re: how to get the array?
Message-Id: <9ehaeq$uus$1@localhost.localdomain>

Mario,

The problem is that what you're getting from the hash is not an array, but a
reference to an array.

$ref_lista=$node->{children};

You then need to dereference it to get the array.

@lista = @{$ref_lista};

Of course, you could combine the statements.

@lista = @{$node->{children}};

Pat

"_Mario Latens" <mario.lat@libero.it> wrote in message
news:20010523.223247.1359512183.1718@localhost.localdomain...
> I have this little program.
> in the variable $node->{children} should be an array.
> How can I get this array?
> How can I print this array(the element of the array)?
> I try whith
>    @lista=$node->{children};
>     print"-@lista-";
> but it don't works! it prints: "ARRAY(0x8175d3c)"
> thank you in advance, Mario.
>
> ---------------------------------------------
> program----------------------------------------
> -----------------------------------------------
> use SNMP;
> $SNMP::save_descriptions = 1; # must be set prior to mib initialization
> SNMP::initMib(); # parses default list of Mib modules from default dirs
>
> # read dotted decimal oid or symbolic name to look up
> # partial name will be searched and all matches returned
> $val = shift || die "supply partial or complete object name or
identifier\n";
> $SNMP::use_long_names=1;
>
> if ($node = $SNMP::MIB{$val}) {
>     print "-$node:$node->{label} [$node->{objectID}]\n";
>     while (($k,$v) = each %$node) {
> print "\t$k => $v\n";
>     }
>     @lista=$node->{children};
>     print"-@lista-";
>     print"------------- -\@node->{children} - --------------";
> } else {
>     while (($k,$v) = each %SNMP::MIB) {
> print "+$v->{label}-> [$v->{obj}]\n" #accepts unique partial key(objectID)
>     if $k =~ /$val/ or $v->{label} =~ /$val/;
>     }
> }
>
>
> ---------------------------------------------------
> output-----------------------------------------------
> ---------------------------------------------------
>
> -HASH(0x8175ce8):dod [.1.3.6]
> varbinds => ARRAY(0x8175d54)
> parent => HASH(0x8175d6c)
> description =>
> objectID => .1.3.6
> syntax =>
> nextNode => HASH(0x8175d9c)
> indexes => ARRAY(0x8175dcc)
> hint =>
> units =>
> textualConvention =>
> status =>
> children => ARRAY(0x8175de4)
> defaultValue =>
> access =>
> label => dod
> subID => 6
> enums => HASH(0x8175e2c)
> type =>
> ranges => ARRAY(0x8175e44)
> moduleID => SNMPv2-SMI
> -ARRAY(0x8175d3c)-------------- -@node->{children} - -------------




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

Date: Wed, 23 May 2001 20:13:26 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: library Files in Perl
Message-Id: <GRUO6.62596$I5.13336202@news1.rdc1.tn.home.com>

>
> I would dispute the sweeping assertion that "people usually" use old
> Perl4-style libraries rather than Perl5-style libraries (aka Exporter
> modules).

I wouldn't. Think about it- out of all the perl programmers in the world,
I'll bet most of them don't know how to write modules. But I'm sure all of
them can put a few subroutines in a file and 'require' it. So I still think
that most people use .pl files instead of modules.




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

Date: Wed, 23 May 2001 15:18:37 -0600
From: "Tom Mullenaux" <tom_mullenaux@agilent.com>
Subject: Re: Mathematical Combinations (similar to "Permuting days of the week" thread)
Message-Id: <990652718.258101@goodnews.cos.agilent.com>

Thank you Craig and Jay. Both work great!

-Tom





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

Date: 23 May 2001 19:56:09 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <slrn9gnr8k.n20.dave@sydney.daveb.net>

On Wed, 23 May 2001 17:59:47 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>In article <9egjlk$ms0$2@mamenchi.zrz.TU-Berlin.DE>,
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>Indeed, but not everyone has your talent in combining conciseness
>>with clarity.
>
>The reason I didn't try was that I felt what he said was wrong in so
>many ways I couldn't think of any way to correct all of it without
>explaining the whole thing from the ground up; I was afraid that if I
>included a partial explanation that it would just confirm his mistaken
>notion that he understood what was going on.

I thought about what you said here and I've decided that you're right.
Although I've read Sipser, I don't think I've put enough effort into
understanding it.  I regret having been angered by your earlier 
comments.  Looking back over my contributions to this thread, I see
that most of them were simply wrong, and some were "not even wrong".
Rather embarrassing.  I should have known better than to be satisfied 
a shallow understanding of the theory of computation.  At least this
experience gives me some motivation to learn more.  I will check out
the references you suggested.

--
Dave Bailey
davidb54@yahoo.com


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

Date: Wed, 23 May 2001 20:29:41 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <tgo7dl3ma4avb3@corp.supernews.com>

In article <3B0BF230.9B2CC80E@bigfoot.com>,
    Thorbjørn Ravn Andersen  <thunderbear@bigfoot.com> wrote:

: Greg Bacon wrote:
: 
: > You're describing something like NP, i.e., the class of decision
: > problems that can be solved in polynomial (in the size of the problem)
: > time on a non-deterministic Turing machine.  Informally, the problems in
: > NP-complete are the hardest problems in NP.
: 
: My teacher used to say something regarding NP around the lines of "a
: _solution_ to the problem can be verified in linear time".

s/linear time/polynomial time/

: I.e. whenever you have something to choose from, you peek at the
: solution and pick the right one.
: 
: Unfortunately, you need to solve the problem first, before you have a
: solution, and computers are not very good at guessing.

A non-deterministic Turing machine is extraordinarily good at guessing.
None of the major vendors seem to have them in stock, though. :-(

Greg
-- 
Today a racist is anyone who is winning an argument with a liberal.
    -- Peter Brimelow


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

Date: 23 May 2001 21:01:23 GMT
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <9eh8f3$3a9$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Mark Jason Dominus
<mjd@plover.com>], who wrote in article <3b0b600a.47eb$355@news.op.net>:
> >I hope you remember the incredible sophistry Hardy and Ramanujan put
> >into their formula for the number of partitions!  [See Littlewood's
> >Mathematical Miscelannia for details.]
> 
> I don't know just what you're getting at here, but if Hardy and
> Ramanujan had trouble

The story is not that they "had trouble".  The story is that anyone
with a bit of math-common-sense can write an asymptotic formula (as
in)

  factorial(n) = sqrt(2*Pi*n) * (n/E)**n * (1 - n/12 + n**2/288 +...)

"Asymptotic" means that keeping more terms gives you better and better
relative precision when n grows, but does not mean anything for one
particular value of n.

What Hardy and Ramanujan noticed is that if one replaces n by (n-1/24)
in an appropriate place of the asymptotic formula for partitions(n),
the asymptotic series becomes converging!  I do not recall seeing any
"scientific" explanation of this phenomena (or any *other* situation
when a similar thing happens).

> The recursion is very complicated for a mathematician because of
> multiply-nested summations.  But any idiot can compute a few special
> cases, and that is all we need here.  It takes O(N^3) time to compute
> all the values needed to solve the problem for N partitioned into P
> parts.

The recursion is very complicated for a mathematician because O(N^3)
is out of the question for any "reasonable" value of N.
Hardy-Ramanujan formula works in - well, I do not remember.  O(log log
N)?  Maybe not...  O(log N) or O(N ** (1/2))?

Ilya


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

Date: 23 May 2001 17:46:26 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <m3zoc3spql.fsf@mumonkan.sunstarsys.com>

mjd@plover.com (Mark Jason Dominus) writes:

> The recursion is very complicated for a mathematician because of
> multiply-nested summations.  But any idiot can compute a few special
> cases, and that is all we need here.  It takes O(N^3) time to compute
> all the values needed to solve the problem for N partitioned into P
> parts.  Probably there is some obvious identity that I am missing that
> would reduce the time to O(n^2), but it is 3AM here so I will leave it
> alone.

Here's one: D(N,K,P) = p(N-KP,1) + p(N-KP,2) + ... + p(N-KP,P)

where 

  p(N,R) = number of partitions of N into exactly R parts.  

(To see this relation, just draw the appropriate picture :-)

I think this will reduce D to O(N^2) by using the simple recurrence 
relation for p:
 
  p(N,R) = p(N-R, R) + p(N-1, R-1)

Here's a (quadratic?) replacement for your earlier D sub:

sub D {
  my ($n, $k, $p) = @_;
  return $n == 0 if $p == 0;
  return 0 if $n <   $k * $p;
  return 1 if $n ==  $k * $p;
  my $sum = 0;
  for (1..$p) {
      $sum += P($n-$k*$p, $_);
  }
  return $sum;

}

sub p {
    my ($n, $r) = @_;
    return $n >= $r      if $n <= $r;
    return 1             if $r == 1;
    return $p{$n,$r}     if exists $p{$n,$r};
    return $p{$n,$r} = p($n-$r,$r) + p($n-1,$r-1);
}


-- 
Joe Schaefer   "The secret to creativity is knowing how to hide your sources."
                                               --Albert Einstein


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

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


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