[22840] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5061 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 30 03:06:04 2003

Date: Fri, 30 May 2003 00:05:11 -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: 5061

Today's topics:
    Re: APP: perl script editor <dillon@SpamMinuSaccessdenied.darktech.org>
        Comments/Help on Ring Element Id Subroutine? (entropy123)
    Re: Comments/Help on Ring Element Id Subroutine? (Sam Holden)
    Re: Comments/Help on Ring Element Id Subroutine? <uri@stemsystems.com>
    Re: Comments/Help on Ring Element Id Subroutine? <email_entropy123@yahoo.com>
    Re: DBI, Error Handling, and accepted programming pract (Bryan Castillo)
        Efficient Date Sorting <mbear@uq.net.au>
    Re: Filling an array from another array <REMOVEsdnCAPS@comcast.net>
    Re: Filling an array from another array <krahnj@acm.org>
    Re: Filling an array from another array <REMOVEsdnCAPS@comcast.net>
    Re: Help: Printing Out an Object?/Overloaded Operation  (entropy123)
        Help: Use of uninitialized value In Subroutine (?hash) (entropy123)
    Re: How can I get XML::RSS? (ActivePerl) <randy@theoryx5.uwinnipeg.ca>
    Re: Nice'ing again.. <minceme@start.no>
        Perl program strange error (sridhar)
    Re: Please help with this script <grazz@pobox.com>
    Re: uninitialized value in eval block? (Bryan Castillo)
    Re: variable for current line number (of script) <REMOVEsdnCAPS@comcast.net>
    Re: variable for current line number (of script) <ericw@nospam.ku.edu>
    Re: variable for current line number (of script) <ericw@nospam.ku.edu>
    Re: variable for current line number (of script) <REMOVEsdnCAPS@comcast.net>
    Re: variable for current line number (of script) <uri@stemsystems.com>
    Re: variable for current line number (of script) <ericw@nospam.ku.edu>
    Re: variable for current line number (of script) (Sam Holden)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 30 May 2003 14:26:31 +0800
From: AcCeSsDeNiEd <dillon@SpamMinuSaccessdenied.darktech.org>
Subject: Re: APP: perl script editor
Message-Id: <p7uddvslbm0nmepgtnlts41e0g76tr4b7g@4ax.com>

I've been using EditPlus for 3 years now.
It runs on M$ Windoze.

It has color coded stuffs, tools to compile/run you code and supports other languages like Java.....

Really worth your $...

Once you use this, you won't bother with any other editors.

On Thu, 29 May 2003 23:09:22 +0100, Cannabis Coffee Shops <nntp@cannabiscoffeeshops.co.uk.INVALID>
wrote:

>Beginner level - what editors are worth a look .


To e-mail, remove the obvious


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

Date: 29 May 2003 22:22:28 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Comments/Help on Ring Element Id Subroutine?
Message-Id: <90cdce37.0305292122.186a015e@posting.google.com>

Hey all,

After 6 weeks and many usenet posts my fragile baby is taking shape. 
I'd appreciate any advice.

%ehash is a %HoH which contains all the nodes which 'might' (ring
-node -ring is a case I'll need to catch) be in a ring, multiple
individual rings, fused rings, or any combination thereof. %ehash is
the result of removing all the deadends from the original hash,
including branched linear chains.

%ehash{C0}{C1} = 3 is a triple bond between C0 and C1.
%ehash{C1}{O3} = 2 is a single bond between C1 and O3.

of course %ehash{C1}{C0} = 3 also exists...

@gt3 is all the 'multiple' ring elements - more than two bonds. If
@gt3 is empty I either have one ring or multiple unfused ones...Hmmm
something to worry about...but for now I can let this one go...

@bt: Is the 'memory' the ring is traversed it tells the path and stops
backtracking. Problem is I can't figure out how to implement this idea
if -for a 3 edge node - the path happened to go through one of those
'other' nodes...the ring will not be detected. This is the major
reason - besides near complete ignorance :) - for my post.

Can I find and identify all the elements of fused and unfused rings
with a setup like this one? Or will I need to ultimately compare
arrays anyway :) Don't know how to do this BTW:)

foreach $slipe (@gt3) { #$slipe is a 3+ degree node
	@bt =(); #haven't gone anywhere yet
	push (@bt, $slipe); #add the starting node
	$flast=$slipe; #make sure there are no damned 'uninit' errors..
	&pick_cherries(\%ehash, $slipe, $flast, \@gt2, \@bt); #call the sub
#@gt2 is all the 2 degree atoms on the candidate list.
    }

sub pick_cherries {#have no idea why I called it this
    my ($ehash, $slipe, $flast, $gt2, $bt) = @_; #references make a
lot of #sense, had no idea what they were yesterday.
    my $fnexter;
    foreach $fnexter (@$gt2) {   
	if ((exists ($ehash->{ $flast }->{ $fnexter })) &&
(&n_exists_element($fnexter, @$bt))) {#on the second traversal if
$fnexter was part of the sweep
#this will be false and the ring will be missed.
	    push(@$bt, $fnexter);
	    push (@$slipe, $fnexter);
	     print "$slipe: @$slipe\n"; #I print things out to try to 'see'
	    if ((exists ($ehash->{ $slipe }->{ $fnexter })) && ( $flast ne
$slipe )) {
		push (@$slipe, $slipe);
		print "Gotta possible Ring here: $slipe: @$slipe\n";
		print "Been there:                       @$bt\n";
		@$slipe = (); Yeah I print it out but I'm not sure how to #return in
such a way it may be reasonably compared with other such arrays.
#		@$bt=(); This was a disaster....infinite loop...
	    }
	    $flast = $fnexter;
	    &pick_cherries($ehash, $slipe, $flast, $gt2, $bt);
	  
	}
    }
}

Help much appreciated!

Thanks,
entropy


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

Date: 30 May 2003 05:38:18 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Comments/Help on Ring Element Id Subroutine?
Message-Id: <slrnbddria.paj.sholden@flexal.cs.usyd.edu.au>

On 29 May 2003 22:22:28 -0700, entropy123 <email_entropy123@yahoo.com> wrote:
> Hey all,
> 
> After 6 weeks and many usenet posts my fragile baby is taking shape. 
> I'd appreciate any advice.
> 
> %ehash is a %HoH which contains all the nodes which 'might' (ring
> -node -ring is a case I'll need to catch) be in a ring, multiple
> individual rings, fused rings, or any combination thereof. %ehash is
> the result of removing all the deadends from the original hash,
> including branched linear chains.
> 
> %ehash{C0}{C1} = 3 is a triple bond between C0 and C1.
> %ehash{C1}{O3} = 2 is a single bond between C1 and O3.
> 
> of course %ehash{C1}{C0} = 3 also exists...

[snip code and algorithm and so on...]

I don't understand the problem domain or the representation of the algorithm
at all, and reading through the perl code by itself is too much work...

Sample input and output is needed. 

An assignment to %ehash which doesn't contain a ring, and another which
does, and one which does but which the code doesn't find.

Searching for a ring still makes me instantly think of depth first search
as the solution, but sample cases dramatically reduce the work required to
understand the code.

-- 
Sam Holden



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

Date: Fri, 30 May 2003 06:00:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Comments/Help on Ring Element Id Subroutine?
Message-Id: <x71xyhas9l.fsf@mail.sysarch.com>

>>>>> "e" == entropy123  <email_entropy123@yahoo.com> writes:

now that you have posted some code, i will be glad to slice and dice
it.

enjoy the ride  :)

  e> foreach $slipe (@gt3) { #$slipe is a 3+ degree node
  e> 	@bt =(); #haven't gone anywhere yet
  e> 	push (@bt, $slipe); #add the starting node

why clear it and then push one element onto it? do you mean to
accumulate data in @bt or does it just have a single $slipe?

  e> 	$flast=$slipe; #make sure there are no damned 'uninit' errors..
  e> 	&pick_cherries(\%ehash, $slipe, $flast, \@gt2, \@bt); #call the sub

	to just pass a new array with $slipe you could use:

 	&pick_cherries(\%ehash, $slipe, $flast, \@gt2, [$slipe]); #call the sub

  e> #@gt2 is all the 2 degree atoms on the candidate list.
  e>     }

  e> sub pick_cherries {#have no idea why I called it this

you should have an idea. the names that you choose are among the most
important coding decisions you ever make. the computer doesn't care
about the names you choose but humans do. so pick names other coders
will understand. the names should actually reflect how some thingy is being
used and they should not just be a mnemonic for you.

  e>     my ($ehash, $slipe, $flast, $gt2, $bt) = @_; #references make a
  e> lot of #sense, had no idea what they were yesterday.

have you read all of perlreftut, perlref, perldsc and perllol? then you
will learn all about refs.

  e>     my $fnexter;
  e>     foreach $fnexter (@$gt2) {   

	foreach my $fnexter (@$gt2) {   

  e> 	if ((exists ($ehash->{ $flast }->{ $fnexter })) &&

you can remove internal -> ops. 

	if ((exists ($ehash->{ $flast }{ $fnexter })) &&

  e> (&n_exists_element($fnexter, @$bt))) {#on the second traversal if

don't call subs with & unless you want its special behavior. 

  e> $fnexter was part of the sweep
  e> #this will be false and the ring will be missed.
  e> 	    push(@$bt, $fnexter);

oh, so you are passing @bt by ref and modifying it. make that clear
above. you still can combine those two lines (way above) into:

	my @bt = ( $slipe ); #add the starting node

  e> 	    push (@$slipe, $fnexter);
  e> 	     print "$slipe: @$slipe\n"; #I print things out to try to 'see'
  e> 	    if ((exists ($ehash->{ $slipe }->{ $fnexter })) && ( $flast ne
  e> $slipe )) {
  e> 		push (@$slipe, $slipe);
  e> 		print "Gotta possible Ring here: $slipe: @$slipe\n";
  e> 		print "Been there:                       @$bt\n";
  e> 		@$slipe = (); Yeah I print it out but I'm not sure how to #return in
  e> such a way it may be reasonably compared with other such arrays.
  e> #		@$bt=(); This was a disaster....infinite loop...

i just have the feeling this can be made much simpler. for one thing
using hashes might clean it all up. you can use them for any form of
structure and you can check for rings with a single lookup and not with
a loop over a list. i am sure someone else will actually show such a
version.

  e> 	    }
  e> 	    $flast = $fnexter;
  e> 	    &pick_cherries($ehash, $slipe, $flast, $gt2, $bt);

again, drop the &. that sub name and those var names need to be
changed. just looking at that single call tells me nothing about what
the hell it is. this is where the coder is making the code impenetrable
and perl has nothing to do with it.

consider picking good names to be a challenge to yourself. have you ever
used a thesaurus to find good names? have you ever made major global
name changes when your little birdie tells you to? have you ever slugged
a cow-orker because of their bad names?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 30 May 2003 01:35:12 -0500
From: "ent123" <email_entropy123@yahoo.com>
Subject: Re: Comments/Help on Ring Element Id Subroutine?
Message-Id: <pan.2003.05.30.06.35.12.404159@yahoo.com>

On Fri, 30 May 2003 05:38:18 +0000, Sam Holden wrote:


> 
> I don't understand the problem domain or the representation of the algorithm
> at all, and reading through the perl code by itself is too much work...
> 
Agreed :) I'm trying to put something more clear together right now...
> Sample input and output is needed. 

Ok, I'll try to use your earlier dfs examples.

> 
> Searching for a ring still makes me instantly think of depth first search
> as the solution, but sample cases dramatically reduce the work required to
> understand the code.
>
Sam, though I'm not quite sure how DFS works it sounds like its the way to
go. I tried making a go of it with your sub but didn't understand its
innards (my lack of perlknowledge) enough to make a stab at modification.

Be back in 1/2 hour...

entropy


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

Date: 29 May 2003 22:44:37 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: DBI, Error Handling, and accepted programming practices
Message-Id: <1bff1830.0305292144.6efa1bc7@posting.google.com>

anothernumber@yahoo.com (Rod) wrote in message news:<eef90f9f.0305291239.3c79fc66@posting.google.com>...
> I have been working on rewriting some CGI's that use DBI to connect to
> a mysql database. While working on the project I became curious as to
> whether there were any practices I should follow when using the DBI
> module. Right now I typically connect to the database when I execute a
> query but immediately disconnect afterwards and reconnect again when a
> connection to the database is needed. Is this acceptable, should I
> strive to keep one connection open through a run of the program, or
> does it really not matter as long as I am consistent? Are there any
> books or sites that deal with accepted programming practices while
> using DBI? I realize that these types of calls do use resources and
> that is why I am concerned, the databases is already rather large and
> I don't need the thing to be any slower.
> 

I don't see any benefit in opening/closing a connection for every
query.
I am willing to bet you have a performance loss because of it.  A CGI
program
doesn't run for very long (usually).  I don't think you would save the
database any time really by closing the connection.  Databases should
handle idle connections efficiently.  If you always close the
connection you would
also loose any benefits from using prepared statements.


> The second part of my question deals with something completely
> different, error handling. How do most people deal with errors when
> writing CGI's? I need to basically print out a detailed message
> stating what errors occured (bad input from the user, couldn't connect
> to the database, etc) and then I want to quit.
> Many times there will be more than one error (the user has bad input
> in two fields), I want to address both errors on the page that is
> displayed. Once again, what is the accepted method of doing this.
> 

There is no one accepted method.  I personally like to use die and
eval, much
like throw and catch in C++.  You should probably think about how to
seperate
error handling, data processing and html rendering into seperate
components. (there is a buzz-word for this, but I don't want to
mention it)

One thing you might run into with error handling is:
  You have already started writing out some html and then you
encounter an
  error.  How do you display the error?  Will it make sense visually?
  Perhaps you are display results from a select statement into a
table.
  Now, an error is encountered and you print it to the browswer.  It
will look
  strange in the middle of a table.

That is why I:
 1. Validate parameters from the request
 2. Perform initialization
 3. Process the prameters and retrieve the results I want to display
 4. Clean up processing resources (database handles, etc....)
 5. Finally, I will print out the html

I will have surrounded steps 1-4 in an eval block and handle any
errors once.

Regarding DBI, I like to set the RaiseError attribute to true for the
connection handles, so I don't have to check return codes.

> I have code that works now, but I would like to clean it up. I am
> still learning, and I would like to avoid aquiring any bad programming
> habits.
> 
> Thank you,
> 
> Rod


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

Date: Fri, 30 May 2003 16:40:10 +1000
From: Matthew Braid <mbear@uq.net.au>
Subject: Efficient Date Sorting
Message-Id: <bb6ucb$87n$1@bunyip.cc.uq.edu.au>

Hi all,

I have to write a coderef to pass to sort so that it takes a list of 
'human-readable' dates. I can't preparse the list in any way first as it 
is being used as part of a Tk widget (Tk::MListbox), so I can't do any 
groovy map-sort-map tricks.

Anyway, the code I'm using currently is:

   use Time::Local;
   ....
   my ($am, $pm) = ($l->AM, $l->PM);
   my $ampmre = qr/\Q$am\E|\Q$pm\E/;
   my $dre =
    qr{^\s*(\d{1,2}):(\d{2})\s($ampmre).+\s+(\d{1,2})/(\d{2})/(\d{4})\z};
   my $date_sort = sub {
     my ($a_hr, $b_hr, $a_min, $b_min, $a_ampm, $b_ampm,
         $a_dy, $b_dy, $a_mn, $b_mn, $a_yr, $b_yr);
     if ($_[0] =~ $dre) {
       ($a_hr, $a_min, $a_ampm, $a_dy, $a_mn, $a_yr) =
         ($1, $2, $3, $4, $5, $6);
     } else {
       ($a_hr, $a_min, $a_ampm, $a_dy, $a_mn, $a_yr) =
         (0, 0, $am, 1, 1, 1900);
     }
     if ($_[1] =~ $dre) {
       ($b_hr, $b_min, $b_ampm, $b_dy, $b_mn, $b_yr) =
         ($1, $2, $3, $4, $5, $6);
     } else {
       ($b_hr, $b_min, $b_ampm, $b_dy, $b_mn, $b_yr) =
         (0, 0, $am, 1, 1, 1900);
     }
     $a_hr = (12 + $a_hr) % 24 if $a_ampm eq $pm;
     $b_hr = (12 + $b_hr) % 24 if $b_ampm eq $pm;
     $a_mn--; $b_mn--;
     my ($at, $bt) = (timelocal(0, $a_min, $a_hr, $a_dy, $a_mn, $a_yr),
                      timelocal(0, $b_min, $b_hr, $b_dy, $b_mn, $b_yr));
     return $at <=> $bt;
   };

A few things to explain this code:

1) This is part of a GUI that has been spec'd as being 
'single-byte-language safe' - that is, there's a translator package that 
uses language files to define how things print. That is what $l is above 
- an instance of the Language object. From it I pull out what the 
current language's strings for 'am' and 'pm' are. Hence the use of 
\Q$am\E, and \Q$pm\E in the RE's

2) Dates are formatted thus:
   12:59 am on Mon 31/12/2003
    Due to the language specs, 'am', 'on' and 'Mon' are not fixed. I 
don't care what 'on' and the day look like, but I need to capture and 
compare the 'am/pm' value. Thankfully the numerical date spec is fixed 
at D?D/MM/YYYY and the time spec is fixed at H?H:MM.

3) Yes, I know this is never going to be the most efficient sort ever.

The code above is about as efficient as I could get it without eating 
into the rest of the project's time (and keeping it readable - a couple 
of vars are set there that don't need to be - eg $at and $bt)

Any suggestions?

MB



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

Date: Thu, 29 May 2003 20:20:17 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Filling an array from another array
Message-Id: <Xns938AD8E71FDFsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Graham Drabble <graham.drabble@lineone.net> wrote in
news:Xns938AD695C801Cgrahamdrabblelineone@ID-77355.user.dfncis.de:

> If I have 
> 
> @choices = ('a', 'b', 'c')
> and
> $depth = 3;
> 
> then how can I make
> 
> @all_possible_choices = ('a a a',
>                                         'a a b',
>                          'a a c',
>                          'a b a',
>                          'a b b',
>                                        .... all the rest,
>                          'c c c',)
> 
> I've tried numerous things using different loops but am getting 
> nowhere.

@all_possible_choices = grep /[abc]{3}/, 'aaa'..'zzz';
:-)

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+1rGUY96i4h5M0egRAgN0AJ0doh/Wyk8YMlwoGIEUskc9q9ujEwCgpnTB
JAVwZY/mRsxSAOada8vOM1Y=
=IMgq
-----END PGP SIGNATURE-----


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

Date: Fri, 30 May 2003 02:21:03 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Filling an array from another array
Message-Id: <3ED6BFFC.4E180DF0@acm.org>

Graham Drabble wrote:
> 
> I'm trying to do this and have been working on it for a while and
> haven't even got close to getting code that does what I need.
> 
> If I have
> 
> @choices = ('a', 'b', 'c')
> and
> $depth = 3;
> 
> then how can I make
> 
> @all_possible_choices = ('a a a',
>                                     'a a b',
>                          'a a c',
>                          'a b a',
>                          'a b b',
>                                    .... all the rest,
>                          'c c c',)
> 
> I've tried numerous things using different loops but am getting
> nowhere.

$ perl -e'
my @choices = qw(a b c);
my $depth = 3;
print "$_\n" for glob do { local $" = ","; "{@choices}" x $depth };
'
aaa
aab
aac
aba
abb
 ...
cbb
cbc
cca
ccb
ccc


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 29 May 2003 21:56:06 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Filling an array from another array
Message-Id: <Xns938AE8BF0A177sdn.comcast@216.166.71.239>

"John W. Krahn" <krahnj@acm.org> wrote in news:3ED6BFFC.4E180DF0@acm.org:

> $ perl -e'
> my @choices = qw(a b c);
> my $depth = 3;
> print "$_\n" for glob do { local $" = ","; "{@choices}" x $depth };
> '

Whoa.

-- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print


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

Date: 29 May 2003 21:46:08 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: Help: Printing Out an Object?/Overloaded Operation Error with Graph Module?
Message-Id: <90cdce37.0305292046.65cc0870@posting.google.com>

Bob,

Thanks man, worked like a charm. Now if I only knew what the hell to
do with output like that...

entropy


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

Date: 29 May 2003 21:45:24 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Help: Use of uninitialized value In Subroutine (?hash)
Message-Id: <90cdce37.0305292045.460778e@posting.google.com>

Hey All,

A while back Sam Holden was nice enough to post a piece of code which
I am sorry to say I don't quite know how to use. As I try solve the
"Find the elements in the cycle" problem in my own inimical way I
return again and again to this subroutine...I get this "use of
uninitialized value in string" error message which I can't seem to
lick and my usenet/CPAN searches yield zilch.

I can't figure out why, but the error occurs in the logical statement
I've ^^^^ under.

Any help is much appreciated...

entropy



sub dfs {
        my $graph = shift;
        my $result;
        foreach $source (keys %$graph) {
                $result = dfs_visit($graph, $source, undef, {}, {}) ||
$result
                        unless defined $colour{$source};
        }
        return $result;
}

sub dfs_visit {
        my ($graph, $source, $parent, $colour, $parents) = @_;
        my $result;
        $colour{$source} = 'grey';
        $parents->{$source} = $parent;

        foreach $dest (keys %{$graph->{$source}}) {
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Error seems to be
here
                if ($colour{$dest} eq 'grey') {
                        $result = 1;
                        my $node = $source;
                        print "Cycle: $dest";
                        while ($node ne $dest) {
                                print " <- $node";
                                $node = $parents->{$node};
                        }
                        print " <- $dest\n";
                } elsif (!defined $colour{$dest}) {
                        $parents->{$dest} = $source;
                        $result = dfs_visit($graph, $dest, $source,
    $colour, $parents) || $result;
                }
        }
        $colour{$source} = 'black';
        return $result;
}


# H - O - H
my %graph1 = ( 'H1' => {'O'=>1}, 'H2' => {'O'=>1}, 'O' => {});

# H   H       H   H
# |   |       |   |
# C - C - C - C - C
#  \ /         \ /
#   C           C
#   |           |
#   H           H
my %graph2 = ( C1=>{H1=>1, C2=>1}, C2=>{H2=>1, C3=>1},
        C3=>{H3=>1, C1=>1, C4=>1}, C4=>{C5=>1}, C5=>{H4=>1, C6=>1},
        C6=>{H5=>1,C7=>1}, C7=>{H6=>1, C5=>1});

if (dfs(\%graph1)) {
        print "Graph 1 has a cycle\n";
}

if (dfs(\%graph2)) {
        print "Graph 2 has a cycle\n";
}


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

Date: Thu, 29 May 2003 21:27:49 -0500
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: How can I get XML::RSS? (ActivePerl)
Message-Id: <EkzBa.23490$NC4.109651@news1.mts.net>

"Paul Silver" <singleantler-news@hotmail.com> wrote in message
 news:2m7cdv40ruuulki9n8lt48538kcrplktl1@4ax.com...
> Hi,
>
> I'm trying to get XML::RSS working in ActivePerl, but the readme says
> I need to compile it. Unfortunately I have no C compiler.
>
> Does anyone know where I can get a packaged version of XML::RSS that
> ppm will be able to cope with? Or any other ideas about getting it
> working?

We have a ppm package at http://theoryx5.uwinnipeg.ca/ppms/
for ActivePerl 8xx and http://theoryx5.uwinnipeg.ca/ppmpackages/
for 6xx.

best regards,
randy kobes





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

Date: Fri, 30 May 2003 05:02:10 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: Nice'ing again..
Message-Id: <bb6oki$mpi$1@troll.powertech.no>

> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

> Vlad Tepes  <minceme@start.no> wrote in comp.lang.perl.misc:
>> Hi,
>> 
>> Reading the other post about altering priorities on scripts, I thought
>> I'd try it out. I was expecting to make the script run slower when
>> giving a high value with setpriority, but it seems not to make any
>> difference.
>
> The effect of task priority on execution speed is indirect and depends
> not only on the type of system you're running but also on the load and
> type of job mix that is running concurrently.  Very little can be said
> in general.
>
> If there is little concurrent load, priority has no effect because there
> are no processes with better priority that want processing.

[snipped]

> Try running two or more of these at different priorities and see what
> happens.

A good idea. I made two versions of the script, one using setpriority
0 and one with 19, then I watched them run with top(1).  Values for nice
was 0 and 19, one of the scripts got 85% CPU, the other one 15%. Good.

Thanks for all replies.

-- 
                                              (,_    ,_,    _,)
                                              /|\`\._( )_./'/|\
                                             · ·  \/ L /\ D  · ·
                                            /__|.-'`-\_/-`'-.|__\
                                           `          "          `


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

Date: 29 May 2003 22:59:54 -0700
From: gsridhar78@yahoo.com (sridhar)
Subject: Perl program strange error
Message-Id: <9b27068c.0305292159.2f952081@posting.google.com>

Hi,

I am running belo program.I am getting Can't call method "get" on an
undefined value in snmpget.pl in  line 30.Please help me I am in very
much trouble.

#!/usr/local/bin/perl
#
# snmpget
#
# Author: Wayne Marquette - 12/14/96
#
# Command line interface for PERL snmp->get funcion
#

use SNMP::Util;
$ENV{'MAX_LOG_LEVEL'} = 'status';

if (@ARGV < 1){
   print "Usage: \n";
   print "       snmpget <IP> <community string> <oid_list>\n";
   print "\n";
   print "       IP = IP address or Switch name\n";
   print "       comm = defaults to hostname\n";
   print "       oid_list = list of oids or names\n";
   exit;
}

#Look for command line arguements
$IP = $ARGV[0];
$Comm_string = $ARGV[1];
print "$IP - $Comm_string\n";
for ($i = 2; $i <= $#ARGV; $i ++){
       push @oid_list,$ARGV[$i];
}

my $snmp = new SNMP::Util(-device     => $IP,
                 -community => $Comm_string) or die "connection
failed";

@get_values = $snmp->get('ontvef','sysUpTimeInstance');
#@get_values = $snmp->get('ontvef',@oid_list);
print "@get_values\n";


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

Date: Fri, 30 May 2003 04:26:28 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Please help with this script
Message-Id: <U3BBa.23042$ca5.19969@nwrdny02.gnilink.net>

L Lamburt <leonid.lamburt@gte.com> writes:
> Steve Grazzini wrote:
>> Remarkably buglike, but I could only check it with 5.6.1...
>>
> So, is it a bug or some obscure feature?
> 

Neither, in fact -- it's just a funny-looking (ugly, evil, grumble grumble)
symbolic reference, as Jay Tilton has correctly pointed out.

-- 
Steve


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

Date: 29 May 2003 22:55:37 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: uninitialized value in eval block?
Message-Id: <1bff1830.0305292155.304f8b84@posting.google.com>

SeeMySig <spam.me.senseless@sitting.duck> wrote in message news:<LtzvpYLFGk1+Ewqk@nildram.co.uk>...
> In message <u98yspwvod.fsf@wcl-l.bham.ac.uk>, Brian McCauley 
> <nobull@mail.com> writes
> >SeeMySig <spam.me.senseless@sitting.duck> writes:
> >
> >> In the process of removing all warning violations from my CGI script,
> >> I find the following gets passed during warningsToBrowser(1):
> >>
> >> <!-- warning: Use of uninitialized value in concatenation (.) or
> >> string at (eval 18) line 32. -->
> >
> >Yes this is a known problem with CGI.pm.  It uses a kind of weird
> >autoload mechanism that uses eval EXPR (not eval BLOCK).  The problem
> >is that if an error or warning occurs in code that results from an
> >eval EXPR the location information is cyrptic.
> You mean I have been tearing out what little hair I have left for no 
> good reason :-(

Isn't learning a good reason?  Don't you know more about eval and
interpreting warning messages than you use to?

> 
> >This could be resolved by putting a #line directive into the string that
> >is evaled in CGI::_compile.
> >
>  Care to spell that one out for me?


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

Date: Thu, 29 May 2003 20:21:58 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: variable for current line number (of script)
Message-Id: <Xns938AD92FFBE5Fsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Eric Wilhelm <ericw@nospam.ku.edu> wrote in 
news:pan.2003.05.29.16.34.08.356856.8222@nospam.ku.edu:

> If a script is making an assumption to which the data does not conform, I
> would like to be able to print the line-number (or nearly so) of said
> assumption in a warning message.

"warn" does that for you.  What's the problem?

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPtax+2PeouIeTNHoEQJ6yACguwoU4Nhgar/FcDcMTnO3WAgRIZ8AoOeG
jvpGsCMFj0irdLVee5XzDZmk
=W8UF
-----END PGP SIGNATURE-----


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

Date: Fri, 30 May 2003 01:53:12 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: variable for current line number (of script)
Message-Id: <pan.2003.05.29.20.50.06.795561.8883@nospam.ku.edu>

On Thu, 29 May 2003 20:21:58 -0500, Eric J. Roode wrote:

> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> Eric Wilhelm <ericw@nospam.ku.edu> wrote in
> news:pan.2003.05.29.16.34.08.356856.8222@nospam.ku.edu:
> 
>> If a script is making an assumption to which the data does not conform,
>> I would like to be able to print the line-number (or nearly so) of said
>> assumption in a warning message.
> 
> "warn" does that for you.  What's the problem?

I see, the problem is me:

$perl -e 'warn "warning\n";'
warning

$perl -e 'warn "warning";'
warning at -e line 1.

$perl -e 'warn "warning","\n";'
warning

$perl -e 'warn "warning"," and\n", "other stuff";'
warning and
other stuff at -e line 1.

Why does the \n at the end kill the extra output?  Does it over-write it
or something?


--Eric


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

Date: Fri, 30 May 2003 01:57:54 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: variable for current line number (of script)
Message-Id: <pan.2003.05.29.20.54.51.644499.8883@nospam.ku.edu>

On Thu, 29 May 2003 18:48:02 -0500, Eric Schwartz wrote:

> Eric Wilhelm <ericw@nospam.ku.edu> writes:
>> On Thu, 29 May 2003 17:20:00 -0500, Winfried Koenig wrote:
>> > try:
>> > 
>> > print "line " . __LINE__ . ' "' . __FILE__ ."\n";
>> 
>> Exactly what I was looking for.
> 
> Nah, what you want is warn(); it's simpler and more maintainable.

except that warn() prints to stderr, which breaks any logging of the
output with a > redirect.

It might be that warn() is what you want in some instances, but that
__LINE__ is what you want in others.

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?

--Eric


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

Date: Thu, 29 May 2003 21:54:26 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: variable for current line number (of script)
Message-Id: <Xns938AE876EEA77sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Eric Wilhelm <ericw@nospam.ku.edu> wrote in
news:pan.2003.05.29.20.50.06.795561.8883@nospam.ku.edu:

> On Thu, 29 May 2003 20:21:58 -0500, Eric J. Roode wrote:
> 
>> "warn" does that for you.  What's the problem?

> I see, the problem is me:
> 
> $perl -e 'warn "warning\n";'
> warning
> 
> $perl -e 'warn "warning";'
> warning at -e line 1.
> 
> $perl -e 'warn "warning","\n";'
> warning
> 
> $perl -e 'warn "warning"," and\n", "other stuff";'
> warning and
> other stuff at -e line 1.
> 
> Why does the \n at the end kill the extra output?  Does it
over-write it
> or something?

It's a feature.  It's so you, the programmer, can choose whether or
not to display the line number and file name.

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+1scVY96i4h5M0egRAiU1AJ0e8pSbRBqDKjoIxGnb2gbStDi90gCg6zRr
pug2AqPbBLstOO4wVXkKo7Y=
=AO/o
-----END PGP SIGNATURE-----


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

Date: Fri, 30 May 2003 03:08:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: variable for current line number (of script)
Message-Id: <x7vfvtb088.fsf@mail.sysarch.com>

>>>>> "EW" == Eric Wilhelm <ericw@nospam.ku.edu> writes:

  EW> $perl -e 'warn "warning";'
  EW> warning at -e line 1.

  EW> $perl -e 'warn "warning","\n";'
  EW> warning

  EW> Why does the \n at the end kill the extra output?  Does it over-write it
  EW> or something?

did you read the docs on warn like i told you to? no, you listened to
others tell you to use warn and you did try it. and you still didn't
read the docs and find out what is happening there. this is a known
feature and you should rtfm already.

never use a new feature without reading the docs about it. you will
learn stuff.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 30 May 2003 05:43:54 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: variable for current line number (of script)
Message-Id: <pan.2003.05.30.00.40.49.296109.9774@nospam.ku.edu>

On Thu, 29 May 2003 22:08:07 -0500, Uri Guttman wrote:

>>>>>> "EW" == Eric Wilhelm <ericw@nospam.ku.edu> writes:
> 
>   EW> $perl -e 'warn "warning";'
>   EW> warning at -e line 1.
> 
>   EW> $perl -e 'warn "warning","\n";'
>   EW> warning
> 
>   EW> Why does the \n at the end kill the extra output?  Does it
>   over-write it EW> or something?
> 
> did you read the docs on warn like i told you to? 
Yes, but I guess I didn't read far enough to learn what I could with two
minutes of trying different things on the command line.

> no, you listened to
> others tell you to use warn and you did try it. and you still didn't
> read the docs and find out what is happening there. this is a known
> feature and you should rtfm already.
I've since spent another ten minutes reading, and apparently you have
better docs than I do, since my perldoc -f warn is about a page long and
refers to a bunch of other docs on %SIG and carp and such.  It would be
great to know that this is a known feature, but where tfitfm is it?  I
cannot find it in perlfunc, perlvar, or Carp, and Carp even implies that,
unlike warn(), it reports where in the code the error was called from.

Funny also that I didn't find __LINE__ in perlvar, since that is the
thing I had been looking for in the first place.

--Eric


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

Date: 30 May 2003 06:04:32 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: variable for current line number (of script)
Message-Id: <slrnbddt3f.pf1.sholden@flexal.cs.usyd.edu.au>

On Fri, 30 May 2003 05:43:54 GMT, Eric Wilhelm <ericw@nospam.ku.edu> wrote:
> On Thu, 29 May 2003 22:08:07 -0500, Uri Guttman wrote:
> 
>> no, you listened to
>> others tell you to use warn and you did try it. and you still didn't
>> read the docs and find out what is happening there. this is a known
>> feature and you should rtfm already.
> I've since spent another ten minutes reading, and apparently you have
> better docs than I do, since my perldoc -f warn is about a page long and
> refers to a bunch of other docs on %SIG and carp and such.  It would be
> great to know that this is a known feature, but where tfitfm is it?  I
> cannot find it in perlfunc, perlvar, or Carp, and Carp even implies that,
> unlike warn(), it reports where in the code the error was called from.

My documentation for warn has at the very first sentence:

    Produces a message on STDERR just like "die", but doesn't exit or
    throw an exception.

So if you want to know what the message is you need to read the "die"
documentation since it will do whatever it says (minus the exit or
exeption).

-- 
Sam Holden



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

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


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