[22986] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5206 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 9 21:52:59 2003

Date: Wed, 9 Jul 2003 18:51:03 -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, 9 Jul 2003     Volume: 10 Number: 5206

Today's topics:
        Setting the mode for trees in PerlTk (A Epstein)
    Re: Setting the mode for trees in PerlTk (A Epstein)
    Re: Setting the mode for trees in PerlTk <lusol@cube0.CC.Lehigh.EDU>
        Simple Regex Question <william.perrin@lawson.com>
    Re: Simple Regex Question <noreply@gunnar.cc>
    Re: Simple Regex Question <coo_t2-NO-LIKE-SPAM@yahoo.com>
    Re: Simple Regex Question <noreply@gunnar.cc>
        simple, stupid perl package Q <joec@aracnet.com>
    Re: simple, stupid perl package Q <emschwar@pobox.com>
        Solution to <STDIN> problem in Perl and print statement (Tan Rezaei)
        String concatenation with .= <FH> (Luke Powell)
    Re: String concatenation with .= <FH> (Jay Tilton)
    Re: String concatenation with .= <FH> (Bryan Castillo)
        Synchronizing two ftp sites/folders (michela rossi)
    Re: Synchronizing two ftp sites/folders <mothra@nowhereatall.com>
    Re: Synchronizing two ftp sites/folders <wgu_@_wurquhart.co.uk>
    Re: Synchronizing two ftp sites/folders <nanae@perusion.com>
        TELNET and waitfor problems <gshears@eastlink.ca>
    Re: Thread and shared data problem <tigger@hagbard.io.com>
    Re: Total Butt Heads in this news group (John D)
    Re: Total Butt Heads in this news group <jboes@nexcerpt.com>
    Re: Total Butt Heads in this news group <bdonlan@bd-home-comp.no-ip.org>
    Re: transform 3*0.0 into 0.0, 0.0, 0.0 <starobs99@yahoo.com>
        Unexpected behavior of signal catcher <stanb@panix.com>
    Re: Unexpected behavior of signal catcher (Greg Bacon)
    Re: Unexpected behavior of signal catcher <glex_nospam@qwest.net>
    Re: Unexpected behavior of signal catcher <stanb@panix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 9 Jul 2003 07:03:30 -0700
From: epstein_asaf@emc.com (A Epstein)
Subject: Setting the mode for trees in PerlTk
Message-Id: <a82b1086.0307090603.54d58505@posting.google.com>

I have created a tree object in PerlTk.  It seems to work fine.  When
the tree is initially displayed, I want all the children (for each
path) to be hidden.  Basically that the parents will have the '+' sign
next to them and when i click it, it will show the sub branches.  I
have written something like this:

foreach (@paths) {

    $tree -> setmode ( $_, 'open' );

}

According to documentation, this is the way to do it.  'open' means
that the branches will be "ready for opening," i.e closed.  However
this seems to have no effect at all.  The branches are all open ('-'
sign) and the children are not hidden.

Btw: I did not forget to put 

$tree -> autosetmode();

at the end, if that is what anyone was thinking.

What am I doing wrong?!!!  Help!!!


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

Date: 9 Jul 2003 12:48:37 -0700
From: epstein_asaf@emc.com (A Epstein)
Subject: Re: Setting the mode for trees in PerlTk
Message-Id: <a82b1086.0307091148.322801e1@posting.google.com>

epstein_asaf@emc.com (A Epstein) wrote in message news:<a82b1086.0307090603.54d58505@posting.google.com>...
> I have created a tree object in PerlTk.  It seems to work fine.  When
> the tree is initially displayed, I want all the children (for each
> path) to be hidden.  Basically that the parents will have the '+' sign
> next to them and when i click it, it will show the sub branches.  I
> have written something like this:
> 
> foreach (@paths) {
> 
>     $tree -> setmode ( $_, 'open' );
> 
> }
> 
> According to documentation, this is the way to do it.  'open' means
> that the branches will be "ready for opening," i.e closed.  However
> this seems to have no effect at all.  The branches are all open ('-'
> sign) and the children are not hidden.
> 
> Btw: I did not forget to put 
> 
> $tree -> autosetmode();
> 
> at the end, if that is what anyone was thinking.
> 
> What am I doing wrong?!!!  Help!!!


I asked the question and I will answer (I found out what happened).
There is no need to use autosetmode which will only override all the
setmode(...) calls done prior to it.  instead, just use the loop w/
setmode(..) as before and add a line to hide the children of each
parent (somebody please hide the children!!!):

foreach (@paths) {
 
    if ($_ is a parent) {
       $tree -> setmode ( $_, 'open' );
    } else {
       $tree->hide('entry', $_);
    }
}

the result will be closed branches w/ '+' signs next to them.  when
you click on the '+', the branches will open up to display the
children.  to check if a path is a parent i just searched the path
string for the parent/child separator but i am sure there is a better
way.


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

Date: 9 Jul 2003 20:00:04 GMT
From: Steve Lidie <lusol@cube0.CC.Lehigh.EDU>
Subject: Re: Setting the mode for trees in PerlTk
Message-Id: <behs84$c4u@fidoii.CC.Lehigh.EDU>

A Epstein <epstein_asaf@emc.com> wrote:

> string for the parent/child separator but i am sure there is a better
> way.


Ask your Perl/Tk questions in comp.lang.perl.tk for possibly better ways (;


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

Date: Wed, 09 Jul 2003 13:02:36 -0500
From: "William S. Perrin" <william.perrin@lawson.com>
Subject: Simple Regex Question
Message-Id: <3F0C58BC.3030205@lawson.com>

Hello, I'm regexing out some names from a file:

	while ($myfile =~ m/(\w+\b) (\w+\b)/g) {
		push @fn, $1;
		push @ln, $2;
	}

Sometimes the last name contains "Jr." or "III" or is a two part last name.

How can I extend $2 (or $1 for that matter) to include these bits if and 
when they occur. I would like to keep it to two fields only.

Thanks, WSP



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

Date: Wed, 09 Jul 2003 20:46:27 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Simple Regex Question
Message-Id: <beho8u$5aell$1@ID-184292.news.dfncis.de>

William S. Perrin wrote:
> Hello, I'm regexing out some names from a file:
> 
>     while ($myfile =~ m/(\w+\b) (\w+\b)/g) {
>         push @fn, $1;
>         push @ln, $2;
>     }
> 
> Sometimes the last name contains "Jr." or "III" or is a two part
> last name.
> 
> How can I extend $2 (or $1 for that matter) to include these bits
> if and when they occur. I would like to keep it to two fields only.

You can try this:

     m/(\w+\b)\s+([\w. ]+?)\s*/g

(untested)

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



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

Date: Wed, 09 Jul 2003 18:53:45 GMT
From: ed <coo_t2-NO-LIKE-SPAM@yahoo.com>
Subject: Re: Simple Regex Question
Message-Id: <ssoogv0lev534g3r3vuag5vtd0tiahe0hk@4ax.com>

On Wed, 09 Jul 2003 13:02:36 -0500, "William S. Perrin"
<william.perrin@lawson.com> wrote:


>How can I extend $2 (or $1 for that matter) to include these bits if and 
>when they occur. I would like to keep it to two fields only.
>

This may work for you:
m/(\w+\b) (\w+\b(?: \w+)?)/

The last group in parenthesis isn't captured due to the fact that it
begins with "?:". That means not to capture this group.  So if the
last bit exists it will be a part of $2 .

--ed


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

Date: Wed, 09 Jul 2003 22:03:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Simple Regex Question
Message-Id: <behsqh$5covk$1@ID-184292.news.dfncis.de>

Gunnar Hjalmarsson wrote:
> William S. Perrin wrote:
>> Hello, I'm regexing out some names from a file:
>>
>>     while ($myfile =~ m/(\w+\b) (\w+\b)/g) {
>>         push @fn, $1;
>>         push @ln, $2;
>>     }
>>
>> Sometimes the last name contains "Jr." or "III" or is a two part
>> last name.
>>
>> How can I extend $2 (or $1 for that matter) to include these bits
>> if and when they occur. I would like to keep it to two fields only.
> 
> You can try this:
> 
>     m/(\w+\b)\s+([\w. ]+?)\s*/g
> 
> (untested)

Well, that wasn't correct. (Should have realized that I'm not 
experienced enough to post untested code. ;-) )

This might work, though:

     m/(\w+)\s+([\w. ]+?)\s*$/gm

On the other hand, we don't know how that file is structured, so 
whatever suggestion you get, it's based on guesses. I believe you'd 
better give us some more info, in order to get some meaningful advise.

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



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

Date: Wed, 09 Jul 2003 11:09:12 -0700
From: Joseph Cipale <joec@aracnet.com>
Subject: simple, stupid perl package Q
Message-Id: <3F0C5A48.DF945A0B@aracnet.com>

I have written a package in perl, and I want to include it in a script
I am developing. I have it in my /home/joec/public_html/cgi directory.

When I try to invoke the script to test the pacakge inclusion, I get the
following message:
Can't locate CGILib/Error.pm in @INC (@INC contains:
/usr/lib/perl5/5.6.0/i686-linux /usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i686-linux /usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl/5.005 /usr/lib/perl5/site_perl) at catbird.cgi
line 19.

In my .cshrc file, I have set the PERL5LIB env var to my path where the
package
module is located. Is there anything else I can do/should do to get this
to work?

Regards,

Joe Cipale
-- 
#----------------------------------------------------------#
#                "Don't fear the penguin!"                 #
#----------------------------------------------------------#
# Registered Linux user: #309247     http://counter.li.org #
#----------------------------------------------------------#


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

Date: 09 Jul 2003 12:43:58 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: simple, stupid perl package Q
Message-Id: <etoel0zczgx.fsf@wormtongue.emschwar>

Joseph Cipale <joec@aracnet.com> writes:
> I have written a package in perl, and I want to include it in a script
> I am developing. I have it in my /home/joec/public_html/cgi directory.
> 
> When I try to invoke the script to test the pacakge inclusion, I get the
> following message:
> Can't locate CGILib/Error.pm in @INC

Two things are possible:

1) When you 

use CGIlib::Error;

Perl searches @INC for a directory which itself contains the file
'CGIlib/Error.pm'.  If you have Error.pm in ~/public_html/cgi, then it
won't find it in the right place.

2) Did you 'setenv PERL5LIB ~/public_html/cgi' ?  in csh, IIRC, you
   have to use setenv to make sure the variable is exported to
   subshells; if you use 'set', it's only valid in the current shell.

3) Much easier than setting PERL5LIB is to

use lib '/home/joec/public_html/cgi';

That adds the given directory to @INC.

-=Eric, hopes he remembers enough csh for that to make sense
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 8 Jul 2003 10:27:56 -0700
From: trezaei@hotmail.com (Tan Rezaei)
Subject: Solution to <STDIN> problem in Perl and print statements not printing on w2k server
Message-Id: <8c92d509.0307080927.1f6e8bbb@posting.google.com>

trezaei@hotmail.com (Tan Rezaei) wrote in message news:<8c92d509.0306281419.4c8482ee@posting.google.com>...
> I have this bit of code on a win2k Server:
> 
> -----------------------------------------
> #!E:\Perl\bin\perl.exe
> print "\n\n Productline (QA, PROD, ...)?\n ";
> chop($opt_p=<STDIN>);
> 
> print "\n\n Company (0001, 1000, 1001, \.\.\.) ? \n";
> chop($opt_c=<STDIN>);
> 
> if ($opt_c =~ /\D/) { warn "Company number contains non digits"}
> 
> print "\n\n Ready to Process Company $opt_c in Productline $opt_p
> (Y/N)?  \n";
> chop($run=<STDIN>);
> -----------------------------------------
> 
> Now when I run this, it does not prompt me for the variables but if I
> enter all three of them then I will get the questions.
> 
> If I comment out all the lines with <STDIN> then I get all the promts
> immediately.
> 
> Now this actually works fine on one machine and I only get this
> problem when I put the file on the server.
> 
> Is there something about terminal settigs or clearing the buffer that
> might be the issue. If so, how do I clear the screen buffer? This is
> one of those things that you just don't want to waste your time on.
> And it is really killing me.
> 
> Any help at all would be greatly appreciated.
> 
> thanks in advance
> 
> T


Well I tried 

$| = 1;
at the begining of the script and everything worked.
I thought I should post it in case someone else runs into this issue. 

 Thank you


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

Date: 8 Jul 2003 14:53:27 -0700
From: powell_luke@hotmail.com (Luke Powell)
Subject: String concatenation with .= <FH>
Message-Id: <e7ccbaac.0307081353.527d24e5@posting.google.com>

I was writing a program to parse some data and I found something odd.
I'm using the ActiveState 5.8.0 for Windows (build 804) version of
Perl, and I found that when I did this:

$record .= <FH>;  #replaces rather than appends to $record

that my record would not be concatenated with the the output of <FH>,
it would be replaced. That was odd so I tried this:

$record .= $_ = <FH>; #acts right and appends to $record

and that worked like a champ. Finally I tried:

$record = $record . <FH>; #also acts right, appends to $record

and I found that worked as well. So my question is why did my original
form not work when the other two did? Could anybody explain this to a
Perl newbie?

Thanks,

Luke Powell
powell_luke@hotmail.com


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

Date: Tue, 08 Jul 2003 23:18:05 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: String concatenation with .= <FH>
Message-Id: <3f0b5117.371408242@news.erols.com>

powell_luke@hotmail.com (Luke Powell) wrote:

: I found that when I did this:
: 
: $record .= <FH>;  #replaces rather than appends to $record
: 
: that my record would not be concatenated with the the output of <FH>,
: it would be replaced.

Not seeing it happen.

    #!perl
    $record = 'foo';
    $record .= <DATA>;
    print $record; # prints "foobar\n"
    __DATA__
    bar

Have you got a short, complete program that demonstrates the
phenomenon?



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

Date: 8 Jul 2003 22:17:33 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: String concatenation with .= <FH>
Message-Id: <1bff1830.0307082117.49fd08a1@posting.google.com>

powell_luke@hotmail.com (Luke Powell) wrote in message news:<e7ccbaac.0307081353.527d24e5@posting.google.com>...
> I was writing a program to parse some data and I found something odd.
> I'm using the ActiveState 5.8.0 for Windows (build 804) version of
> Perl, and I found that when I did this:
> 
> $record .= <FH>;  #replaces rather than appends to $record
> 

Could you post a very small script that shows this?
I couldn't reproduce what you describe above. (although Im using 5.6.1)
Here is what I tried:

use strict;
use warnings;
open(F,"<$0") || die $!;
my $record = "first line\n";
$record .= <F>;
print "record = ",$record,"\n";

Its output was:
record = first line
use strict;

> that my record would not be concatenated with the the output of <FH>,
> it would be replaced. That was odd so I tried this:
> 
> $record .= $_ = <FH>; #acts right and appends to $record
> 
> and that worked like a champ. Finally I tried:
> 
> $record = $record . <FH>; #also acts right, appends to $record
> 
> and I found that worked as well. So my question is why did my original
> form not work when the other two did? Could anybody explain this to a
> Perl newbie?
> 
> Thanks,
> 
> Luke Powell
> powell_luke@hotmail.com


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

Date: 8 Jul 2003 08:52:15 -0700
From: michela_rossi66@hotmail.com (michela rossi)
Subject: Synchronizing two ftp sites/folders
Message-Id: <1ed550fd.0307080752.ffca3e0@posting.google.com>

Hi,
Wonder if anyone can help me.

We have a local server, say STAGING on which we preview a site we're
developing. Periodically we upload files to the live site.

Does anyone know of any kind of shell script/perl script which we
could run which could recursively look at each folder on the live site
and STAGING, and if any files are out of date on live copy them up
from STAGING to live?

Anything like this around that anyone knows about?
Any help would be gratefully received ......

Many thanks,
Michela.


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

Date: Tue, 8 Jul 2003 08:55:14 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Synchronizing two ftp sites/folders
Message-Id: <3f0ae98d$1@usenet.ugs.com>


"michela rossi" <michela_rossi66@hotmail.com> wrote in message
news:1ed550fd.0307080752.ffca3e0@posting.google.com...
>
> We have a local server, say STAGING on which we preview a site we're
> developing. Periodically we upload files to the live site.
>
> Does anyone know of any kind of shell script/perl script which we
> could run which could recursively look at each folder on the live site
> and STAGING, and if any files are out of date on live copy them up
> from STAGING to live?
>
unix or WNT or both?

Mothra




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

Date: Tue, 08 Jul 2003 16:55:52 +0100
From: The Sender <wgu_@_wurquhart.co.uk>
Subject: Re: Synchronizing two ftp sites/folders
Message-Id: <0VBOa.17926$pd.12077@news-binary.blueyonder.co.uk>

At some time in the past michela rossi wrote :

> Hi,
> Wonder if anyone can help me.
> 
> We have a local server, say STAGING on which we preview a site we're
> developing. Periodically we upload files to the live site.
> 
> Does anyone know of any kind of shell script/perl script which we
> could run which could recursively look at each folder on the live site
> and STAGING, and if any files are out of date on live copy them up
> from STAGING to live?
> 
> Anything like this around that anyone knows about?
> Any help would be gratefully received ......
> 
> Many thanks,
> Michela.

Have a look at the man pages for wget.

-- 
Regards,

William


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

Date: Tue, 8 Jul 2003 16:01:20 +0000 (UTC)
From: Perusion hostmaster <nanae@perusion.com>
Subject: Re: Synchronizing two ftp sites/folders
Message-Id: <slrnbglqmm.1hv.nanae@ns.valuemedia.com>

On 8 Jul 2003 08:52:15 -0700, michela rossi <michela_rossi66@hotmail.com> wrote:
> Hi,
> Wonder if anyone can help me.
> 
> We have a local server, say STAGING on which we preview a site we're
> developing. Periodically we upload files to the live site.
> 
> Does anyone know of any kind of shell script/perl script which we
> could run which could recursively look at each folder on the live site
> and STAGING, and if any files are out of date on live copy them up
> from STAGING to live?
> 
> Anything like this around that anyone knows about?
> Any help would be gratefully received ......

Perl is not the best thing for the job, rsync(1) is:

	http://rsync.samba.org/

-- 
Perusion Hostmaster

"Being against torture ought to be sort of a bipartisan thing."
-- Karl Lehenbauer


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

Date: Wed, 9 Jul 2003 10:52:14 -0300
From: <gshears@eastlink.ca>
Subject: TELNET and waitfor problems
Message-Id: <37VOa.39931$PD3.156523@nnrp1.uunet.ca>

I am using perl's telnet to collect data on a TL1 connection, the waitfor
option doesn't seem to work:

$telnet->print('ACT-USER:AAACSV_5000:TEST:A1::TEST1;');
$telnet->waitfor('/;/');
$telnet->print('CSVRTRV-MVISVC:AAACSV_5000::A1:::USED:1:1,2048;');

The second print command is issued without waiting for the semicolon.

Any suggestions?

Thanks,

George




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

Date: Tue, 08 Jul 2003 21:49:52 -0500
From: Paul Archer <tigger@hagbard.io.com>
Subject: Re: Thread and shared data problem
Message-Id: <R9OdnVdb3_NNH5aiXTWJiA@io.com>


(I'm tired, and I can't think well enough right now to really analyze
this, but one thing you might look into is using 'threads' (new ithreads
implementation) rather than 'Thread', which is the old 5005 implementation.
Keep in mind that with ithreads, you have to explicitly share you data.
perlthrtut has more info (and make sure you're reading the right version
if you've upgraded perl on your system--that bit me on the rear just yesterday.)

Paul


Ole Borup <oleborup@diku.dk> spewed forth with:
> Hi

> I am making a perl program using threads, but got some odd problems
> using shared variables.

> To illustrate I used an example from "Programming Perl 3rd Edition
> (O'Reilly)" page 456.

> #!/usr/bin/perl
> use Thread qw(async yield);
> my $var = 0;
> print \$var."\n";
> sub abump {
>        if ($var == 0) {
>                yield;
>                $var++;
>        }
>        print \$var."\n";
> }

> my $t1 = new Thread(\&abump);
> my $t2 = new Thread(\&abump);

> for my $t ($t1, $t2) { $t->join }
> print "var is $var\n";
> print \$var."\n";

> As the output shows, it isn't the same $var used in the two threads
> and the main program:

> SCALAR(0x8060d04)
> SCALAR(0x812acd4)
> SCALAR(0x8189d14)
> var is 0
> SCALAR(0x8060d04)

> I am using "This is perl, v5.8.0 built for i386-linux-thread-multi"
> and have tried on both RedHat 8.0 and Mandrake 9.0 with the same
> result.

> What am I missing here, everything I found about shared variables
> indicated that $var should shared.

> - Ole Borup


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

Date: 8 Jul 2003 10:45:09 -0700
From: johndageek@yahoo.com (John D)
Subject: Re: Total Butt Heads in this news group
Message-Id: <c608545f.0307080945.48de471c@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbgk749.3f2.tadmc@magna.augustmail.com>...
> Robert <yyyy@yyy.com> wrote:
> 
> > Subject: Total Butt Heads in this news group
> 
> 
> That is true. 
> 
> History has shown that you don't hang around here for long though.


if this is going to be one of those entertaining flame wars, please
refer to original post so the rest of us "Total Butt Heads" can see
what we are being insulted/complimented for doing or not doing?

Thanks in advance for your help ;}
JD


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

Date: Tue, 08 Jul 2003 20:50:58 GMT
From: "Jeff Boes" <jboes@nexcerpt.com>
Subject: Re: Total Butt Heads in this news group
Message-Id: <2e1fb897b763e58094f8ff7b6058faf5@free.teranews.com>

On Tue, 08 Jul 2003 00:31:18 +0000, Robert wrote:

> Bite me

I guess that's a "Yes" ... 8->

> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
> news:Xns93B1CDAA6C3F8sdn.comcast@206.127.4.25...
>>
>> Did you have difficulty comprehending the posting guidelines to which
>> you were referred?

-- 
Jeff Boes                                      vox 269.226.9550 ext 24
Database Engineer                                     fax 269.349.9076
Nexcerpt, Inc.                                 http://www.nexcerpt.com
           ...Nexcerpt... Extend your Expertise



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

Date: Tue, 08 Jul 2003 17:16:57 -0400
From: "bd" <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: Total Butt Heads in this news group
Message-Id: <pan.2003.07.08.21.16.56.312449@bd-home-comp.no-ip.org>

On Tue, 08 Jul 2003 10:45:09 -0700, John D wrote:

> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbgk749.3f2.tadmc@magna.augustmail.com>...
>> Robert <yyyy@yyy.com> wrote:
>> 
>> > Subject: Total Butt Heads in this news group
>> 
>> 
>> That is true. 
>> 
>> History has shown that you don't hang around here for long though.
> 
> 
> if this is going to be one of those entertaining flame wars, please
> refer to original post so the rest of us "Total Butt Heads" can see
> what we are being insulted/complimented for doing or not doing?

Actually, he quoted the original post in its entirety :P
-- 
Freenet distribution not available
Basically my wife was immature.  I'd be at home in the bath and she'd
come in and sink my boats.
		-- Woody Allen



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

Date: Tue, 08 Jul 2003 12:24:18 -0500
From: CM <starobs99@yahoo.com>
Subject: Re: transform 3*0.0 into 0.0, 0.0, 0.0
Message-Id: <beeump$4dgt0$1@ID-189674.news.dfncis.de>

Brian McCauley wrote:
> CM <starobs99@yahoo.com> writes:
> 
> 
>>Thanks to all, I finaly adopted the following program (just for people
>>who could have a similar question) :
>>
>>--------------------------------------------------------------------
>>#!/usr/bin/perl
> 
> 
> Always:
>   use strict;
>   use warnings;
> 
> Do not wait for your failure to do so to cause you pain and
> embarassement, do it now.

OK. So I put these two commands on the top of the file? As explained and 
as you can see, I'm very new in perl...

> 
>># Transform e.g. 3*4.5 into 4.5 4.5 4.5
>># Transform , into _space_
>># Usage: removestars.pl input.dat > output.dat
>>#
>>open(INPUT, "<$ARGV[0]") || die "Cannot open $ARGV[0]";
> 
> 
> Don't waste your time.  Just use the magic ARGV filehandle.
> 

How?

>>while (<INPUT>)
>>   {
>>     $a =$_;
> 
> 
> Either use a named variable or use the default variable $_.
> 
> If you do use a named variable make it lexically scoped.
> 
> Don't use $a

What do you mean? Avoiding the use of $a will turn the program to look 
like what?

> 
>>     $a =~ s/(\d+)\*(\S+)(,)/print "$2 " for 1 .. $1/e;
>>     $a =~ s/(\d+)\*(\S+)($)/print "$2 " for 1 .. $1/e;
> 
> 
> Eeek!  
> 
> You really should not be printing in the RHS of the s///

If I don't print, it doens't work... I certainly missed something.

> You should not use a for loop in a non-void context.

Well, and without loops?

> Do you really want to rely on their being whitespace after the comma?

No,

> Do you really want only to consider a maximum of 2 * in a line?

No, it can be more...

> 
>>     $a =~ s/,/ /g;
>>     print $a;
>>   }
>>close(INPUT);
>>--------------------------------------------------------------------
> 
> 
> So did you really want...
> 
>  '1, 4*2,3, 4*5, 3*6'
> 
> ...to be reansformed into...
> 
>  '2,3 2,3 2,3 2,3 6 6 6 1 '
> 
> ...?
> 
> I would have thought you'd have wanted:
> 
>  '1 2 2 2 2 3 5 5 5 5 6 6 6' 

Yep exactly! But I laso want to remove any coma, even if no * around...
In conclusion, could you send me a more perly code?
Thanks,
CM




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

Date: Tue, 8 Jul 2003 17:48:39 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Unexpected behavior of signal catcher
Message-Id: <bef05n$ilm$1@reader1.panix.com>

I've got the following small test script:

#!/usr/bin/perl

my $true = 1;

sub catch_zap {
       my $signame = shift;
	   $shucks++;
	   die "Somebody sent me a SIG$signame!";
} 

sub catch_alm {
        my $signame = shift;
		$shucks++;
		print "Somebody sent me a SIG$signame!";
		return;
} 

$SIG{INT} = \&catch_alm;  # best strategy
$SIG{ALRM} = \&catch_zap;  # best strategy

while ($true)   # Main loop
{
}

Problem is that if I run it, and send it a SIGALM, it exits.

Why does it do this? I expected it to return to the main loop afterwards.

How can I get around this behavior?


 
-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: Tue, 08 Jul 2003 18:14:35 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Unexpected behavior of signal catcher
Message-Id: <vgm2gblb6cj148@corp.supernews.com>

In article <bef05n$ilm$1@reader1.panix.com>,
    Stan Brown  <stanb@panix.com> wrote:

: sub catch_zap {
:        my $signame = shift;
: 	   $shucks++;
: 	   die "Somebody sent me a SIG$signame!";
: } 
: 
: [...]
: $SIG{INT} = \&catch_alm;  # best strategy
: $SIG{ALRM} = \&catch_zap;  # best strategy
: 
: [...] 
: Problem is that if I run it, and send it a SIGALM, it exits.

Your SIGALRM handler dies!

Greg
-- 
The price of empire is terror.  The price of occupation is terror.  The
price of interventionism is terror.  As Barry Goldwater used to say, it
is as simple as that.
    -- Pat Buchanan


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

Date: Tue, 08 Jul 2003 13:17:02 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: Unexpected behavior of signal catcher
Message-Id: <UTDOa.74$wW.40750@news.uswest.net>

Stan Brown wrote:
> I've got the following small test script:
> 
> #!/usr/bin/perl
> 
> my $true = 1;
> 
> sub catch_zap {
>        my $signame = shift;
> 	   $shucks++;
> 	   die "Somebody sent me a SIG$signame!";
> } 
> 
> sub catch_alm {
>         my $signame = shift;
> 		$shucks++;
> 		print "Somebody sent me a SIG$signame!";
> 		return;
> } 
> 
> $SIG{INT} = \&catch_alm;  # best strategy
> $SIG{ALRM} = \&catch_zap;  # best strategy
> 
> while ($true)   # Main loop
> {
> }
> 
> Problem is that if I run it, and send it a SIGALM, it exits.
> 
> Why does it do this? I expected it to return to the main loop afterwards.
> 
> How can I get around this behavior?
> 
> 
>  

on SIGALRM catch_zap() is being called, which is calling a die.  Maybe 
you want it to call catch_alm instead??



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

Date: Tue, 8 Jul 2003 20:03:16 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: Unexpected behavior of signal catcher
Message-Id: <bef824$m9m$1@reader1.panix.com>

In <vgm2gblb6cj148@corp.supernews.com> gbacon@hiwaay.net (Greg Bacon) writes:

>In article <bef05n$ilm$1@reader1.panix.com>,
>    Stan Brown  <stanb@panix.com> wrote:

>: sub catch_zap {
>:        my $signame = shift;
>: 	   $shucks++;
>: 	   die "Somebody sent me a SIG$signame!";
>: } 
>: 
>: [...]
>: $SIG{INT} = \&catch_alm;  # best strategy
>: $SIG{ALRM} = \&catch_zap;  # best strategy
>: 
>: [...] 
>: Problem is that if I run it, and send it a SIGALM, it exits.

>Your SIGALRM handler dies!

OOPS!

Been to long since I coded perl.

THANKS!!!

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

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


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