[23647] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5854 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 25 00:05:55 2003

Date: Mon, 24 Nov 2003 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 24 Nov 2003     Volume: 10 Number: 5854

Today's topics:
    Re: ActiveX component cannot create object <david@digiportal.com>
    Re: Assigning split to a list: undefined values? (Malcolm Dew-Jones)
    Re: Assigning split to a list: undefined values? <bmb@ginger.libs.uga.edu>
    Re: clarification on comment <bxtrap01@comcast.net>
        module selction <allidance2002@hotmail.com>
    Re: module selction <invalid-email@rochester.rr.com>
    Re: newbie <STDIN> question <nospam@mailandnews.com>
    Re: Perl Editor <bmb@ginger.libs.uga.edu>
    Re: Perl Editor <jurgenex@hotmail.com>
    Re: push @arr, slice-of-href <eddhig22@yahoo.com>
    Re: push @arr, slice-of-href <noreply@gunnar.cc>
    Re: push @arr, slice-of-href <eddhig22@yahool.com>
    Re: push @arr, slice-of-href <noreply@gunnar.cc>
        Question regarding Net::FTP (D. Alvarado)
    Re: Question regarding Net::FTP <invalid-email@rochester.rr.com>
    Re: Reading dbf file over network possible? Default@IO_Error_1011101.xyz
    Re: status of redirecting STDOUT/STDERR to file (Jay Tilton)
    Re: trying to understand fork and wait (John)
    Re: trying to understand fork and wait (Tad McClellan)
    Re: undif as if it is 0 <invalid-email@rochester.rr.com>
    Re: unpack vs. split problem (really weird) <krahnj@acm.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Nov 2003 03:40:32 GMT
From: "David Jameson" <david@digiportal.com>
Subject: Re: ActiveX component cannot create object
Message-Id: <QaAwb.39756$Hb.13031239@news4.srv.hcvlny.cv.net>

From some experiments I have performed, it appears that this problem is due
to MISSING registry entries.
I've managed to put a few of the appropriate entries back in (by looking at
my older machine where everything is working) and have gotten past the
original error message (ActiveX component cannot create object) to a new
message "The server module cannot be found"

Clearly this means that the classID was now found but there's still
something missing that's causing it to not be able to invoke PerlSE.DLL
properly.

Any ideas?

Thanks,
D





"David Jameson" <david@digiportal.com> wrote in message
news:TJawb.20026$Hb.7095181@news4.srv.hcvlny.cv.net...
> I just moved to a new machine, now running XP. I have some MS Access code
> that invokes PerlScript. However, whenever I try to run it, I get the
error
> message
>
> Runtime error 429
> ActiveX component cannot create object
>
>
> I've looked around the web and seen this generic error which appears
> whenever ANY activeX component cannot be instantiated but I have not been
> able to find how to solve this for ActivePerl.
>
> I did try manually registering every DLL/OCX that I could find in the Perl
> folders  but that didn't help.
>
> Does anyone know how to fix this problem with ActivePerl?  ActiveState has
> not replied to my email messages for support.
>
>
> Thanks,
> David Jameson
>
>
>
>
> -- 
>
>
> ______________________
> Dr. David H. Jameson
> DigiPortal Software Inc
>
> Three quarters of the mail you receive on the internet
> is spam, and that's on a good day!
>
> Stop it all with ChoiceMail Enterprise
> http://www.digiportal.com
>
>
>




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

Date: 24 Nov 2003 17:02:52 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Assigning split to a list: undefined values?
Message-Id: <3fc2aa3c@news.victoria.tc.ca>

Dmitry Epstein (mitia.nospam@northwestern.edu.invalid) wrote:
: ko <kuujinbo@hotmail.com> wrote in
: news:bpme0m$25q$1@pin3.tky.plala.or.jp: 
: > Dmitry Epstein wrote:
: >> Here is a code snippet:
: >> 
: >> while ($line = <F>) {
: >>          my ($node1, $node2, $node3) = split ' ', $line;
: >>          last unless defined $node3;
: >>          ...
: >> }
: >> 
: >> The idea here was that the loop stops if the line was split
: >> into fewer than 3 values.  It doesn't work however: when the
: >> line has only 2 values, the variable $node3 is initialized
: >> with zero instead of remaining undefined.  How come?
: >> 
: >> (I have since changed the code to use an array instead of a
: >> list.) 
: >> 
: > 
: > Since the pattern ' ' is split()ing on whitespace, the newline
: > on each line results in an empty trailing field ('', which is
: > a defined value). So you need to get rid of the newline on
: > each line: 
: > 
: > use strict;
: > use warnings;
: > 
: > while (my $line = <DATA>) {
: >    chomp $line;
: >    my ($node1, $node2, $node3) = split ' ', $line;
: >    last unless defined $node3;
: >    print join(" ", $node1, $node2, $node3), "\n"
: > }
: > 
: > __DATA__
: > a s d
: > a s
: > 
: > HTH- keith

: I don't think so.  Split on ' ' is supposed to "chomp" any trailing 
: whitespace.  In fact, if I use an array to store the value of split 
: instead of a list of scalars, the array does not receive a null 
: value in the end.

Not exactly.  The "default" behaviour is to drop empty trailing fields,
but what does "default" mean?

perldoc -f split also states that assigning to a _list_ (which is what you
have) creates an implicit limit on the number of fields to be extracted.

So I am guessing that "default" is refering to the "limit", but since you
have implicitly defined a limit then you don't get the default behaviour.

Instead you get the first three fields, the third of which is the empty
string "found" at the end.


	"first-item  second-item \n"
         1111111111  22222222222   3 (3rd is 0 chars long)


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

Date: Mon, 24 Nov 2003 21:06:20 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Assigning split to a list: undefined values?
Message-Id: <Pine.A41.4.58.0311242032270.17692@ginger.libs.uga.edu>

On Fri, 22 Nov 2003, Dmitry Epstein wrote:

> Here is a code snippet:
>
> while ($line = <F>) {
>     	my ($node1, $node2, $node3) = split ' ', $line;
>     	last unless defined $node3;
>     	...
> }
>
> The idea here was that the loop stops if the line was split into
> fewer than 3 values.  It doesn't work however: when the line has
> only 2 values, the variable $node3 is initialized with zero instead
> of remaining undefined.  How come?

I doubt that $node3 is initialized to zero, but it is initialized to '',
apparently because of the "\n" at the end of $line.

That isn't what I would have expected from reading this in perldoc -f
split:

    If LIMIT is unspecified or zero, trailing
    null fields are stripped (which potential users of
    "pop" would do well to remember)

but if you chomp $line, your logic works as it appears you intend...

% cat -n ./qt
     1  #!/usr/local/bin/perl
     2  use strict;
     3  use warnings;
     4
     5  my $line = '';
     6  while ($line = <DATA>) {
     7          my ($node1, $node2, $node3) = split " ", $line;
     8          last unless defined $node3;
     9          #...
    10          print "-$node1- -$node2- -$node3- : $line";
    11  }
    12
    13  __DATA__
    14  1 2 3
    15  1 2

% ./qt
-1- -2- -3- : 1 2 3
-1- -2- -- : 1 2

% cat -n ./qt
     1  #!/usr/local/bin/perl
     2  use strict;
     3  use warnings;
     4
     5  my $line = '';
     6  while ($line = <DATA>) {
     7          chomp $line;
     8          my ($node1, $node2, $node3) = split " ", $line;
     9          last unless defined $node3;
    10          #...
    11          print "-$node1- -$node2- -$node3- : $line\n";
    12  }
    13
    14  __DATA__
    15  1 2 3
    16  1 2

% ./qt
-1- -2- -3- : 1 2 3


Regards,

Brad


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

Date: Mon, 24 Nov 2003 23:50:57 GMT
From: "bbxrider" <bxtrap01@comcast.net>
Subject: Re: clarification on comment
Message-Id: <BPwwb.294922$Tr4.931442@attbi_s03>

ok lets close this book, thanks for clarifying tintin, i guess this is what
what i was wondering about your
comment, so i do owe you an apology
and by the way i do understand the code much better now, again i thank
everybody for their help, this
works for me
and also did some more testing of that original code after reading the info
from gunnar:

use URI::Escape;
 $safe = uri_escape("10% is -%20- enough\n");
 $str  = uri_unescape($safe);
print "raw result of 10%.... is $safe<br>";
print "result of 10% is enough... after uri_unescape is $str<br>";
$safe=~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/ge ;
print "result of 10% is enough... after regular expression is $safe";

the results printed on a web page were:
raw result of 10%.... is 10%25%20is%20-%2520-%20enough%0A
result of 10% is enough... after uri_unescape is 10% is -%20- enough
result of 10% is enough... after regular expression is 10% is -%20- enough

the results of using uri_unescape seem to be the same as the RE, at least
with this particular string
so that gives me more confidence about the validity of the code
however, i must admit as well, that especially with regular exrpessions, i
will probably be wondering
if it really will always work for a quite a while

"Tintin" <me@privacy.net> wrote in message
news:bpsisi$1s4chk$1@ID-172104.news.uni-berlin.de...
>
> "bbxrider" <bxtrap01@comcast.net> wrote in message
> news:lDfwb.215071$mZ5.1626135@attbi_s54...
> > i can't know the exact motivation of tintin's comments and if i
> > misintrepeted, i regret that.
> > the extent and tone of his reply, solely as written, seems to be
> questioning
> > my right to even ask the question
> > it has a sarcastic tone and it seems to be scolding or demeaning, if
thats
> > all somebody has to say without
> > any hint of 'maybe you should try this or read this, etc' then i can
only
> > assume they have not other motivation
> > other than negativity.
>
> The purpose of my comment is that I wouldn't like to claim a piece of code
I
> found (that isn't peer reviewed) works without fully understanding how it
> works.
>
> The reason for this is that unless you provide a wide range of test data
to
> see if there are any flaws in the code, it's a little difficult to tell
how
> well it works.
>
> I can't for the life of me comprehend how you managed to take offense at
> that and interpret it as scolding, demeaning and sarcastic.
>
>




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

Date: Tue, 25 Nov 2003 14:10:52 +1100
From: Alison <allidance2002@hotmail.com>
Subject: module selction
Message-Id: <3FC2C83C.3050401@hotmail.com>

Hello

I could spend few weeks looking and trying every module on cpan till I 
find something works. or I could ask on this board.

is there a good module to plot my stock data 'bar chart' some module 
that is known to do it all kind of thing.

thank you



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

Date: Tue, 25 Nov 2003 03:37:37 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: module selction
Message-Id: <3FC2CD5C.2040109@rochester.rr.com>

Alison wrote:

 ...

> is there a good module to plot my stock data 'bar chart' some module 
> that is known to do it all kind of thing.
 ...


GD::Graph might do what you want without undue hassle.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Tue, 25 Nov 2003 03:41:21 GMT
From: leegold <nospam@mailandnews.com>
Subject: Re: newbie <STDIN> question
Message-Id: <BbAwb.1467$Ll3.683@nwrddc01.gnilink.net>

Gunnar Hjalmarsson wrote:
> leegold wrote:
> 
>> What if a user presses enter for the line number?
>> Please see below.
>> How will I test for that and make $linenum default to 1 ?
> 
> 
> After the line
> 
>     chomp($linenum);
> 
> you can for instance add:
> 
>     $linenum ||= 1;

Thank you. An empty var will evaluate to false.
I read it but it did not "click" till I saw your post.
Thanks again for the help.

Lee G.




> 
>> chomp(&linenum);
> 
> --------^
> 
>> IF (not $linenum =~ m/^\d+$/) {
> 
> --^^
> 
> Please paste, not type, code that you post.
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
> 


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

Date: Mon, 24 Nov 2003 19:58:54 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Perl Editor
Message-Id: <Pine.A41.4.58.0311241958340.17692@ginger.libs.uga.edu>

On Mon, 24 Nov 2003, AnnMarie wrote:

> What is the best editor for Perl CGI-Scripts?


perldoc -q editor

Regards,

Brad


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

Date: Tue, 25 Nov 2003 01:40:42 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl Editor
Message-Id: <uqywb.1182$Ll3.639@nwrddc01.gnilink.net>

AnnMarie wrote:
> What is the best editor for Perl CGI-Scripts?

"Real programmers "cp /dev/audio a.out" and whistle into the mike."
(Randal L. Schwartz )

jue




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

Date: Tue, 25 Nov 2003 13:41:50 +1100
From: Edo <eddhig22@yahoo.com>
Subject: Re: push @arr, slice-of-href
Message-Id: <3FC2C16E.30200@yahoo.com>

Gunnar Hjalmarsson wrote:
 > Edo wrote:
 >
 >> in the if block, all what I want to do is use the $tmp as a key for
 >> section of %dbits which the sub check evaluated its \@vd.
 >
 >
 > In that case, why are you using @tmp as the key?
 >

I really don't know, I am just doing all I can with this thing over my
head, if it wasn't for the help of many on the board I would not have
been able to install linux let alone write a perl prog.

sub scan (\%\%\%) {
      my ($dbits, $sbits, $set) = @_;
      my @kd = keys %$dbits; my @ks = keys %$sbits;
      my @vs = @$sbits{ @ks };
      for( 0 .. (@kd - @ks) ) {
	my @vd = @$dbits{ @kd[$_ .. $_+@ks-1 ] };
	my $tmp = check( \@vd, \@vs );
	my @k = (keys @$set{ @kd[$_ .. $_+@ks-1 ]});
	my $max = (sort {$a <=> $b} @k)[0] || 0;
	if ( $tmp > $max ) {
	    $set->{$tmp} = @$dbits{@kd[$_ .. $_+@ks-1 ]};
	}
      }
}

Type of arg 1 to keys must be hash (not hash slice) at path line 43,
near "})"

well, I want the that has slice in the results, which I expect to be like

%set-HoAoH = (
		tmp1 => [
			dbits slice1,
			 dbits slice2 if the same tmp
				#each slice @kd[$_ .. $_+@ks-1 ] and has its own keys and values
			]


		tmp2 =>


		tmp3 =>
		)

man, it took me 20 minuts just to put my thoughts in the question. well.
it will take me a long time to be 1/10 of some of you out there, thanks
alot for helping.



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

Date: Tue, 25 Nov 2003 04:35:52 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: push @arr, slice-of-href
Message-Id: <bpuj8h$1rplkm$1@ID-184292.news.uni-berlin.de>

Edo wrote:
> 
>     my @k = (keys @$set{ @kd[$_ .. $_+@ks-1 ]});

<snip>

> Type of arg 1 to keys must be hash (not hash slice) at path line
> 43, near "})"

It's good that you now work with strictures enabled.

A hash slice is not a hash. It's a list with some of the _values_ from
the hash, and it has no keys. Accordingly, Perl complains when you try
to extract the non-existing keys.

Isn't this what you actually want:

     my @k = @kd[ $_ .. $_+@ks-1 ];

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Tue, 25 Nov 2003 15:54:11 +1100
From: Edo <eddhig22@yahool.com>
Subject: Re: push @arr, slice-of-href
Message-Id: <3FC2E073.8090009@yahool.com>

Gunnar Hjalmarsson wrote:
> Edo wrote:
> 
>>
>>     my @k = (keys @$set{ @kd[$_ .. $_+@ks-1 ]});
> 
> 
> <snip>
> 
>> Type of arg 1 to keys must be hash (not hash slice) at path line
>> 43, near "})"
> 
> 
> It's good that you now work with strictures enabled.
> 
> A hash slice is not a hash. It's a list with some of the _values_ from
> the hash, and it has no keys. Accordingly, Perl complains when you try
> to extract the non-existing keys.
> 
> Isn't this what you actually want:
> 
>     my @k = @kd[ $_ .. $_+@ks-1 ];
> 

no, I need to find out what is the highest key "$tmp" inside the HoAoH %set
so I thought to do
#get all of the keys in the %set in an array @k

     my @k = (keys @$set{ @kd[$_ .. $_+@ks-1 ]});

#then sort it and get the first value which is the max
     my $max = (sort {$a <=> $b} @k)[0] || 0;



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

Date: Tue, 25 Nov 2003 05:54:56 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: push @arr, slice-of-href
Message-Id: <bpunte$1s0ro3$1@ID-184292.news.uni-berlin.de>

Edo wrote:
> Gunnar Hjalmarsson wrote:
>> Isn't this what you actually want:
>> 
>>     my @k = @kd[ $_ .. $_+@ks-1 ];
> 
> no, I need to find out what is the highest key "$tmp" inside the
> HoAoH %set so I thought to do
> #get all of the keys in the %set in an array @k
> 
>     my @k = (keys @$set{ @kd[$_ .. $_+@ks-1 ]});

Then why not just

     my @k = keys %$set;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 24 Nov 2003 18:59:51 -0800
From: laredotornado@zipmail.com (D. Alvarado)
Subject: Question regarding Net::FTP
Message-Id: <9fe1f2ad.0311241859.26fcf172@posting.google.com>

Hello,
   I have a simple question regarding this helpful module.  I would
like to know how to check if a remote directory exists, and if in
fact, that is indeed a directory.  Thanks in advance, Dave


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

Date: Tue, 25 Nov 2003 03:35:38 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Question regarding Net::FTP
Message-Id: <3FC2CCE6.4060102@rochester.rr.com>

D. Alvarado wrote:

> Hello,
>    I have a simple question regarding this helpful module.  I would
> like to know how to check if a remote directory exists, and if in
> fact, that is indeed a directory.  Thanks in advance, Dave
> 

One way would be to use the ->dir method on a Net::FTP session object. 
Then peruse the results of that method to see if your desired directory 
is present or not.  I think perhaps the format of the listing could vary 
depending upon the remote FTP server, as the ->dir method returns what 
the remote server sends.

You could also use the ->cwd method to attempt to change directory to 
your directory -- if it fails, you could assume the directory doesn't exist.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Mon, 24 Nov 2003 23:09:46 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: Reading dbf file over network possible?
Message-Id: <_cwwb.526$ML.144@nwrdny02.gnilink.net>

> Hello Group,
> 
> My perl program is on a Mac OSX and the dbf file on a Windows
> machine(both networked).
> My question is can I perform a DBI->connect("DBI:XBase: ... ") from
> the Mac to access the dbf file on Windows machine giving its IP
> address? If yes, what will be its format? Do I need any other Perl
> networking modules to do so?
> 
> Or is there is any other option?
> 
> Or is its something IMPOSSIBLE?
> Waiting for some help
> 
> TIA
yea i saw something on CPAN that does just that (using ftp).
it's listed under network modules can't miss it. g'luck
> Vijoy
> 



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

Date: Tue, 25 Nov 2003 00:58:49 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: status of redirecting STDOUT/STDERR to file
Message-Id: <3fc2a900.157291075@news.erols.com>

ttyp32000@yahoo.com (jonathan) wrote:

: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<bpklsj$da3$1@mamenchi.zrz.TU-Berlin.DE>...
: > jonathan <ttyp32000@yahoo.com> wrote in comp.lang.perl.misc:
: > > hey all,
: > > 
: > > just curious, but if I do the following (after __cut__), does this
: > > have any repercussions for the 'regular' STDERR, STDOUT handles?
: > 
: > It shouldn't.
: > 
: > Why are you dealing with STDOUT in redirect()?  You're not using it in
: > any way.

: I appreciate the help, but the attitude could be a little less snide. 

There was nothing in the article that betrayed any attitude, snide or
otherwise.

Pointing out that localizing the STDOUT filehandle has no useful effect
because it is never used in that dynamic scope was actually a partial
answer to the question.

: The code snippet was designed to show whether or not any effects might
: happen outside of the subroutine.

It depends on what is meant by "outside."

Outside of the sub's lexical scope but still within the typeglob's
localized dynamic scope, yes.

Outside of the typeglob's dynamic scope, i.e. when the subroutine exits,
no.



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

Date: 24 Nov 2003 15:58:00 -0800
From: jguad98@hotmail.com (John)
Subject: Re: trying to understand fork and wait
Message-Id: <a964da31.0311241558.7ef49584@posting.google.com>

My original script has been hacked & massaged & now looks like it
ought to work as intended.  I made a dummy copy to run in a test
environment.  I ran it and it failed ... specifically the fork is
failing with this message:

Uncaught exception from user code:
        17234: cannot fork: No such file or directory at
 ./testlogreader.pl line 77.
Use of uninitialized value at ./testlogreader.pl line 25 (#1)

    (W) An undefined value was used as if it were already defined.  It
was
    interpreted as a "" or a 0, but maybe it was a mistake.  To
suppress this
    warning assign an initial value to your variables.


I put "use:diagnostics" in the script  ... without the diagnostics
module it just said fork failed at line 77 without any further ado. 
The thing that bothers me the most is the failure to fork ... it says
"no such file or directory" ... what could that possibly be trying to
tell me?  Here is the section of script with the fork:

   74       #-----------------------------------------------------
   75       # now we fork
   76       #-----------------------------------------------------
   77       my $kidpid = fork() or die "$$: cannot fork: $!";
   78       if($kidpid) {

There's nothing in the fork instruction that references any file or
directory, so why does it look like it's trying to find a file or dir?

Any assistance will be mucho appreciated ...

John


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

Date: Mon, 24 Nov 2003 19:54:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: trying to understand fork and wait
Message-Id: <slrnbs5di1.2eb.tadmc@magna.augustmail.com>

John <jguad98@hotmail.com> wrote:

> I ran it and it failed ... specifically the fork is


So did you then read the docs for fork() ?


> failing with this message:
> 
> Uncaught exception from user code:
>         17234: cannot fork: No such file or directory at
> ./testlogreader.pl line 77.
> Use of uninitialized value at ./testlogreader.pl line 25 (#1)
> 
>     (W) An undefined value was used as if it were already defined.  It
> was
>     interpreted as a "" or a 0, but maybe it was a mistake.  To
> suppress this
>     warning assign an initial value to your variables.
> 
> 
> I put "use:diagnostics" in the script  


I doubt that...


> ... without the diagnostics
> module it just said fork failed at line 77 without any further ado. 


That is what it is supposed to do you know.

All "use diagnostics" does is look up the message in
perldiag.pod for you.


> The thing that bothers me the most is the failure to fork ... it says
> "no such file or directory" ... what could that possibly be trying to
> tell me?  


If the fork did _not_ fail, then $! will contain a left-over
message and cannot be relied upon.


>    77       my $kidpid = fork() or die "$$: cannot fork: $!";



   perldoc -f fork


Says that fork() will return one of three things:

   PID in the parent process

   zero in the child process

   undef if the fork() fails

Your die() will execute in either of those last two cases.


   defined(my $kidpid = fork()) or die "$$: cannot fork: $!";


> There's nothing in the fork instruction that references any file or
> directory, so why does it look like it's trying to find a file or dir?


It isn't, the message is stale.

The real problem is the logic of your "or die".


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


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

Date: Tue, 25 Nov 2003 04:14:16 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: undif as if it is 0
Message-Id: <3FC2D5F3.7010708@rochester.rr.com>

Edo wrote:

 ...

> I am getting $max = undif if nothing in @top3, but due to the way the 

undef?----------------^^^^^

> code below is written, I need it to show 0 instead.
> do I have to change the code? or there is an operator to change undif to 
> 0 in this case?
 ...
>     my @kd = keys %$dbits; my @ks = keys %$sbits;
>     my @vs = @$sbits{ @ks };
> 
>     for( 0 .. 5 ) {
>     my $tmp = 4;
>     my $max = (sort {$b <=> $a} @top3)[0];
>     if ( $tmp > $max ) {
>         ... code
>         push @top3, \%set;
>     }
>     }
> 

Unless you need the contents of $max for something else not shown, it 
will not matter if $max is 0 or undef.  Since > is a numeric comparison 
operator, undef will be treated the same as 0 in the comparison, and you 
don't use $max elsewhere.  If you really need it to be a numeric 0, put:

     $max+=0;

after the sort.  That will force a "numerification" of $max, and will be 
a no-op if $max is already numeric.  Or append +0 to the end of the 
sort, as in:

     my $max = (sort {$b <=> $a} @top3)[0]+0;

Also, I note that you are pushing references to the hash %set to the 
array @top3, which is the same array you are sorting on.  There are two 
things wrong here:  First, the next time through your for loop, you will 
sort this hash reference numerically with whatever was already in @top3, 
and then compare the largest of the result with $max.  That is not a 
reasonable thing to do with references.  What it is you are really 
trying to accomplish?  The second problem is (although you haven't shown 
where hash %set is defined), you may be pushing references to *the same 
hash* into @top3 time after time.  If so, all the references will then 
point to *the same hash*, the one called %set, and you'll wonder why you 
have an array full of references to the same hash over and over.  This 
is a very common bug, and one that can be a bit tricky to ferret out. 
You should probably push a reference to an anonymous copy of your hash, 
as in:

     push @top3,{%set};

BTW, please improve your indenting style.  The lack of reasonable 
indenting makes your program harder to follow than necessary.  Thanks.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Mon, 24 Nov 2003 23:26:00 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: unpack vs. split problem (really weird)
Message-Id: <3FC29386.BFA1A046@acm.org>

Mike Hunter wrote:
> 
> I'm having a weird problem.  Check this out:
> 
> [snip]
> 
> mth_inet_ntoa_debug length $stuff: 4
> mth_inet_ntoa debug lengths 1 1 1 1
> mth_inet_ntoa debug 00000001000001001010110000000000
> mth_inet_ntoa debug #00000001#00000100#10101100#00000000#
> 
> Now, if I change from
> 
> split //, $stuff
> 
> to
> 
> unpack "CCCC", $stuff
> 
> I get these totally weirded-out results:
> 
> mth_inet_ntoa_debug length $stuff: 4
> mth_inet_ntoa debug lengths 3 2 2 1
> mth_inet_ntoa debug 00000001000001001010110000000000
> mth_inet_ntoa debug #100011000100110000011100#1100110001001100#1010110011001100#00001100#
> 
> [snip]
> 
> Shouldn't unpack "CCCC" work?

The equivalent of:

my @o = split //, $stuff

Is:

my @o = unpack 'a' x length $stuff, $stuff


The equivalent of:

my @o = unpack 'CCCC', $stuff

Is:

my @o = map ord, split //, $stuff



John
-- 
use Perl;
program
fulfillment


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

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


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