[29134] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 378 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 25 09:10:28 2007

Date: Wed, 25 Apr 2007 06:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 25 Apr 2007     Volume: 11 Number: 378

Today's topics:
        2D array values got replaced error <csoon@xilinx.com>
    Re: 2D array values got replaced error anno4000@radom.zrz.tu-berlin.de
    Re: Cant open a file with just a relative path <tadmc@augustmail.com>
    Re: Cant open a file with just a relative path (Randal L. Schwartz)
    Re: How solve this error mukunthini@gmail.com
    Re: How solve this error anno4000@radom.zrz.tu-berlin.de
    Re: How to parse text file into hash table <tadmc@augustmail.com>
    Re: How to parse text file into hash table <tadmc@augustmail.com>
    Re: How to retrieve the Perl script returned value in C <tadmc@augustmail.com>
    Re: How to trigger garbage collection anno4000@radom.zrz.tu-berlin.de
    Re: How to trigger garbage collection <ignoramus13980@NOSPAM.13980.invalid>
        new CPAN modules on Wed Apr 25 2007 (Randal Schwartz)
        passing objects to threads gaurava@lycos.com
    Re: Re-inventing the wheel, same hash, three scripts <tadmc@augustmail.com>
        signal HANDLER in perl gaurava@lycos.com
        trying to generate integer from string <bpatton@ti.com>
    Re: trying to generate integer from string <wahab-mail@gmx.de>
    Re: trying to generate integer from string anno4000@radom.zrz.tu-berlin.de
    Re: trying to generate integer from string <wahab-mail@gmx.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Apr 2007 13:00:19 +0800
From: "Ken Soon" <csoon@xilinx.com>
Subject: 2D array values got replaced error
Message-Id: <f0mne5$hg41@cnn.xsj.xilinx.com>

Hmm I go through a list
-7.9 2.1 F
-7.4 2.1 F
-6.9 2.1 F
-6.4 2.1 F
-5.9 2.1 P
-7.9 2.2 F
-7.4 2.2 F
-6.9 2.2 F
-6.4 2.2 F
-5.9 2.2 P
And i use the first and 2nd value as counters for my 2D array and third one 
as the value
Storing using the following code: (I have cut away most codes for simplicity 
sake)
while (<file1>)
{
    if ($_ =~ /Site/)
    {
      @arr = split(/\s+/,$_);
          $var1 = $arr[6];
          $var2 = $arr[7];
          $a[$var1][$var2] = $arr[9];
     }
}

open (report, ">C://perl//report.txt") or die ("File Invalid");

Printing with the following code ($lastv is 2.2, $firstv is 2.1, $lasti 
is -5.9, $firsti is -7.9)
for ($i=$lastv;$i>=$firstv ;$i=$i-0.1)
{
     print $a[-0.01][2.2];
     for ($j=$firsti;$j<=$lasti;$j=$j+0.5)
     {
          print report "$a[$j][$i],";
     }
}
close report;

However, I got a matrix of just P printed out
And if I changed the last value from a P to an F, I get the matrix of F. It 
is as though the last value assigned will replace all the values in the 
array.
is there something I should be careful of when storing values in a 2D array? 




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

Date: 25 Apr 2007 07:17:45 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: 2D array values got replaced error
Message-Id: <598dkpF2jqhf6U1@mid.dfncis.de>

Ken Soon <csoon@xilinx.com> wrote in comp.lang.perl.misc:
> Hmm I go through a list
> -7.9 2.1 F
> -7.4 2.1 F
> -6.9 2.1 F
> -6.4 2.1 F
> -5.9 2.1 P
> -7.9 2.2 F
> -7.4 2.2 F
> -6.9 2.2 F
> -6.4 2.2 F
> -5.9 2.2 P
> And i use the first and 2nd value as counters for my 2D array and third one 
> as the value

You say counters (index is the common term), but the values are
not natural numbers.  Arrays (in Perl and elsewhere) take integer
indices.  A float point number is first converted to an integer.
Also, negative indices are special (they count from the end of the
array).

> Storing using the following code: (I have cut away most codes for simplicity 
> sake)
> while (<file1>)
> {
>     if ($_ =~ /Site/)
>     {
>       @arr = split(/\s+/,$_);
>           $var1 = $arr[6];
>           $var2 = $arr[7];
>           $a[$var1][$var2] = $arr[9];
>      }
> }

[more code with similar problems snipped]

That won't do what you want.  Use a hash %a instead of the array @a.

Anno


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

Date: Tue, 24 Apr 2007 21:57:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Cant open a file with just a relative path
Message-Id: <slrnf2tgtk.6fi.tadmc@tadmc30.august.net>

skieros <nikos1337@gmail.com> wrote:
> open(FILE, ">>/somefolder/somesubfolder/digest.passwd") or die $!;
                ^
                ^ lose this char, or put a dot in front of it

> Wehn i try to use this relative path 


relative paths do not start with a directory separator character.

They are relative to the current directory, hence the "relative"
in "relative path".


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


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

Date: Wed, 25 Apr 2007 02:50:01 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: skieros <nikos1337@gmail.com>
Subject: Re: Cant open a file with just a relative path
Message-Id: <861wi8kcl2.fsf@blue.stonehenge.com>

>>>>> "skieros" == skieros  <nikos1337@gmail.com> writes:

skieros> open(FILE, ">>/somefolder/somesubfolder/digest.passwd") or die $!;
skieros>      print FILE "$user:$realm:" . Digest::MD5::md5_hex("$user:$realm:
skieros> $pass") . "\n";
skieros> close(FILE);

skieros> Wehn i try to use this relative path instead of d:\www\blabla which is
skieros> absolute apache tells me it cant find the file.

This question was asked and answered on perlmonks.  Please don't
repeat the same thread here.

And I find it annoying that someone posts the same question to multiple help
forums without disclosing such.  It causes an unneeded waste of resources.

But, we'll always have newbies, I guess.

print "Just another Perl hacker,"; # the original

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

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: 25 Apr 2007 03:45:26 -0700
From: mukunthini@gmail.com
Subject: Re: How solve this error
Message-Id: <1177497926.249979.302590@t38g2000prd.googlegroups.com>

Dear Anno,
Thaks alot for your reply
i've changed the codes as you mentioned, when i run in web browser it
is displaying "1". that is from the last print cmd. under error log /
var/log/httpd the following 2 errors displayed.
[Wed Apr 25 21:31:52 2007] [error] [client 127.0.0.1] [Wed Apr 25
21:31:52 2007] hi.pl: Cannot open counter.dat for reading: No such
file or directory at /var/www/cgi-bin/hi.pl line 7.
[Wed Apr 25 21:31:52 2007] [error] [client 127.0.0.1] [Wed Apr 25
21:31:52 2007] hi.pl: Cannot open counter.dat for writing: Permission
denied at /var/www/cgi-bin/hi.pl line 14.
when i executed from terminal it gives this error " [Wed Apr 25
21:51:00 2007] hi.pl: Cannot open counter.dat for reading: No such
file or directory at hi.pl line 7 " and the new file "counter.dat" is
created under working directory and "1" is stored in that file.
Again if i execute the same form web browser now it is dispalying "2"
and in the log only writing error displayed.so it is reading from the
file, not writing the incremented value. when i execute again the same
value "2" is displaying in web browser.
But when i executing from terminal is working reading and wring new
value to that file.

#!/usr/local/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
print "Content-type: text/html\n\n";
use strict;

  open (COUNT, "counter.dat") or warn "Cannot open counter.dat for
reading: $!";
  my $hitcount = <COUNT>;
  close COUNT;

  $hitcount = $hitcount + 1;

  open (COUNT, "> counter.dat") or warn "Cannot open counter.dat for
writing: $!";
  flock(COUNT, 2);
  print COUNT "$hitcount";
  close COUNT;

  print "$hitcount";

exit;

i have given read and write permission to both file and the directory
(cgi-bin and counter.dat) (chmod 777)....

So, is this error happened due to apache configuration mistake? do i
need to change the httpd.conf file?
or is that web browser (mozilla) doesnt have permission to write file?
how can i overcome this? pls help me....

regards,
Mukunthini





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

Date: 25 Apr 2007 12:38:12 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How solve this error
Message-Id: <5990dkF2k43l0U1@mid.dfncis.de>

 <mukunthini@gmail.com> wrote in comp.lang.perl.misc:
> Dear Anno,
> Thaks alot for your reply

Which reply do you mean?  It's been almost three days.  In the
meantime, I've read hundreds of questions similar to yours
and answered a few.  Pleas quote some context when you reply.

> i've changed the codes as you mentioned, when i run in web browser it
> is displaying "1". that is from the last print cmd. under error log /
> var/log/httpd the following 2 errors displayed.
> [Wed Apr 25 21:31:52 2007] [error] [client 127.0.0.1] [Wed Apr 25
> 21:31:52 2007] hi.pl: Cannot open counter.dat for reading: No such
> file or directory at /var/www/cgi-bin/hi.pl line 7.

Okay, so the file doesn't exist where it is expected.  You should
check for that anyway and react accordingly.

> [Wed Apr 25 21:31:52 2007] [error] [client 127.0.0.1] [Wed Apr 25
> 21:31:52 2007] hi.pl: Cannot open counter.dat for writing: Permission
> denied at /var/www/cgi-bin/hi.pl line 14.

Clearly, whoever is running the web server doesn't have write
access to that directory.

> when i executed from terminal it gives this error " [Wed Apr 25
> 21:51:00 2007] hi.pl: Cannot open counter.dat for reading: No such
> file or directory at hi.pl line 7 " and the new file "counter.dat" is
> created under working directory and "1" is stored in that file.

> Again if i execute the same form web browser now it is dispalying "2"
> and in the log only writing error displayed.so it is reading from the
> file, not writing the incremented value. when i execute again the same
> value "2" is displaying in web browser.
> But when i executing from terminal is working reading and wring new
> value to that file.
> 
> #!/usr/local/bin/perl
> use CGI::Carp qw(fatalsToBrowser);
> use CGI qw/:standard/;
> print "Content-type: text/html\n\n";
> use strict;
> 
>   open (COUNT, "counter.dat") or warn "Cannot open counter.dat for
> reading: $!";
>   my $hitcount = <COUNT>;
>   close COUNT;
> 
>   $hitcount = $hitcount + 1;
> 
>   open (COUNT, "> counter.dat") or warn "Cannot open counter.dat for
> writing: $!";
>   flock(COUNT, 2);
>   print COUNT "$hitcount";
>   close COUNT;
> 
>   print "$hitcount";
> 
> exit;
> 
> i have given read and write permission to both file and the directory
> (cgi-bin and counter.dat) (chmod 777)....

A risky thing to do.  Apparently it hasn't had the desired effect
because the web server still doesn't have write access.

> So, is this error happened due to apache configuration mistake? do i
> need to change the httpd.conf file?

That is way off topic in clpm.  I don't know.

> or is that web browser (mozilla) doesnt have permission to write file?
> how can i overcome this? pls help me....

The *browser* has nothing to do with it.  CGI happens on the web
server.

You'll have to discuss this in a news group that is about web server
configuration.  It's outside Perl territorry.

Anno


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

Date: Tue, 24 Apr 2007 21:30:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to parse text file into hash table
Message-Id: <slrnf2tfav.6fi.tadmc@tadmc30.august.net>

anitawa@gmail.com <anitawa@gmail.com> wrote:


> I am new to perl and i need some help.


A hash access starts with a dollar sign.

A hash subscript goes in curly braces.

Statements in Perl are separated with a semicolon.


> myhash(start) = ""
> myhash(day) = "1,2,3"


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


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

Date: Tue, 24 Apr 2007 21:36:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to parse text file into hash table
Message-Id: <slrnf2tfls.6fi.tadmc@tadmc30.august.net>

anitawa@gmail.com <anitawa@gmail.com> wrote:


> Basically i have some text file like this:
>
> start -day 1,2,3 -month 6,12 -message "there is a message for you" -
> group book club -emergency


Please speak Perl rather than English, when possible.

If you had (as I do below) then everybody knows what your real
data looks like (it appears your posting software word wrapped
it in a bad place).

Have you seen the Posting Guidelines that are posted here frequently?



Your data is inconsistent as the first key-to-be does not start
with a hyphen like all of the other ones do, so I added a hyphen
below.


> I want to put this into a hash table like this
>
> myhash(start) = ""
> myhash(day) = "1,2,3"
> myhash(month) = "6,12"
> myhash(message) = "there is a message for you"
> myhash(group) = "book club"
> myhash(emergency) = ""
>
>
> Can someone help me get started?


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

my $str = '-start -day 1,2,3 -month 6,12 -message "there is a message '
        . 'for you" -group book club -emergency';

my %myhash = $str =~ /(-\S+)\s*([^-]*)/g;

print qq($_  ==>  "$myhash{$_}"\n) for sort keys %myhash;
-----------------------------


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


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

Date: Tue, 24 Apr 2007 21:50:21 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to retrieve the Perl script returned value in C program? Many thanks
Message-Id: <slrnf2tgfd.6fi.tadmc@tadmc30.august.net>

mike <needpassion@gmail.com> wrote:

> Subject: How to retrieve the Perl script returned value in C program? Many thank


The same way you would retrieve an exit value (not a return value)
from a program written in any other programming language.

That is, you have a C question, not a Perl question.

comp.lang.c is over thataway ==>

:-)


> Here comes the question: How can I return 0 or 1 from Perl script to
> the C program? 


That is not the same question as in your Subject...

   perldoc -f exit


> I made a C test program, and called the Perl script
> this way:
>
> int ret_val = system("perl_script email_file_name");
>
> When I call exit(0) in the Perl script, 


It looks like you already know how to exit with a 0 or 1 from
your Perl program.


> the ret_val in the C test
> program is 0; but when I call exit(1) in the Perl script, the ret_val
> in the C test program is 256,
>
> How come it happens this way? Any suggestion would be appreciated.


I would suggest reading the documentation for the (C) system() function.

(it very likely behaves similarly to Perl's system() function,
 so maybe you could get a clue from reading that description...)


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


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

Date: 25 Apr 2007 09:37:04 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How to trigger garbage collection
Message-Id: <598lq0F2je7leU1@mid.dfncis.de>

Ignoramus2319  <ignoramus2319@NOSPAM.2319.invalid> wrote in comp.lang.perl.misc:
> I have a script that runs 10 hours or so, using XML::Simple,
> HTML::TreeBuilder, DBI, etc. I do properly use 'my' variables, so that
> they get deleted when they get out of scope, and for HTML::TreeBuilder
> trees, I do use delete method to trigger garbage collection. I also
> 'use strict' to let me know if I am making any scoping mistakes.
> 
> I do use one global hash that maps integers to integers, which I
> estimate to be about 20,000 integers. (not much) I also have a second
> hash with not much more. 
> 
> Despite that, my script grows to large sizes in memory, which screws
> things up. (600+ MB)
> 
> What I would like to know is whether I can trigger some sort of
> garbage collection that deletes circular structures and everything
> else that perl can find, besides just doing reference count based
> deletion. I would then do that periodically, say every 100
> iterations. 

As Xho said, the best solution would be to find the leak and
eliminate it.

For a quick-and-dirty solution you could restart the script
periodically.  It seems that the state you need to keep is
in one or both of those hashes of integers.  Every so-many
iterations you could save these to disk and restart

    # save state
    exec $^X, $0;
    # restore state
    # continue

Anno


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

Date: Wed, 25 Apr 2007 08:06:11 -0500
From: Ignoramus13980 <ignoramus13980@NOSPAM.13980.invalid>
Subject: Re: How to trigger garbage collection
Message-Id: <rJOdnR8ufr_ez7LbnZ2dnUVZ_hudnZ2d@giganews.com>

On 25 Apr 2007 09:37:04 GMT, anno4000@radom.zrz.tu-berlin.de <anno4000@radom.zrz.tu-berlin.de> wrote:
> Ignoramus2319  <ignoramus2319@NOSPAM.2319.invalid> wrote in comp.lang.perl.misc:
>> I have a script that runs 10 hours or so, using XML::Simple,
>> HTML::TreeBuilder, DBI, etc. I do properly use 'my' variables, so that
>> they get deleted when they get out of scope, and for HTML::TreeBuilder
>> trees, I do use delete method to trigger garbage collection. I also
>> 'use strict' to let me know if I am making any scoping mistakes.
>> 
>> I do use one global hash that maps integers to integers, which I
>> estimate to be about 20,000 integers. (not much) I also have a second
>> hash with not much more. 
>> 
>> Despite that, my script grows to large sizes in memory, which screws
>> things up. (600+ MB)
>> 
>> What I would like to know is whether I can trigger some sort of
>> garbage collection that deletes circular structures and everything
>> else that perl can find, besides just doing reference count based
>> deletion. I would then do that periodically, say every 100
>> iterations. 
>
> As Xho said, the best solution would be to find the leak and
> eliminate it.
>
> For a quick-and-dirty solution you could restart the script
> periodically.  It seems that the state you need to keep is
> in one or both of those hashes of integers.  Every so-many
> iterations you could save these to disk and restart
>
>     # save state
>     exec $^X, $0;
>     # restore state
>     # continue
>

Anno, I will use that as a last resort. The script is already
restartable at any time. It keeps its state on disk. Can I clarify
something? If the script is called with command arguments, I need to
call it with

exec $^X, $0, @ORIG_ARGV;

right?

i


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

Date: Wed, 25 Apr 2007 04:42:09 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Apr 25 2007
Message-Id: <JH1EE9.202B@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Blikistan-0.05
http://search.cpan.org/~lukec/Blikistan-0.05/
Create a blog from content in a wiki
----
CGI-SSI-0.90
http://search.cpan.org/~james/CGI-SSI-0.90/
Use SSI from CGI scripts
----
CPAN-Reporter-0.42
http://search.cpan.org/~dagolden/CPAN-Reporter-0.42/
Provides Test::Reporter support for CPAN.pm
----
CPAN-Reporter-0.43
http://search.cpan.org/~dagolden/CPAN-Reporter-0.43/
Provides Test::Reporter support for CPAN.pm
----
Catalyst-Plugin-Log-Handler-0.01
http://search.cpan.org/~pepe/Catalyst-Plugin-Log-Handler-0.01/
Catalyst Plugin for Log::Handler
----
Class-DBI-Audit-0.01
http://search.cpan.org/~bduggan/Class-DBI-Audit-0.01/
Audit changes to columns in CDBI objects.
----
Class-Generate-1.08
http://search.cpan.org/~swartik/Class-Generate-1.08/
Generate Perl class hierarchies
----
Crypt-GpgME-0.01
http://search.cpan.org/~flora/Crypt-GpgME-0.01/
Perl interface to libgpgme
----
DBIx-Class-Indexed-0.02
http://search.cpan.org/~bricas/DBIx-Class-Indexed-0.02/
Index data via external indexing facilities.
----
Device-ScanShare-1.002
http://search.cpan.org/~leocharre/Device-ScanShare-1.002/
manage USERDIRTS.TXT ecopy file to manage scanner device options
----
Dir-Project-3.010
http://search.cpan.org/~wsnyder/Dir-Project-3.010/
Project Environment determination
----
Exception-System-0.03
http://search.cpan.org/~dexter/Exception-System-0.03/
The exception class for system or library calls
----
Games-Sudoku-Component-TkPlayer-0.01
http://search.cpan.org/~ishigaki/Games-Sudoku-Component-TkPlayer-0.01/
Let's play Sudoku
----
Geo-Coder-HostIP
http://search.cpan.org/~dodger/Geo-Coder-HostIP/
----
Geo-Coder-HostIP_0_02
http://search.cpan.org/~dodger/Geo-Coder-HostIP_0_02/
Object-Oriented Retrival of IP based geocoding info
----
GnuPG-Interface-0.35
http://search.cpan.org/~jesse/GnuPG-Interface-0.35/
Perl interface to GnuPG
----
HTML-ListScraper-0.01
http://search.cpan.org/~vbar/HTML-ListScraper-0.01/
generic web page scraping support
----
JSON-Any-1.04
http://search.cpan.org/~cthom/JSON-Any-1.04/
Wrapper Class for the various JSON classes.
----
Lemonldap-Handlers-Generic-3.2.0
http://search.cpan.org/~egerman/Lemonldap-Handlers-Generic-3.2.0/
Perl extension for Lemonldap sso system
----
Log-Handler-0.14
http://search.cpan.org/~bloonix/Log-Handler-0.14/
A simple handler to log messages to log files.
----
Mail-Karmasphere-Client-2.09
http://search.cpan.org/~shevek/Mail-Karmasphere-Client-2.09/
Client for Karmasphere Reputation Server
----
Math-Polynom-0.12
http://search.cpan.org/~erwan/Math-Polynom-0.12/
Operations on polynomials
----
Module-Refresh-0.11
http://search.cpan.org/~jesse/Module-Refresh-0.11/
Refresh %INC files when updated on disk
----
MooseX-Method-0.15
http://search.cpan.org/~berle/MooseX-Method-0.15/
Method declaration with type checking
----
Music-Tag-0.19
http://search.cpan.org/~ealleniii/Music-Tag-0.19/
Module for collecting information about music files.
----
Music-Tag-0.2
http://search.cpan.org/~ealleniii/Music-Tag-0.2/
Module for collecting information about music files.
----
Net-Pavatar-1.00
http://search.cpan.org/~karjala/Net-Pavatar-1.00/
Pavatar client
----
POE-Filter-JSON-0.04
http://search.cpan.org/~xantus/POE-Filter-JSON-0.04/
A POE filter using JSON
----
Pad-Tie-0.001
http://search.cpan.org/~hdp/Pad-Tie-0.001/
tie an object to lexical contexts
----
Pad-Tie-0.002
http://search.cpan.org/~hdp/Pad-Tie-0.002/
tie an object to lexical contexts
----
Pad-Tie-0.002_01
http://search.cpan.org/~hdp/Pad-Tie-0.002_01/
tie an object to lexical contexts
----
Pad-Tie-0.002_02
http://search.cpan.org/~hdp/Pad-Tie-0.002_02/
tie an object to lexical contexts
----
Pad-Tie-0.003
http://search.cpan.org/~hdp/Pad-Tie-0.003/
tie an object to lexical contexts
----
Perl-RPM-1.50
http://search.cpan.org/~rjray/Perl-RPM-1.50/
----
Perl-RPM-1.51
http://search.cpan.org/~rjray/Perl-RPM-1.51/
----
Perl-Repository-APC-1.244
http://search.cpan.org/~andk/Perl-Repository-APC-1.244/
Class modelling "All Perl Changes" repository
----
Perl-Tidy-20070424
http://search.cpan.org/~shancock/Perl-Tidy-20070424/
Parses and beautifies perl source
----
Pod-POM-Web-1.03
http://search.cpan.org/~dami/Pod-POM-Web-1.03/
HTML Perldoc server
----
RRDTool-Creator-0.2
http://search.cpan.org/~jacquelin/RRDTool-Creator-0.2/
Creators for round robin databases (RRD)
----
ShipIt-0.48
http://search.cpan.org/~bradfitz/ShipIt-0.48/
software release tool
----
Sprocket-0.01
http://search.cpan.org/~xantus/Sprocket-0.01/
A pluggable POE based Client / Server Library
----
Template-Plugin-Shorten-0.01
http://search.cpan.org/~kentaro/Template-Plugin-Shorten-0.01/
Template plugin to shorten/lengthen URLs
----
Time-Elapsed-0.11
http://search.cpan.org/~burak/Time-Elapsed-0.11/
Displays the elapsed time as a human readable string.
----
Time-Elapsed-0.12
http://search.cpan.org/~burak/Time-Elapsed-0.12/
Displays the elapsed time as a human readable string.
----
VR-API-1.02
http://search.cpan.org/~nmarden/VR-API-1.02/
Communicate with VerticalResponse's API services
----
WWW-Monitor-0.24
http://search.cpan.org/~yaron/WWW-Monitor-0.24/
Monitor websites for updates and changes
----
load-0.19
http://search.cpan.org/~elizabeth/load-0.19/
control when subroutines will be loaded
----
mogilefs-server-2.10
http://search.cpan.org/~bradfitz/mogilefs-server-2.10/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

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


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

Date: 24 Apr 2007 21:43:08 -0700
From: gaurava@lycos.com
Subject: passing objects to threads
Message-Id: <1177476188.750163.162810@n15g2000prd.googlegroups.com>

Hi,
  I am trying to create a new thread within my script and use a global
object reference within the thread. The global object is initialized
before it is passed to the thread. However the thread doesn't receive
an initialized copy. It gets a copy of the reference. I am doing:

use Thread;

Should I use threads and threads::shared? How do I share object
references?

Thanks,
Gaurav



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

Date: Tue, 24 Apr 2007 22:23:37 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Re-inventing the wheel, same hash, three scripts
Message-Id: <slrnf2tidp.790.tadmc@tadmc30.august.net>

Justin C <justin.0704@purestblue.com> wrote:
> In article <240420071017079484%jgibson@mail.arc.nasa.gov>, Jim Gibson wrote:

>> You can improve this scheme by using 'package', 'my', or 'our' in
>> various combinations (left as an exercise or another poster).
>
> Thanks, that's more to read up on, I know 'my' (learnt that very early!)
> not come across 'package', or 'our' before, so that's going to confuse
> the grey matter... still, I need something to keep me occupied at work.


Then see:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


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


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

Date: 24 Apr 2007 21:36:00 -0700
From: gaurava@lycos.com
Subject: signal HANDLER in perl
Message-Id: <1177475760.274513.64490@u32g2000prd.googlegroups.com>

Hi,
  I am trying to write a program where the main process registers a
SIGNAL handler for SIGCHLD, forks a bunch of processes and then reaps
the dead children. I have some control over when to register the
signal handler (before or after forking the child processes but not a
whole lot). I am seeing some weird behaviour. Basically I see a valid
child exit, handle it, and then start seeing a slew of SIGCHLD signals
from a process with PID 0. I was wondering if someone could tell me
the right way to handle signals, or has seen this problem before and
knows how to fix it. I am copying pseudo code for my script below.

Thanks,
Gaurav


sub handler {
   while(($kid = waitpid(-1, WNOHANG)) != -1) {
      if ($kid == $imp_pid) {
         exit();
      }
   }
}

$imp_pid = fork_important_child();
$SIG{CHLD} = 'handler;

$other_pid = fork_normal_process();
$yet_another_pid = fork_normal_process();
:
:
snip



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

Date: 25 Apr 2007 03:51:59 -0700
From: bpatton <bpatton@ti.com>
Subject: trying to generate integer from string
Message-Id: <1177498319.668285.163740@n15g2000prd.googlegroups.com>

I'm trying to generate a unique integer from a string.  It must
generate the same integer each time it has the same string.  I'm
trying to use unpack to do this.
Here is a small sample.  My real version now has @ 2000 strings, but
his is only going up.
my $s1 = '-Dfull_drc=true -Dgds_file=gds.VIA4T -Dgds_layer=VIA4T -
Dstore_layer=VIA4T';
my $s2 = '-Dfull_drc=true -Dgds_file=gds.VIA1T -Dgds_layer=VIA1T -
Dstore_layer=VIA1T';
my ($u1,$u2);
($u1) = unpack("%J*",$s1);
($u2) = unpack("%J*",$s2);
print "u1 = $u1\n";
print "u2 = $u2\n";

If I change the J to an A this example works ok, but hunderds other
one fail.
I'm checking these by creating a perl hash where the $U# is the key
and the string is the value.
So that I check for the existance of a key, if it exists the I compare
the values. if the are equal then it is an error


Here is my actual code : (less genRppPermutations too large) $s1 and
$s2 are examples from genRppPerrmutations.
my @switchList;
my ($rpp,%hash,$key,$string);
foreach $rpp ( qw ( COMBINE  GEN_STORE  L2G.gatet L2G.met L2G.primary
L2G.umc MASTER_RPP PG_PASS1 PG_PASS2 PG_PASS2.SPLITPOL PG_PASS2.met
PG_PASS3) ) {
  @switchList = genRppPermutations($rpp);
  foreach $string (@switchList) {
    ($key) = unpack("%A*",$string);
    if (exists $hash{$key}) {
      unless ($hash{$key} eq $string) {
        print "collision between strings, both generated '$key'\n";
        print "  s1 : $string\n";
        print "  s2 : $hash{$key}\n";
      }
    } else {
      $hash{$key} = $string;
    }
  }
}



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

Date: Wed, 25 Apr 2007 13:43:01 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: trying to generate integer from string
Message-Id: <f0nf79$9o5$1@mlucom4.urz.uni-halle.de>

bpatton wrote:
> I'm trying to generate a unique integer from a string.  It must
> generate the same integer each time it has the same string.  I'm
> trying to use unpack to do this.
> Here is a small sample.  My real version now has @ 2000 strings, but
> his is only going up.
> my $s1 = '-Dfull_drc=true -Dgds_file=gds.VIA4T -Dgds_layer=VIA4T -
> Dstore_layer=VIA4T';
> my $s2 = '-Dfull_drc=true -Dgds_file=gds.VIA1T -Dgds_layer=VIA1T -
> Dstore_layer=VIA1T';
> my ($u1,$u2);
> ($u1) = unpack("%J*",$s1);
> ($u2) = unpack("%J*",$s2);
> print "u1 = $u1\n";
> print "u2 = $u2\n";
> 
> If I change the J to an A this example works ok, but hunderds other
> one fail.
> I'm checking these by creating a perl hash where the $U# is the key
> and the string is the value.
> So that I check for the existance of a key, if it exists the I compare
> the values. if the are equal then it is an error

Depending on the length of the string, compute a 10-20 byte 'fingerprint'
of them, for example with the md5 or sha1 algorithm. There are modules for
this purpose, you may use one of the Digest:: Modules
(http://search.cpan.org/~gaas/Digest-1.15/Digest.pm), eg. SHA1

> 
> Here is my actual code : (less genRppPermutations too large) $s1 and
> $s2 are examples from genRppPerrmutations.

Example:
==>

use strict;
use warnings;
# print 20 byte number , sha1 (40 byte hex code)
use Digest::SHA1  qw(sha1_hex);

my @strings = qw'
    COMBINE GEN_STORE L2G.gatet L2G.met L2G.primary L2G.umc MASTER_RPP PG_PASS1
    PG_PASS2 PG_PASS2.SPLITPOL PG_PASS2.met PG_PASS3';

my ($rpp, %hash, $key, $string, $collision);

foreach $rpp (@strings) {
    foreach $string ( genRppPermutations($rpp) ) {
       $key = sha1_hex( $string );
       if( exists $hash{$key} ) {
          if( $hash{$key} ne $string ) {
             print "collision" . ++$collision . "between generated '$key'\n";
             print "  s1 : $string\n";
             print "  s2 : $hash{$key}\n"
          }
       }
       else {
          $hash{$key} = $string;
          print "$key, "
       }
    }
}
print "all ok!\n" unless $collision;

<==

Regards

M.


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

Date: 25 Apr 2007 12:13:35 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: trying to generate integer from string
Message-Id: <598uvfF2k021sU1@mid.dfncis.de>

bpatton  <bpatton@ti.com> wrote in comp.lang.perl.misc:
> I'm trying to generate a unique integer from a string.  It must
> generate the same integer each time it has the same string.  I'm
> trying to use unpack to do this.
> Here is a small sample.  My real version now has @ 2000 strings, but
> his is only going up.

But two thousand is nothing.  Just use the strings as hash keys.

If it were two millions or more, using a digest could be meaningful.
If so, use a module that generates a tried-and-(mathematically-)proven 
digest instead of am ad-hoc solution.

Anno


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

Date: Wed, 25 Apr 2007 13:52:59 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: trying to generate integer from string
Message-Id: <f0nh92$a9e$1@mlucom4.urz.uni-halle.de>

Mirco Wahab wrote:
> Depending on the length of the string, compute a 10-20 byte 'fingerprint'
> of them, for example with the md5 or sha1 algorithm. There are modules for
> this purpose, you may use one of the Digest:: Modules
> (http://search.cpan.org/~gaas/Digest-1.15/Digest.pm), eg. SHA1

If you need "normal integers (4 byte)" as keys,
you'd look at the CRC32 algorithm, where a
module is also available. The following would
use "regular" integers as keys:
(only modified parts shown)
==>
    ...
    use Digest::CRC qw'crc32';
    ...

    ...
       foreach $string ( genRppPermutations($rpp) ) {
          my $key = crc32($string);
          if( exists $hash{$key} ) {
             if( $hash{$key} ne $string ) {
                print "collision " . ++$collision . " between generated '$key'\n";
                print "  s1 : $string\n  s2 : $hash{$key}\n";
             }
          }
          else {
             $hash{$key} = $string;
             printf "0x%08X, ", $key
          }
       }
    ...


<==

Regards

M.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

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

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 378
**************************************


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