[18388] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 556 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 23 18:05:52 2001

Date: Fri, 23 Mar 2001 15:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985388718-v10-i556@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 23 Mar 2001     Volume: 10 Number: 556

Today's topics:
    Re: Can perl handle 'fields' like awk can? (e)
    Re: Can perl handle 'fields' like awk can? (Jon Bell)
    Re: Can perl handle 'fields' like awk can? <thomastk@prodigy.net>
    Re: Creating array context <philipp@phemker.de>
    Re: Docs didn't help - problem setting locale under Win <thoren@southern-division.com>
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
    Re: every 15 seconds <iltzu@sci.invalid>
    Re: every 15 seconds <bigrich318@yahoo.com>
    Re: every 15 seconds (Randal L. Schwartz)
    Re: Hmmm... Which PERL Book Is Best Suited For This??? <jboes@qtm.net>
    Re: How can I read a file backwards? <djberge@uswest.com>
    Re: How can I read a file backwards? <lmoran@wtsg.com>
    Re: How can I read a file backwards? <callgirl@la.znet.com>
    Re: How can I read a file backwards? <uri@sysarch.com>
        how to close() on filehandle without wait()ing? <dbohling@newsfactor.com>
        Malformed UTF-8 character <thomastk@prodigy.net>
    Re: Need help with script as I suck at perl. (Michel Dalle)
    Re: Newbie question <djberge@uswest.com>
    Re: Newbie question <thomastk@prodigy.net>
        Output replication inside of DESTROY <david@freemm.org>
    Re: PERL <thomastk@prodigy.net>
    Re: PERL <uri@sysarch.com>
    Re: PERL <djmarcus@ex-pressnet.com>
    Re: PLEASE HELP (0/1) <uri@sysarch.com>
        Problem using Archive::Zip <tfbiv@SPAMMENOTerols.com>
    Re: Read and write a hash of arrays ? <bigrich318@yahoo.com>
    Re: regexp with // in the input string <thomastk@prodigy.net>
        safe IPC under Windows <usenet@hank.org>
    Re: Shared memory problem <sruyle@quik.com>
        SIGHUP for restarting perl daemon <N_O_S_P_A_M_syn_uw@hotmail.com>
    Re: Still can't die with Tar (BUCK NAKED1)
    Re: using closures (road to OO) <iltzu@sci.invalid>
        Using LWP, HTTP::Cookies etc in multi-threading in Wind <djmarcus@ex-pressnet.com>
        Wild Card Problem! <clinton.munden@alcatel.com>
        Wild Card Search!! <clinton.munden@alcatel.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 Mar 2001 19:26:18 GMT
From: sendthis@yahoo.delthisandasdf.com (e)
Subject: Re: Can perl handle 'fields' like awk can?
Message-Id: <5C206010769BFDA9.43FAEBB4EBD580C0.686ED4A62B0EAB6C@lp.airnews.net>

That didn't work. I assumed I replaced $F with $<var> but I tried it both ways 
just in case.

This is what I'm trying to do... (not exactly.)

#!/bin/perl

open (FILE,"results.xls");
@array = <FILE>;
close (FILE);

foreach $line (@array)
{

print $line; # this works and prints contents of line
print $line [6]; # this returns no value
print $line [5]; # I tried this and the following to make sure
print $line [4]; # it did not count <tab> as a field.


}


Thanks,
E

In article <slrn9bn40d.h9i.abigail@tsathoggua.rlyeh.net>, abigail@foad.org 
says...
>
>e (sendthis@yahoo.delthisandasdf.com) wrote on MMDCCLXI September
>MCMXCIII in 
<URL:news:AB908D5F12924C82.8EB88DD09177740B.ED3AA4EA29F2BC31@lp.airnews.net>:
>%% I'm not very familiar with PERL, I have a book opened, but it doesn't seem 
to
>%% tell how to manipulate data separated by delimiters or i'm not using the 
righ
>%% keywords to look it up. 
>
>split
>
>%% I want to access the 7th field, data after the 6th <tab>. I'm trying to 
write
>%% all my scripts in PERL to handle my data at work since it's more flexible.
>%% 
>%% 
>%% I want the equivalent of 
>%% 
>%% awk { print $7 } 
>%% 
>%% Is there an easy way to do this in perl?
>
>
>perl -nawle 'print $F [6]'
>
>
>
>Abigail
>-- 
>:$:=~s:$":Just$&another$&:;$:=~s:
>:Perl$"Hacker$&:;chop$:;print$:#:



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

Date: Fri, 23 Mar 2001 20:24:13 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Can perl handle 'fields' like awk can?
Message-Id: <GAo3CD.GJn@presby.edu>

In article <5C206010769BFDA9.43FAEBB4EBD580C0.686ED4A62B0EAB6C@lp.airnews.net>,
e <sendthis@yahoo.delthisandasdf.com> wrote:
>
>This is what I'm trying to do... (not exactly.)
>
>#!/bin/perl
>
>open (FILE,"results.xls");
>@array = <FILE>;
>close (FILE);
>
>foreach $line (@array)
>{
>
>print $line; # this works and prints contents of line
>print $line [6]; # this returns no value

Indeed, it shouldn't.  $line is not an array, it's a scalar that contains 
a string.  You need to "split" the string into its component fields, 
according to whatever separator you're using.  Assuming you're using '\t' 
(tab) as the separator, you can construct an array of all the fields 
(minus the separators) as follows:

   @fields = split (/\t/, $Line);

Then $fields[6] will give you the seventh field.  If you don't need the 
other fields, just the seventh one:

   $whatever = (split (/\t/, $Line))[6];

You can also extract multiple fields this way:

   ($firstname, $lastname, $whatever) = (split (/\t/, $Line))[0,1,6];

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA


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

Date: Wed, 21 Mar 2001 14:08:08 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Can perl handle 'fields' like awk can?
Message-Id: <99ghdn$3c1q$1@newssvr06-en0.news.prodigy.com>

you can do something like the following:

if the source string is copied to $_ ..

/(?:.*?\t){6}(.*?)\t/;
print $1;

e <sendthis@yahoo.delthisandasdf.com> wrote in message
news:AB908D5F12924C82.8EB88DD09177740B.ED3AA4EA29F2BC31@lp.airnews.net...
> I'm not very familiar with PERL, I have a book opened, but it doesn't seem
to
> tell how to manipulate data separated by delimiters or i'm not using the
right
> keywords to look it up.
>
> I want to access the 7th field, data after the 6th <tab>. I'm trying to
write
> all my scripts in PERL to handle my data at work since it's more flexible.
>
>
> I want the equivalent of
>
> awk { print $7 }
>
> Is there an easy way to do this in perl?
>
> Thanks,
> E
>




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

Date: Fri, 23 Mar 2001 21:38:07 GMT
From: Philipp Hemker <philipp@phemker.de>
Subject: Re: Creating array context
Message-Id: <m2r8zop3nk.fsf@phemker.de>

Bjoern Hoehrmann <bjoern@hoehrmann.de> writes:

> >`'   @{[ <array context> ]}

> I thought of something like
> 
>   my $B = scalar @{[$user =~ m|[$comp]|g]} # [1] [2]

my $B = grep 1, $user =~ m|[$comp]|g;


btw, you're cheating ;)

bis dann, 
  philipp

-- 


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

Date: Fri, 23 Mar 2001 21:53:27 +0100
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: Docs didn't help - problem setting locale under WinNT
Message-Id: <MPG.1525d636a68cefd5989967@news.t-online.de>

In article <3ABB88D5.B1CE6713@engelschall.com>, Steffen Beyer aka 
sb@engelschall.com says...

> Has anybody *SUCCESSFULLY* changed the locale under WinNT,
> so that "use locale" does the right thing when comparing strings?
> 
> How did you do it?

use POSIX qw(locale_h);
setlocale(LC_ALL, "de");
use locale;

 ...wenn ich die frage richtig verstanden habe.

> But even when I try to set these environment variables, the system pays
> absolutely no
> heed to them.

hmmm... control-panel -> regional-settings?

-- 
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
END{tie$@=>X=>and$@=42=>print"$@8#X"}eval(reverse(q?}esrever{HCTEF::A bus
;>=101010>>42;}"JAPHn\"=_${EROTS::A bus}'A'>=@$\sselb{RALACSEIT::X bus?))


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

Date: 23 Mar 2001 22:37:17 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_985386844@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Windows
            http://www.gnu.org/software/emacs/windows/ntemacs.html
	    ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

	o   More Emacs resources at 
	    http://tiny-tools.sourceforge.net/emacs-elisp.html


Emacs Perl Modules

    Cperl -- Perl programming mode

        .ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
        .<olson@mcs.anl.gov>           Bob Olson (started 1991)
        .<ilya@math.ohio-state.edu>    Ilya Zakharevich

        Major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

	.http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Grep through all Perl manpages (.pod)
        o   Follow POD manpage references to next pod page with TinyUrl
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.
        o   TinyUrl is used to jump to URLs (other pod pages, man pages etc)
            mentioned in POD pages. (It's a general URL minor mode)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in the Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up datatbases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to run the find for you, You can adjust
        recursive grep options, ignored case, add user grep options.

        You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
	Check also ftp://ftp.ihs.com/pub/kevinr/

    TinyCompile -- Browsing grep results in Emacs *compile* buffer

        TinyCompile is minor mode for *compile* buffer from where
        you can collapse unwanted lines, shorten the file URLs

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->
            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: 23 Mar 2001 19:47:59 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: every 15 seconds
Message-Id: <985375973.29865@itz.pp.sci.fi>

In article <o5tmbtke9bclmclnue5rs25aj12cg0bv0d@4ax.com>, Tom Scheper wrote:
>>
>>while(1){
>>   print "Hello World!\n";
>>   sleep(15);
>
>Ahh.. But what if print "Hello World!" is replaced with something that
>takes several seconds to complete, but at other times just
>miliseconds?

  use Time::HiRes qw/time sleep/;  # works without, but not as well

  my $T = time();
  while (1) {
      $T += 15;
      print "Hello World!\n";
      sleep($T - time()) if $T > time();
  }

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Fri, 23 Mar 2001 14:26:57 -0600
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: every 15 seconds
Message-Id: <tbnc5ftog8eob4@corp.supernews.com>


"Tom Scheper" <tom@power.net.uk> wrote in message
news:o5tmbtke9bclmclnue5rs25aj12cg0bv0d@4ax.com...
> On Fri, 23 Mar 2001 09:40:11 -0600, Daniel Berger <djberge@uswest.com>
> shed a beam of light on us:
>
> >Bjoern Kaiser wrote:
> >
> >> how do i output something every 15 seconds?
> >
> >while(1){
> >   print "Hello World!\n";
> >   sleep(15);
>
> Ahh.. But what if print "Hello World!" is replaced with something that
> takes several seconds to complete, but at other times just
> miliseconds?
>
> -=Cornelis

use strict;

for (1..4){
my $before = time;
my $output = &delayed_output;
my $after = time;
sleep(15-int($after-$before));
print $output.' / Displayed-'.scalar(localtime())."\n";
}

sub delayed_output {
#delay up to 10 seconds
my $delay = int(rand(11));
sleep($delay);
return "Delayed ".$delay." seconds-".scalar(localtime());
}




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

Date: 23 Mar 2001 14:53:27 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: every 15 seconds
Message-Id: <m1y9twumfs.fsf@halfdome.holdit.com>

>>>>> "Rich" == Rich  <bigrich318@yahoo.com> writes:

Rich> use strict;

Rich> for (1..4){
Rich> my $before = time;
Rich> my $output = &delayed_output;
Rich> my $after = time;
Rich> sleep(15-int($after-$before));
Rich> print $output.' / Displayed-'.scalar(localtime())."\n";
Rich> }

Rich> sub delayed_output {
Rich> #delay up to 10 seconds
Rich> my $delay = int(rand(11));
Rich> sleep($delay);
Rich> return "Delayed ".$delay." seconds-".scalar(localtime());
Rich> }

This would be simpler, and sleeps until the even multiples of 15 seconds:

    while (1) {
      sleep 15 - time % 15;
      ... do task here ...
    }

-- 
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: Fri, 23 Mar 2001 16:53:41 -0500
From: Jeff Boes <jboes@qtm.net>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <aehnbt8pbpr3mb78aqed7h83jkeqeph74l@4ax.com>

At some point in time, bogus@erol.com (---Pete---) wrote:

>I'm looking for a reference book that is instructional as well
>as extensively indexed such that I can pickup a sample
>Perl script and quiclky find topics or functions like sysread(),
>or  even simple things like "$!" that I find in the sample Perl
>code. This PERL book should also written with the CGI in
>mind.

You can find a very extensive list at:

http://www.perl.com/reference/query.cgi?section=books&x=13&y=14


--
~~~~~~~~~~~~~~~~|It is by caffeine alone I set my mind in motion, 
Jeffery Boes    |It is by the beans of Java that thoughts acquire speed, 
jboes@qtm.net   |The hands acquire shaking, the shaking becomes a warning, 
UIN 3394914     |It is by caffeine alone I set my mind in motion. 


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

Date: Fri, 23 Mar 2001 13:10:16 -0600
From: Daniel Berger <djberge@uswest.com>
Subject: Re: How can I read a file backwards?
Message-Id: <3ABB9F98.A7D73EA9@uswest.com>

Daniel Berger wrote:

> ...a line at a time, without putting the entire file into memory?  Is this
> possible?
>
> I've checked the Cookbook (which suggests that it's *not* possible), this
> newsgroup, and the various faq's but have found nothing.  Anyone have any ideas
> or suggestions?  Thanks in advance.
>
> Regards,
>
> Dan
>
> --
> "Evil will always triumph because Good is *dumb*"
>
> - Dark Helmet, Spaceballs

Hmmm...my eyes must have glazed over File-Readbackwards the first time around
searching.  Never mind. :)

Dan

--
"Evil will always triumph because Good is *dumb*"

- Dark Helmet, Spaceballs





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

Date: Fri, 23 Mar 2001 16:19:49 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: How can I read a file backwards?
Message-Id: <aefnbtgo9n7715b60tbru160huur48cnip@4ax.com>

On Fri, 23 Mar 2001 13:10:16 -0600, Daniel Berger <djberge@uswest.com>
wrote wonderful things about sparkplugs:

>Daniel Berger wrote:
>
>> ...a line at a time, without putting the entire file into memory?  Is this
>> possible?
>>
>> I've checked the Cookbook (which suggests that it's *not* possible), this
>> newsgroup, and the various faq's but have found nothing.  Anyone have any ideas
>> or suggestions?  Thanks in advance.
>>
>> Regards,
>>
>> Dan
>>

>
>Hmmm...my eyes must have glazed over File-Readbackwards the first time around
>searching.  Never mind. :)
>
>Dan

Damn!  Now my witty

use Mirror;

is out the window.... ;)

--
print "\x{263a}" 


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

Date: Fri, 23 Mar 2001 14:11:01 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: How can I read a file backwards?
Message-Id: <3ABBC9F5.D27F1F29@la.znet.com>

Daniel Berger wrote:
 
> ...a line at a time, without putting the entire file into memory?
> Is this possible?

This is possible but rather complex and highly inefficient,
for most circumstances but not all.

Use of a backwards stepping seek and read is a possibility
but usually not worthwhile with so much programming and memory
required to accomplish this. I do have a rather nice chat
which employs backwards seek and read, but only to a very
limited degree and it relies on a dynamic database specifically
formatted for backwards reading. It is efficient for my
circumstances but I would not suggest this for large reads.
I should add, my chat doesn't read line-by-line; it moves
backwards by paragraph numbers then reads forward. However,
this principle would work for line-by-line but does involve
rather complex mathematics.
 
> I've checked the Cookbook (which suggests that it's *not* possible),
> this newsgroup, and the various faq's but have found nothing.
>  Anyone have any ideas or suggestions?  Thanks in advance.

There is an exceptionally efficient way to handle this although
it requires one instance of inefficiency and a sacrifice of
some disk space.

Create a duplicate of your file, backwards. Otherwords, two files
are available, one forward, one backwards. Your program then makes
a decision which to use.

I use this method extensively for Natural Language Emulation,
to run both tree branching and root branching, as needed for
specific circumstances. When one of my numerous data files
is updated, modified in some way, a special program runs
which reads in the entire file, as a slurped array. This
array is reversed and a 'backwards' file is created. This
is the single instance of inefficiency; using slurp.

I have found having two versions of a file with which to work,
is more efficient than programming to read a file backwards,
significantly more efficient, with larger backwards reads.
Tradeoff in this case, is greater efficiency gained by a 
sacrifice of disk space. This doubled use of disk space is
an equitable exchange with most of my files being under
one-hundred kilobytes, averaging about fifty kilobytes.

Godzilla!


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

Date: Fri, 23 Mar 2001 22:24:22 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How can I read a file backwards?
Message-Id: <x7r8zo15ux.fsf@home.sysarch.com>

>>>>> "DB" == Daniel Berger <djberge@uswest.com> writes:

  DB> ...a line at a time, without putting the entire file into memory?
  DB> Is this possible?

  DB> I've checked the Cookbook (which suggests that it's *not*
  DB> possible), this newsgroup, and the various faq's but have found
  DB> nothing.  Anyone have any ideas or suggestions?  Thanks in
  DB> advance.

gawd, the att/roadrunner news feed is really sucking today (what else is
new?). this post was dated at Date: Fri, 23 Mar 2001 12:13:14 -0600 or
about 6 hours ago.

i have already gotten and sent email to dan about File::ReadBackwards
which is seems to need.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 23 Mar 2001 16:58:11 -0500
From: Daniel <dbohling@newsfactor.com>
Subject: how to close() on filehandle without wait()ing?
Message-Id: <3ABBC6F3.1010802@newsfactor.com>

Hi all.

Is there a way to use the perl's open() call to open a pipe to a 
process, print to it, and let it run without waiting for it to finish?
I dont care about the return status or anything the child does after it 
receives the message.

sub send_many_simultaneous {
	my $not_spam = 1;
	my $newsletter = 1;
	my $qmail_inject = "To much disk i/o";
	my $qmail_remote = "Send and forget";
	for ( my $i = 0; $i < 10; $i++) {
		&deliver($i);
	}
}

sub deliver {
	my $i = shift;
	my $mailhndl = 'MAIL';
	my @mailprog = (
	"/var/qmail/bin/qmail-remote",
	"server.com",
	"me\@me.com",
	"address\@server.com"
	);
	my $mailprog = join " ", @mailprog;
	print "Running $mailprog\n";	
	open MAIL, "|-" or  exec @mailprog;
		
	
	
	select $mailhndl;
	$| = 1;
	
print qq~To: address\@server.com
From: me\@me.com
Subject: TEST
Content-Type: text/plain;

test $i
~;

	select STDOUT;
}




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

Date: Wed, 21 Mar 2001 13:47:43 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Malformed UTF-8 character
Message-Id: <99gg7h$3cfk$1@newssvr06-en0.news.prodigy.com>

Hi,

In a transliteration routine that converts Latin 1 chars to UTF-8 chars, I
get the following warning:

Malformed UTF-8 character at ekautil.pm line 86.
The referred line is: $str =~ tr/\0-\xFF//CU;

I think, this worked without any warning on an NT machine where I developed
the script, but error warning shows up on a Solaris box where the script is
installed.

I don't understand the meaning of this warning. Could somebody please help
me to decipher it?

Thanks in advance
Thomas.




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

Date: Fri, 23 Mar 2001 19:05:15 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Need help with script as I suck at perl.
Message-Id: <99g6sn$66v$1@news.mch.sbs.de>

In article <3abb5cf6.6659025@ns1.nothingbutnet.net>, java2e@yahoo.com (Kev.-) wrote:

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

# we'll need this
use PSI::ESP qw(:full :gigo);

>>> I am suppose to call this link:
>>> http://www.abc.com/xxx.cgi?link=Dude/1/test&seed=41FLZ9FJJ

# hmmm, sounds easy...
use LWP::Simple;
my $content = 
get('http://www.abc.com/xxx.cgi?link=Dude/1/test&seed=41FLZ9FJJ');

>>> which return this:
>>> http://www.xzy.com/default.asp?seed=41FLZ9FJJ &pop=12&receipt=12

# err, what ?
use Random::Code;
my($pop) = $content =~ /&pop=(\d+)/;

>>> Then I am suppose to pass the pop to a function called valid.

# no problem - but what is valid ?
valid($pop);

>>> How heck to I do this??
>>> I am suppose to recall the abc.com link but I cant figure it out.

# aha, we've seen this before, haven't we ?
$content =
get('http://www.abc.com/xxx.cgi?link=Dude/1/test&seed=41FLZ9FJJ');

# now what ?
exit;

Somehow, I don't think this solves your problem...
Can you clarify your problem a little bit more ?

Michel.


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

Date: Fri, 23 Mar 2001 14:03:18 -0600
From: Daniel Berger <djberge@uswest.com>
Subject: Re: Newbie question
Message-Id: <3ABBAC06.5B2F5228@uswest.com>

John Michael wrote:

> It is a hash assignment.
> hash are for storing name=value pairs
>
> Look at the second line in the list @words.  [0] would be the first line.
> If the second line in @words is:  someword
> then
> $key{'someword'} is now equal to "YES"
>
> If you did:
> print "$key{'someword'}";
> you would get the answer YES
>

Isn't he technically assigning a range instead of an element?

i.e. $key{@words[1]} = "someword"

instead of...

$key{$words[1]} = "someword"

My guess is that he wants the latter approach.  Or do I have this wrong?

Dan


--
"Evil will always triumph because Good is *dumb*"

- Dark Helmet, Spaceballs





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

Date: Wed, 21 Mar 2001 14:19:45 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Newbie question
Message-Id: <99gi3i$481k$1@newssvr06-en0.news.prodigy.com>

$hash{$key} gives the value stored in hash %hash that corresponds to $key.
And the assignment is also done same way.

So, in your script, the a hash value is set to 'YES', for a key that is
stored in @words.

But this info must be there in any basic book/doc on Perl !!!

Howard Miller <howard.miller@marketingms.com> wrote in message
news:3ABBF548.957FA918@marketingms.com...
> Hi,
>
> I am new to Perl and trying to maintain some (undocumented) software
> somebody else wrote. There is some syntax that I just don't understand,
> and can't find in my books or in the online docs.
>
>    $key{@words[1]} = "YES";
>
> @words is an array full of strings and $key is new here.
>
> I would be really pleased if somebody would tell me what this does.
>
> Thanks
>
> Howard
>




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

Date: Fri, 23 Mar 2001 21:39:59 GMT
From: "David M. Lloyd" <david@freemm.org>
Subject: Output replication inside of DESTROY
Message-Id: <Pine.LNX.4.21.0103231532260.18529-100000@homebody.freemm.org>

I have created a class that implements DESTROY to do a simple
leak-detection thingy... it goes something like this:


package BaseClass;

sub new {

	my ($class) = @_;

	our %cnt;

	$cnt{$class} ++;

	print "$class created, $cnt{$class} hanging around\n";

	#... other stuff ...

}

sub DESTROY {

	my ($self) = @_;

	our %cnt;

	my $class = ref($self);

	$cnt{$class} --;

	print "$class destroyed, $cnt{$class} hanging around\n";

}


But when I run it, the 'print' in the DESTROY function is replicated
several times.  I know it's not calling the destructor multiple times
because $cnt{$class} maintains a count above zero, but I get about 6
prints in the DESTROY to every print in the new().

I thought it was a flushing issue, so I tried syswrite(STDOUT,
 ...) instead but the effect was the same.

What is going on here?

- D

<david@freemm.org>



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

Date: Wed, 21 Mar 2001 14:21:22 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: PERL
Message-Id: <99gi6k$730a$1@newssvr06-en0.news.prodigy.com>

http://www.perlshop.org/

Vontel Girish <girish66@yahoo.com> wrote in message
news:99erk0$heu$1@kraken.itc.gu.edu.au...
> I am creating a shopping cart in Perl Language. Can any one tell me if any
> code is available on the net????
>
>




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

Date: Fri, 23 Mar 2001 22:36:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: PERL
Message-Id: <x7ofus15a1.fsf@home.sysarch.com>

>>>>> "LM" == Lou Moran <lmoran@wtsg.com> writes:

  LM> On Fri, 23 Mar 2001 16:50:26 GMT, Uri Guttman <uri@sysarch.com> wrote
  LM> wonderful things about sparkplugs:

  >>>>>>> "DJM" == David J Marcus <djmarcus@ex-pressnet.com> writes:

  DJM> Now that we've gotten that out of the way... how about a useful
  DJM> answer?
  >> 
  >> then why don't you provide it. tell the KLB how to find his code or
  >> write it for him and let him use it.

  LM> KLB?  Draws a 404 on the Jargon File.

from irc: known lazy bastard. notice how marcus has not posted any
useful help either?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 23 Mar 2001 18:02:45 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Re: PERL
Message-Id: <tbnlg64637g45d@corp.supernews.com>

'Marcus' would post something, except Marcus is a newbie to Perl and knows
better. The one time I posted a response, Perl gurus quickly responded with
far superior answers. This confirms in my mind that the proper protocol is
to:
    - listen
    - learn
    - contribute

I am in the listen/learn mode until I get more Perl-ized. Currently I'm
still thinking in C++/Java/VB mode.

My response was really to politely chastise the original responder for being
so flippant about his 'response'... it is a waste of time to read through
such messages. I suspect he was the type of person that when asked if he
knows what time it is, would answer 'yes'.... a perfectly correct answer but
totally useless.

btw: I much prefer to be referred to as David... saying 'Marcus' without the
'Mr.' is rude.

-David

"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7ofus15a1.fsf@home.sysarch.com...
> >>>>> "LM" == Lou Moran <lmoran@wtsg.com> writes:
>
>   LM> On Fri, 23 Mar 2001 16:50:26 GMT, Uri Guttman <uri@sysarch.com>
wrote
>   LM> wonderful things about sparkplugs:
>
>   >>>>>>> "DJM" == David J Marcus <djmarcus@ex-pressnet.com> writes:
>
>   DJM> Now that we've gotten that out of the way... how about a useful
>   DJM> answer?
>   >>
>   >> then why don't you provide it. tell the KLB how to find his code or
>   >> write it for him and let him use it.
>
>   LM> KLB?  Draws a 404 on the Jargon File.
>
> from irc: known lazy bastard. notice how marcus has not posted any
> useful help either?
>
> uri
>
> --
> Uri Guttman  ---------  uri@sysarch.com  ----------
http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
Consulting
> The Perl Books Page  -----------
http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net  ----------
http://www.northernlight.com




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

Date: Fri, 23 Mar 2001 22:21:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: PLEASE HELP (0/1)
Message-Id: <x7wv9g160f.fsf@home.sysarch.com>

>>>>> "MJ" == Michael Jenneson <michael1981@btinternet.com> writes:

  MJ> I have to get this program working
  MJ> it is supposed to read in any number of unix commands
  MJ> and pipe them together and execute each command in
  MJ> separate processes.
  MJ> i cant get it to run
  MJ> PLEASE HELP

please post your code in plain text. no one here wants to decode it just
to help you. and don't beg, it is very demeaning to you. instead offer
bushels of shekels and talents of gold to attract the help you want.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 23 Mar 2001 14:38:37 -0500
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: Problem using Archive::Zip
Message-Id: <re8nbtgleg8gk7fhlletn4rk3c0iuc9350@4ax.com>

The unzip logic in Archive::Zip doesn't work in my environment.

When I create a zip file using addFile and writeToFileNamed, I can
unzip the files with WinZip or WinRAR and the files compare. But if I
unzip with the library's extractMember function, the files
consistently are about 2% short.

Anybody have any idea what's going on here?

TIA
Tom


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

Date: Fri, 23 Mar 2001 13:25:09 -0600
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: Read and write a hash of arrays ?
Message-Id: <tbn8mcc2ge0na9@corp.supernews.com>


<u665313720@spawnkill.ip-mobilphone.net> wrote in message news:l.985361665.1477722167@botsun1.unizh.ch...
> Hi,
<snip>

use strict;

my %enzymes_hash;
my $keyword;

while (<DATA>) {
if (/^(\w+)::$/) { $keyword = $1; next;};
my ($clone, $best_hit_id, $e_value, $percent_ident, $aln_length, $species, $desc) =
(/^(\w+)\s+(\w+)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?\s+.*?)\s+(.*)/);
push(@{$enzymes_hash{$best_hit_id}}, join(" ", ($e_value, $clone, $best_hit_id, $percent_ident, $aln_length, $species, $desc)));
}

# print hash of arrays
print "Keyword is $keyword\n\n";
foreach my $key (sort keys %enzymes_hash) {
print "Contents of ${key}:\n";
foreach (sort @{$enzymes_hash{$key}}) {
print;
print "\n";
}
print "\n";
}
__DATA__
ACYLASE::
HVSMEb0011A11f  ACY1_PIG    1.10e-06   38,32%  107  Sus scrofa             AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
HVSMEb0011A21f  ACY1_PIG    9.40e-35   51,15%  217  Sus scrofa             AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
HVSMEb0014B21f  FABD_BACSU  2.00e-12   47,14%  140  Bacillus subtilis      MALONYL COA-ACYL CARRIER PROTEIN TRANSACYLASE (EC
HVSMEc0009D01f  ACY1_HUMAN  2.60e-24   52,07%  169  Homo sapiens           AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
HVSMEf0010D05f  ACY1_HUMAN  1.70e-14   52,38%   84  Homo sapiens           AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
HVSMEf0023M23f  FABD_BACSU  4.00e-13   38,38%   99  Bacillus subtilis      MALONYL COA-ACYL CARRIER PROTEIN TRANSACYLASE (EC
HVSMEg0013L23f  ACY1_PIG    1.20e-23   51.46%  171  Sus scrofa             AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-
HVSMEk0024P21f  FABD_BACSU  6.60e-29   39,50%  200  Bacillus subtilis      MALONYL COA-ACYL CARRIER PROTEIN TRANSACYLASE (EC





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

Date: Wed, 21 Mar 2001 14:32:05 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: regexp with // in the input string
Message-Id: <99giqk$6hl2$1@newssvr06-en0.news.prodigy.com>

Remove ? from regexp and make it greedy, then it will work.
m/i18n\(\"(.*)\"/;
but this will return http://blaat

Thomas <zander@xs3.xs4all.nl> wrote in message
news:99f3n1$9um$1@news1.xs4all.nl...
> Hi,
>
> I have a regexp to find strings in a C-source file;
>     m/i18n\(\"(.*?)\"/;
>     $theString .= $1;
>
> This maches fine, and all i18n("blaat") are found,
> except when the text between the quotes contains a double slash.
> The
>   i18n("http://blaat")
> did not mach; any idea how to mach this anyway?
>
> Using perl, version 5.005_03 built for i586-linux
>
> Thanx!




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

Date: Fri, 23 Mar 2001 13:32:13 -0800
From: Bill Moseley <usenet@hank.org>
Subject: safe IPC under Windows
Message-Id: <MPG.152560b7c030efa9897d6@news.newsguy.com>

[This is a repost of a question on comp.infosystems.www.authoring.cgi -- 
nobody responded which is either scary or expected -- I'm not sure 
which]

Under unix when I need to run an external program from a perl CGI script 
I use perldoc perlipc's "Safe Pipe Opens" method to avoid passing any 
data through the shell.

Can someone familiar with Windows comment on ways to run external 
programs from a CGI script in a safe way?  I'm not asking about 
untainting my data, rather passing parameters to a program without 
passing through the shell.

I'm aware of fork under the current ActiveState version of perl, and the 
example they provide to emulate a -| open.  But I'm looking more for a 
general overview of different ways to run programs under Windows and 
under different versions of perl that do and don't support fork, and the 
security issues with different methods (and please no "Windows: unsafe 
at any speed" comments ;).

I'm also interested in differences running Win98 vs. NT/2000.

RTFM pointers always welcome...


-- 
Bill Moseley


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

Date: Fri, 23 Mar 2001 21:33:24 GMT
From: sruyle <sruyle@quik.com>
Subject: Re: Shared memory problem
Message-Id: <3ABBEA9E.C7323784@quik.com>

sruyle wrote:

> I have a problem trying to read a shared memory segment created in a C
> program.
> I can access it correctly in another C program.
> In perl, however, It seems that i can correct to the correct segment,
> but
> cant read the data from it.
> shmget attaches to the right segment, but shmread only returns nulls,
> any idea?
> the shared segment only contains a short int.
> here is the perl code.
> #!/usr/bin/perl
>
> use IPC::SysV qw(IPC_CREAT IPC_RMID S_IRUSR S_IRGRP S_IROTH);
>
>     $SHM_ID =$ENV{CPU_LOAD_AVG_SHM_ID};
>     if ( ! $SHM_ID )
>         {
>            print STDERR "ERROR: Environment not configured\n";
>            print STDERR "CPU_LOAD_AVG_SHM_ID must be set\n";
>            exit;
>          }
>     print "SHM_ID is $SHM_ID\n";
>     $size = 2;
>     $key = shmget($SHM_ID, $size, IPC_CREAT | S_IRUSR | S_IRGRP |
> S_IROTH ) || die "$!";
>     shmread($key, $buff, 0, 2) || die "$!";
>     print "shm key $key\n";
>     print "read  buff: '$buff'\n";
>     printf " value = %4.4x\n", $buff;
>     $foo = unpack('s*', $buff);
>     print "read foo: '$foo'\n";
>
> #    print "deleting shm $key\n";
> #    shmctl($key, IPC_RMID, 0) || die "$!";
>
> thanks in advance for any answers.
> steve

fixed:
dont know why.
I changed the C program that creates and writes to the segment to write a
sting instead of a short
and it works...

steve




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

Date: Fri, 23 Mar 2001 22:33:24 +0100
From: Marc Bigler <N_O_S_P_A_M_syn_uw@hotmail.com>
Subject: SIGHUP for restarting perl daemon
Message-Id: <3ABBC124.1DBC47C1@hotmail.com>

Hello,

I would like to use the signal HUP to restart a perl base daemon. The
problem that I am getting is the following: the first kill -HUP on the
perl process will work perfectly, restarting my perl daemon, great! But
if then I do again a kill -HUP to restart it again then no reactions
from my daemon, it still works but it just seems that it doesn't want to
process anymore my HUP.

Here is the code I use to do that:

$SIG{HUP} = \&reinitialize;

sub reinitialize {

 print "HUP signal received, reinitializing server...\n";
 print "DEBUG: Closing server socket\n";
 close(SERVER_SOCKET) or warn "Can't close listen socket: $!\n";

 print "Killing childrens if any...\n";
 kill_childrens();

 unlink PID_FILE;
 chdir("/tmp");
 sleep 1;
 exec(SELF) or die("ERROR: Couln't restart");

}

That's all basically, so when I receive a HUP i restart my perl daemon
using exec(). SELF as a constant like this:

use constant SELF => '/tmp/my_perl_daemon.pl';

Anyone has an idea why this reaction ?

Thanks for the help

Regards,
Marc






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

Date: Fri, 23 Mar 2001 14:05:04 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Still can't die with Tar
Message-Id: <16877-3ABBAC70-203@storefull-247.iap.bryant.webtv.net>

 
Re: Still can't die with Tar   
 
> Benjamin Goldberg wrote: 
> > BuckNaked wrote:
> > system("gunzip success.tar.gz"); 
> > print "Gunzip Success returns a Value of $?"; print "<BR>"; 
> > system("gunzip failure.tar.gz"); 
> > print "Gunzip Failure returns a Value  of $?"; print "<BR><BR>"; 
> > [snip]
> > Gunzip Success returns a Value of 256 
> Exit value 1 
> > Gunzip Failure returns a Value of 512 
> Exit value 3 

Yes, I made a mistake. I meant to type "gunzip" instead of "gzip".
However, I've changed it to gunzip, and I still get return values of 256
and 512. Can you give me the code* that gives you those different exit
values of 1 and 3... so I can run it and see? 

I'm still reviewing the rest of your information. I just wanted to
quickly respond to the above for now.

* Please give a script if you will, to check the return values of
gunzip... I'm beginning to question if my shell commands are working
properly.

Thanks,
--Dennis



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

Date: 23 Mar 2001 19:27:13 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: using closures (road to OO)
Message-Id: <985375017.29008@itz.pp.sci.fi>

In article <tbmsa3da2jsb24@corp.supernews.com>, Greg Bacon wrote:
>In article <985346252.10004@itz.pp.sci.fi>,
>    Ilmari Karonen  <usenet11404@itz.pp.sci.fi> wrote:
>
>: In article <tbk5ub44ktf1f7@corp.supernews.com>, Greg Bacon wrote:
>:
>: >No.  There's no closure.
>: 
>: Of course there's a closure, [...]
>
>RTFM (from the perlref manpage):
>
>    Anonymous subroutines act as closures with respect to my()
>    variables, that is, variables lexically visible within the current
>    scope.  Closure is a notion out of the Lisp world that says if you
>    define an anonymous function in a particular lexical context, it
>    pretends to run in that context even when it's called outside the
>    context.
>
>The OP's code contained no anonymous subs.

Not the "what is a closure?" debate again.  IMHO, if it looks like a
closure and quacks like a closure..

In any case, perl doesn't really care if you define your subs like

  BEGIN {
      my $answer = 42;
      sub get_answer { $answer }
  }

or like

  BEGIN {
       use vars '*get_answer';
       my $answer = 42;
       *get_answer = sub { $answer };
  }

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Fri, 23 Mar 2001 16:56:44 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Using LWP, HTTP::Cookies etc in multi-threading in Windows 2000
Message-Id: <tbnhkc8kkjjob7@corp.supernews.com>

Hi

<<<This message has also been posted to comp.lang.per.moderated>>>

I am planning to use LWP and related packages in a multi-threaded Perl
application. The book "Network Programming With Perl" by Stein reiterates
the warnings, in the chapter on multi-threading, that 'multithreading should
not be used in production systems'.

I have three questions:
    1) Is LWP, HTTP:Cookies and related packages thread-safe?

    2) The warnings appear to be associated more with version 5.005 than
5.6. Stein mentions that things are much better in 5.6 but defers to version
6 (promised by summer of 2001, according to Stein) as the consummate Perl
with threading support. I am wondering if people have relevant experience of
using LWP etal in a multi-threading application?

    3) Assuming that the answers to the first two questions are positive, is
Active Perl the correct version to use for Windows 2000? (the deployment
platform). Is their Multi-threading version stable?

-TIA
David




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

Date: Fri, 23 Mar 2001 15:04:03 -0500
From: Clinton Munden <clinton.munden@alcatel.com>
Subject: Wild Card Problem!
Message-Id: <3ABBAC33.C70DA44F@alcatel.com>

Hi there,

I have a search script and here is the problem.  If I do a wild card
search ( * ) I get a server error.   Right now, as a work around, I have
add the following code

$value =~ tr/*/a/;

this allows the search to continue without error.  But it is not a good
solution because if I do a wild card search like this for example (
help* ), then the above code replaces the '*' with 'a' and searches for
"helpa"  which obviously give no search results.  Does anyone know some
short code to deal with the wild card character?

Thanks in Advance,
Clinton Munden



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

Date: Fri, 23 Mar 2001 15:02:23 -0500
From: Clinton Munden <clinton.munden@alcatel.com>
Subject: Wild Card Search!!
Message-Id: <3ABBABCF.7AE488C3@alcatel.com>

Hi there,

I have a search script and here is the problem.  If I do a wild card
search ( * ) I get a server error.   Right now, as a work around, I have
add the following code

$value =~ tr/*/a/;

this allows the search to continue without error.  But it is not a good
solution because if I do a wild card search like this for example (
help* ), then the above code replaces the * with a and searches for
"helpa"  which obviously give no search results.  Does anyone know some
short code to deal with the wild card character?

Thanks in Advance,
Clinton Munden



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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