[22405] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4626 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 26 09:05:57 2003

Date: Wed, 26 Feb 2003 06:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 26 Feb 2003     Volume: 10 Number: 4626

Today's topics:
        accessing a list of files from multiple machines <chris@cjx.com>
        Beginner question: Accessing anonymous data struct <brinker.h@stn-atlas.de>
    Re: Beginner question: Accessing anonymous data struct (Anno Siegel)
    Re: Beginner question: Accessing anonymous data struct (Tad McClellan)
        better way to avoid "uninitialized value in join" ? <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
    Re: better way to avoid "uninitialized value in join" ? <NoSpamPleaseButThisIsValid2@gmx.net>
    Re: better way to avoid "uninitialized value in join" ? (Anno Siegel)
    Re: editting photos on the fly <tassilo.parseval@post.rwth-aachen.de>
    Re: FAQ proposal: Why can't I compare two strings using (Philip Lees)
    Re: FAQ proposal: Why can't I compare two strings using (Philip Lees)
    Re: FAQ proposal: Why can't I compare two strings using (Tad McClellan)
    Re: FAQ proposal: Why can't I compare two strings using (Philip Lees)
    Re: Feedback request: photobrowser (Tad McClellan)
    Re: Feedback request: photobrowser (Tad McClellan)
    Re: Feedback request: photobrowser (Tad McClellan)
    Re: Getting answers with perldocs (Anno Siegel)
    Re: Getting answers with perldocs (Helgi Briem)
    Re: Getting answers with perldocs <ellem52@mail.com>
    Re: Need Help: fork / kill / kill 0 <usenet@tinita.de>
    Re: Need Help: fork / kill / kill 0 (Anno Siegel)
    Re: NET::FTP cut my file ? <madbat28@hotmail.com>
    Re: NET::FTP cut my file ? (eric)
    Re: NET::FTP cut my file ? <tassilo.parseval@post.rwth-aachen.de>
    Re: newbie regexp question <mike@luusac.co.uk>
    Re: newbie regexp question (Tad McClellan)
    Re: perl download script - how to minimize server memor (Adrian Grigore)
    Re: perl download script - how to minimize server memor (Adrian Grigore)
    Re: perl download script - how to minimize server memor <ubl@schaffhausen.de>
    Re: perl <ian@WINDOZEdigiserv.net>
    Re: Silencing Default Error Output of getopts <spero126NOSPAM@yahoo.com>
    Re: Tk::TableMatrix for ActivePerl 8xx Build? (Helgi Briem)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Feb 2003 09:39:12 +0000
From: Chris Allen <chris@cjx.com>
Subject: accessing a list of files from multiple machines
Message-Id: <slrnb5p2q0.93k.chris@mona.cjx.com>
Keywords: multiple files, locking, nfs



The directory /usr/web/incoming is a nfs-mounted partition that
is available from several machines. Each machine is going to run
a perl script that grabs a file from this directory, processes
it then discards it. 

I would *like* to do something like this:

@list contains full pathnames of all applicable files in /usr/web/lib/incoming

get_some_filename_unique_to_my_host() returns a filename in /usr/web/lib/incoming
that is unique to this host and marks the file as being processed.


for $file (@list)
{
	my $localname=get_some_filename_unique_to_my_host();
	my $result=rename($file,$localname);
	if($result)
	{
		# we got it

		get_on_with_processing($localname);
	}
	else
	{
		# somebody else got it

		log_that_we_didnt_get($file,$!);		
	}
}


I am assuming that if two different machines hit the file with
rename() at the same time then one will win and one will lose 
with a 'file not found' message.


Questions:


- Will the above work? Or am I being naive about the
underlying system?

- If it won't work, can anybody point me to a 'standard' way of
doing this sort of thing (perhaps I need flock()??)

Many thanks,


Chris Allen.






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

Date: Wed, 26 Feb 2003 11:54:25 GMT
From: Heinz Brinker <brinker.h@stn-atlas.de>
Subject: Beginner question: Accessing anonymous data struct
Message-Id: <1103_1046260465@dsit03>


When using the XML::Simple package it returns a data struct.
What I get is, when dumped, something like

'persons' => {
   'person' => {
      'P1' => {
         'personname' => {
            'value' => 'unknown'
         },
      },
      'P2' => {
         'personname' => {
            'value' => 'Name of person 1'
         },
         'born' => {
            'value' => 'xx.xx.xxxx'
         },
         'died' => {
            'wert' => 'yy.yy.yyyy'
         },
         'vita' => 'some text here',
      }
      'P3' => {
 .. you get the scheme
      }
   }
};

I tried using references to the data and the hashes themselves,
but I still can't figure out, how to access the data. Its easy
to address an entry if the data is known, but how do you do it
if you don't know the number of entries in the struct?

First I'd like to learn how I can find the number of persons in
the person hash.
Second I'd like to learn how to access a person by its name (if
there is a better way than to loop through the entries).

I tried to find the answers in the manuals, but my english seems
unsufficient to figure out the right way of my own. 

Any help is appreciated

Heinz from Bremen, Germany




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

Date: 26 Feb 2003 12:54:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Beginner question: Accessing anonymous data struct
Message-Id: <b3ideq$lpj$1@mamenchi.zrz.TU-Berlin.DE>

Heinz Brinker  <brinker.h@stn-atlas.de> wrote in comp.lang.perl.misc:
> 
> When using the XML::Simple package it returns a data struct.
> What I get is, when dumped, something like
> 
> 'persons' => {
>    'person' => {
>       'P1' => {
>          'personname' => {
>             'value' => 'unknown'
>          },
>       },
>       'P2' => {
>          'personname' => {
>             'value' => 'Name of person 1'
>          },
>          'born' => {
>             'value' => 'xx.xx.xxxx'
>          },
>          'died' => {
>             'wert' => 'yy.yy.yyyy'
>          },
>          'vita' => 'some text here',
>       }
>       'P3' => {
> .. you get the scheme
>       }
>    }
> };
> 
> I tried using references to the data and the hashes themselves,
> but I still can't figure out, how to access the data. Its easy
> to address an entry if the data is known, but how do you do it
> if you don't know the number of entries in the struct?
> 
> First I'd like to learn how I can find the number of persons in
> the person hash.

If the whole structure is in %h, the list of persons is

    keys %{ $h{ person}}

In the example this would return "P1", "P2" and "P3" in any order.
Used in scalar context it returns their number.

> Second I'd like to learn how to access a person by its name (if
> there is a better way than to loop through the entries).

    $h{ person}->{ P2}

will be the hashref that is assigned to P2.

Anno


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

Date: Wed, 26 Feb 2003 07:00:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Beginner question: Accessing anonymous data struct
Message-Id: <slrnb5pejj.4pc.tadmc@magna.augustmail.com>

Heinz Brinker <brinker.h@stn-atlas.de> wrote:
> 
> When using the XML::Simple package it returns a data struct.
> What I get is, when dumped, something like
                              ^^^^^^^^^^^^^^


It would have been nice if you had simply given it in "exactly like"
form so that we could easily have real data to work with...


> 'persons' => {
>    'person' => {
>       'P1' => {

>       'P2' => {


Numerically increasing keys make it likely that an array
would be better than a hash at this level...


> I tried using references to the data and the hashes themselves,
> but I still can't figure out, how to access the data. Its easy
> to address an entry if the data is known, but how do you do it
> if you don't know the number of entries in the struct?


Use recursion.


> First I'd like to learn how I can find the number of persons in
> the person hash.


I'll assume the top-level hash is named %h.

Use keys() in a scalar context to find out how many entries are in a hash:

   my $num_persons = keys %{ $h{persons}{person} };


> Second I'd like to learn how to access a person by its name (if
> there is a better way than to loop through the entries).


I don't understand the question. Is "P2" the "name" or is
"Name of person 1" the "name" that you refer to?


> I tried to find the answers in the manuals, but my english seems
> unsufficient to figure out the right way of my own. 


"Use Rule 1" from

   perldoc perlreftut

is not too hard to follow if you do it in 3 steps:

   my $num_persons = keys %hash;  # pretend it is a plain hash

   my $num_persons = keys %{  };  # replace the name with a block

   # fill in the block with a reference to the desired hash
   my $num_persons = keys %{ $h{persons}{person} };


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


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

Date: 26 Feb 2003 11:57:28 GMT
From: Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
Subject: better way to avoid "uninitialized value in join" ?
Message-Id: <b3ia38$rv2$1@reader10.wxs.nl>

Hi,

in a script I get a reference to an array, that may contain undefined
values.
I need to reduce this array to a string, but I get errors like:
Use of uninitialized value in join or string at ./dbi_bcp.pl line 133
if I do:
print HANDLE1 join("\t",@$arrayref);
what I want is:
('foo',undef,'bar') => "foo\t\tbar"

I found one solution that works:
print HANDLE1 join("\t",map{defined $_ ? $_ : ''} @$arrayref);

but I think this will cost a lot of extra execution time. Is there an
easier/quicker way?

thanks, Rene

-- 
 ___              _
| _ \___ _ _  ___//
|   / -_) ' \/ -_)  
|_|_\___|_||_\___|  


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

Date: Wed, 26 Feb 2003 13:11:11 +0100
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid2@gmx.net>
Subject: Re: better way to avoid "uninitialized value in join" ?
Message-Id: <3E5CAEDF.61A18734@gmx.net>

Rene van Leeuwen wrote:
> 
> Hi,
> 
> in a script I get a reference to an array, that may contain undefined
> values.
> I need to reduce this array to a string, but I get errors like:
> Use of uninitialized value in join or string at ./dbi_bcp.pl line 133
> if I do:
> print HANDLE1 join("\t",@$arrayref);
> what I want is:
> ('foo',undef,'bar') => "foo\t\tbar"

What about switching off the warning for that join?

{ no warnings 'uninitialized';
  print HANDLE1 join("\t",@$arrayref);
}

You know that undef in string context equals '' so you know it is safe
to switch off the warning here.

Wolf



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

Date: 26 Feb 2003 13:02:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: better way to avoid "uninitialized value in join" ?
Message-Id: <b3idtj$lpj$2@mamenchi.zrz.TU-Berlin.DE>

Rene van Leeuwen  <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl> wrote in comp.lang.perl.misc:
> Hi,
> 
> in a script I get a reference to an array, that may contain undefined
> values.
> I need to reduce this array to a string, but I get errors like:
> Use of uninitialized value in join or string at ./dbi_bcp.pl line 133
> if I do:
> print HANDLE1 join("\t",@$arrayref);
> what I want is:
> ('foo',undef,'bar') => "foo\t\tbar"
> 
> I found one solution that works:
> print HANDLE1 join("\t",map{defined $_ ? $_ : ''} @$arrayref);
> 
> but I think this will cost a lot of extra execution time. Is there an
> easier/quicker way?

You could switch off 'uninitialized' warnings as shown in another reply.

Other than that, you approach of filtering out the undef's is fine,
but is better written with grep() instead of map()

    grep defined, @$arrayref;

Anno


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

Date: 26 Feb 2003 08:55:53 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: editting photos on the fly
Message-Id: <b3hvep$640$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Abigail:

> Steve (sdyck@engr.uvic.ca.spam) wrote on MMMCDLXVI September MCMXCIII in
><URL:news:3E5C3264.4FFE92FE@engr.uvic.ca.spam>:

><>  In North America, you have to be 18 (Canada) and 21 (most of the USA) to
><>  access adult material.  Is adult material accessible by all in the
><>  Netherlands?
> 
> 
> You certainly won't get send to prison if you see a picture of a topless
> person while you're 15 years old.
> 
> What's the punishment for seeing a picture of a topless person while
> you're younger than 21 in the USA?

I think the point is that not the underage person seeing such a pic is
punished but rather the person who makes such media accessible to
people being of this 'illegal' age.

Having said that, by simply saying "Don't enter this page unless you are
of legal age because it contains some nudity" as the OP did is probably
counter-productive (I already sense the script-kiddies klicking the link
eagerly with dribbling mouths). This wouldn't stand before court if it
came to that.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 26 Feb 2003 09:46:51 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <3e5c85f0.68749500@news.grnet.gr>

On Tue, 25 Feb 2003 05:50:46 -0600, "Eric J. Roode"
<REMOVEsdnCAPS@comcast.net> wrote:

>"Jürgen Exner" <jurgenex@hotmail.com> wrote in
>news:3MM5a.8267$_J5.4846@nwrddc01.gnilink.net: 
>
>> One of the most frequently asked questions is
>>     "Why can't I compare two strings using == ?"
>
>Perhaps this proposal should be expanded to include
>
>    "Why can't I compare two strings/numbers using = ?"
>
>We've seen that a few times in the past couple weeks, too.

OK. Yet another post in today's batch seemed to be tripping over that
same thing, so here's a more detailed proposal:

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

'Why don't my equality tests work right?'

You're probably using the wrong operator. The first thing to remember
is that a single '=' does NOT do a comparison of any kind, it just
copies a value from one variable to another and returns that value.
So this code:

if ( $foo = $bar ){
	# do something
}

will copy the value of $bar to $foo and be true and execute the 'do
something' code if $bar is true and not if $bar is false.

The next thing to remember is that Perl has different operators for
comparing strings and numbers. The numeric equality comparison is '=='
and the equivalent for strings is 'eq'. If you use the wrong one you
probably won't  get the result you expect.

For example:

my $foo = 'foo';
my $bar = 'bar';

if ( $foo == $bar ){
	print "Same\n";
}else{
	print "Different\n";
}

This prints 'Same' because $foo and $bar are being compared as
numbers. Since they have no numeric value Perl sees them both as zero
and returns true.

NOTE: If you use strictures and warnings (as you should) then Perl
will warn you about what's wrong.

Here's another example:

my $foo = '0011';
my $bar = '11';

if( $foo == $bar ) numeric comparison -> TRUE

if( $foo eq $bar ) string comparison -> FALSE

The same kind of thing applies to inequality operators. See perlop for
more.

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

This is probably a bit wordy. Any comments?

Phil
-- 
Ignore coming events if you wish to send me e-mail


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

Date: Wed, 26 Feb 2003 09:48:56 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <3e5c8d32.70607937@news.grnet.gr>

On Wed, 26 Feb 2003 09:46:51 GMT, pjlees@ics.forthcomingevents.gr
(Philip Lees) wrote:

Correction:

>will copy the value of $bar to $foo and be true and execute the 'do

will copy the value of $bar to $foo and execute the 'do

>something' code if $bar is true and not if $bar is false.

Dunno where that 'be true and ' came from.

Phil
-- 
Ignore coming events if you wish to send me e-mail


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

Date: Wed, 26 Feb 2003 05:54:00 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <slrnb5pamo.4np.tadmc@magna.augustmail.com>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:

> 'Why don't my equality tests work right?'


> if ( $foo == $bar ){

> NOTE: If you use strictures and warnings (as you should) then Perl
               ^^^^^^^^^^^^^^
> will warn you about what's wrong.


strictures have nothing to do with the warning.

adding warnings alone will be enough to have perl tell you about it.


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


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

Date: Wed, 26 Feb 2003 13:42:02 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <3e5cc3d7.84597531@news.grnet.gr>

On Wed, 26 Feb 2003 05:54:00 -0600, tadmc@augustmail.com (Tad
McClellan) wrote:

>Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>
>> NOTE: If you use strictures and warnings (as you should) then Perl
>               ^^^^^^^^^^^^^^
>> will warn you about what's wrong.
>
>
>strictures have nothing to do with the warning.
>
>adding warnings alone will be enough to have perl tell you about it.

I know that. I just thought it wouldn't hurt to mention the strictures
as well.

Phil
-- 
Ignore coming events if you wish to send me e-mail


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

Date: Wed, 26 Feb 2003 06:32:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Feedback request: photobrowser
Message-Id: <slrnb5pcu9.4np.tadmc@magna.augustmail.com>

A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote:

> I spent some time over the last few days, incorporating comments I 
> received on an earlier version of this script, and looking for more code 
> to steal :).
  ^^^^^^^^

The correct term is "to reuse".  :-)


> # See if location contains any relative paths


The comment does not match what the code actually does.

It doesn't check for *any* relative paths, only those that
might go "higher" in the dir tree.

 ./me.jpg  and  family_reunion/sis.jpg

are relative paths that your code does not check for.


> bail_out($location, 'Invalid location specified in request.') 
>   if $location =~ /(\.\.)/;
                     ^    ^
                     ^    ^ a useless use of parens

Absolute paths can be bad too, but you don't check for them.

   if $location =~ /\.\./ or $location =~ m#^/#;

You should probably have an explicit chdir() somewhere near
the top of your program too.


> my $photo_path = "$config{htdocs_path}/${location}";
                                          ^        ^
                                          ^        ^
A useless use of curlies.


> sub bail_out {
> 	my $file = shift;
> 	my $message = shift;


   my($file, $message) = @_;


Makes it easier to add a 3rd argument...


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


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

Date: Wed, 26 Feb 2003 06:34:31 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Feedback request: photobrowser
Message-Id: <slrnb5pd2n.4np.tadmc@magna.augustmail.com>

A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote:

> my $location = $query->param("location");
> $location = '' if !$location;


What if  $location eq '0' ?

Do you want to overwrite it with the empty string?

Probably not, so:

   $location = '' unless defined $location;


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


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

Date: Wed, 26 Feb 2003 06:35:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Feedback request: photobrowser
Message-Id: <slrnb5pd5c.4np.tadmc@magna.augustmail.com>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> Also sprach A. Sinan Unur:

>> By the way, I am not sure the included code below is getting too long for 
>> posting here. Should I just post a URL in the future?
> 
> Depends on the length of the script. This one isn't too long and by
> putting it into the post, the group can comment on it line-by-line
> without any prior copying.


But we don't really need to see all (or any) of the HTML template.


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


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

Date: 26 Feb 2003 11:41:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Getting answers with perldocs
Message-Id: <b3i962$ins$1@mamenchi.zrz.TU-Berlin.DE>

LM  <ellem52@mail.com> wrote in comp.lang.perl.misc:
> Let's pretend I have no Perl Books, and no internet connection; I have
> to find all of my info with Perldocs.  Certainly Perldocs is "deep"
> enough for all my questions.
> 
> How would I find answers to these questions....
> 
> Removing Spaces In Files Names
> Renaming All Files With An Appended Number
> Merging File Contents
> Making  List, Checking It Twice
> Making text HTML, XML

These are general programming tasks none of which is specific to Perl.
In fact, some of them may be solved best with other tools than Perl.

> I need perldoc tips that perldoc perldoc isn't helping me with.  I get
> answers sometimes but more often than not I either get "junk: (I
> know... JIJO) or way too many answers.

The Perl documentation documents the Perl language.  It doesn't try
to give answers to each and every programming question.  The answers
to most Perl-specific questions can be found readily once you are
acquainted with its makeup.  It may also contain answers to one or
more of the questions above, but there is no good way to look them
up systematically.  Grepping through the .pod files is a possibility
(as has been mentioned in this thread).

The _Perl Cookbook_ (O'Reilly) would come close to what you expect,
but it's only available in print.

Anno


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

Date: Wed, 26 Feb 2003 11:44:19 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Getting answers with perldocs
Message-Id: <3e5ca582.1640560571@news.cis.dfn.de>

On Tue, 25 Feb 2003 14:34:59 -0500, LM <ellem52@mail.com>
wrote:

>Let's pretend I have no Perl Books, and no internet connection; I have
>to find all of my info with Perldocs.  Certainly Perldocs is "deep"
>enough for all my questions.
>
>How would I find answers to these questions....
>
>Removing Spaces In Files Names

perldoc perlrequick

my $file = 'something   with spaces in . txt'
$file =~  s/\s+/_/g;

>Renaming All Files With An Appended Number

perldoc -f rename

my $oldname = '/path/to/whatever';
my $newname = "$old.$number";
rename $oldname, $newname or 
   die "Cannot rename $old to $new:$!\n";

>Merging File Contents

perldoc -q append
perldoc -f open
perldoc -f print

>Making  List, Checking It Twice

my @list = qw/one two three four/;
my @list = (<INFILE>);
my @list = (1..500);
my @list = $one,$two,$three,$four;
my @list = split, "\t",$line;

I have no idea what you mean by Checking it Twice.

>Making text HTML, XML

That's really an HTML or XML question, not Perl.

perldoc -f print

-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Wed, 26 Feb 2003 08:51:00 -0500
From: LM <ellem52@mail.com>
Subject: Re: Getting answers with perldocs
Message-Id: <0fhp5vsob9jcacdhjnebittm1m2if3euah@4ax.com>

On Wed, 26 Feb 2003 11:44:19 GMT, helgi@decode.is (Helgi Briem) wrote:

>>Making  List, Checking It Twice
>
>my @list = qw/one two three four/;
>my @list = (<INFILE>);
>my @list = (1..500);
>my @list = $one,$two,$three,$four;
>my @list = split, "\t",$line;
>
>I have no idea what you mean by Checking it Twice.

It was a joke based on the song Santa Claus Is Coming To Town

 ...He's making a list, he's checking it twice
He's gonna find out who's naughty or nice
Santa Claus is coming to town...

--
There's more than one way to do it, but only some of them work


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

Date: 26 Feb 2003 08:57:09 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Need Help: fork / kill / kill 0
Message-Id: <tinhaws3q$1hf$tina@news01.tinita.de>

Peter W. Osel <pwo@infineon.com> wrote:
> I have a script which starts a child (via open("$commad |)"); Then I try 
> to kill the child with signal TERM, if this did not kill the child, I 
> want to kill the child using INT, etc.  The following code does not seem 
> to work (what am I missing?).  It looks as if kill 0 $pid does not 
> detect that the child was killed?

> The main script:
> ---
> #!/opt/perl_5.6.1/bin/perl -w
> #
> $child = "./_test-kill-child.pl";
> unless ($pid = open(CHILD, "$child |")) {
>          print STDERR "${0}: FATAL: Can't open $child : $!";
>          exit(1);
>          }

> sleep 2;

> for my $sig (qw(TERM INT HUP KILL)) {
>      print STDERR "${0}: DBG: kill child $pid (via $sig) ...\n";
>      kill($sig, $pid);
>      sleep 2;
>      #last unless kill(0, $pid);
>      if (kill(0, $pid)) {
>          print STDERR "${0}: DBG: child $pid survived $sig ...\n";
>          }

you probably want to add a "last" here in case $pid was killed:
       else { last }

>      }
> ---
> The child script
> ---
> #!/opt/perl_5.6.1/bin/perl

> $SIG{CHLD} = 'IGNORE';

put that into the main script and see what happens.
also always be careful with filehandles while forking.
see
 perldoc perlipc
for details.

hth, tina

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: 26 Feb 2003 10:02:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need Help: fork / kill / kill 0
Message-Id: <b3i3bk$e2p$1@mamenchi.zrz.TU-Berlin.DE>

Peter W. Osel <pwo@Infineon.COM> wrote in comp.lang.perl.misc:
> I have a script which starts a child (via open("$commad |)"); Then I try 
> to kill the child with signal TERM, if this did not kill the child, I 
> want to kill the child using INT, etc.  The following code does not seem 
> to work (what am I missing?).  It looks as if kill 0 $pid does not 
> detect that the child was killed?

You must wait() (or rather waitpid()) for the child process after
it was killed.  Otherwise, the child process leaves a zombie which
still can be signalled.

[code snipped]

Anno


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

Date: Wed, 26 Feb 2003 11:17:30 +0100
From: "The M@db@T" <madbat28@hotmail.com>
Subject: Re: NET::FTP cut my file ?
Message-Id: <b3i410$pnv$2@fata.cs.interbusiness.it>

Thanks Tassilo, the problem is in the transfer-mode settings because the
right set is :
$ftp->binary;
and now the code works fine :).

The M@db@T


"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> ha scritto nel
messaggio news:b3hr8i$1t5$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach The M@db@T:
>
> > I have a simple Win32 Perl code with FTP::NET module, and when my ftp
client
> > downloading file, he lost me some bytes. For example if  the file is
> > 3.000.503 bytes, after the download he become 3.000.465 : result i lost
38
> > bytes.....???? I wrong something or there is a bug ..............
> >
> > This is my code :
> >
> > use Net::FTP;
> > use Strict;
> > use Warnings;
>
>   use strict;
>   use warnings;
>
> Note the capitalization. Strictures and warnings are both pragmatas and
> therefore there's no capital first letter.
>
> >
> > print "Insert IP address : ";
> > chomp($site = <STDIN>);
> chomp(my $site = <STDIN>);
>
> > print "Insert Username: ";
> > chomp($username = <STDIN>);
> chomp(my $username = <STDIN>);
>
> > print "Insert Password: ";
> > chomp($password = <STDIN>);
> chomp(my $password = <STDIN>);
>
> > $ftp = Net::FTP->new($site,Timeout => 60,Passive => 1,Port => 21, Debug
=>
> > 3)
>
> my $ftp = ...
>
> >        or die "Can't connect: $@\n";
>                                 ^^
> You are checking the wrong variable here. Check $!. $@ is for something
> else. See 'perlvar.pod' for details on all of these special variables.
>
> > $ftp->login($username,$password);
> > $ftp->type(binary);
>              ^^^^^^
> Don't use barewords. Make it a string:
>
>     $ftp->type("binary");
>
> or simply
>
>     $ftp->binary;
>
> > $ftp->get('file.zip');
> > $ftp->quit;
> >
> > Anyone has an idea ???
>
> I suspect that the transfer-mode wasn't correctly set to 'binary' since
> you used a bareword instead of a properly quoted string.
>
> Tassilo
> --
>
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
>
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
>
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval




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

Date: 26 Feb 2003 03:24:01 -0800
From: ericehlers@hotmail.com (eric)
Subject: Re: NET::FTP cut my file ?
Message-Id: <65ed5bbb.0302260324.61d6dbff@posting.google.com>

"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in message news:<b3hr8i$1t5$1@nets3.rz.RWTH-Aachen.DE>...
> Also sprach The M@db@T:
> 
> > $ftp = Net::FTP->new($site,Timeout => 60,Passive => 1,Port => 21, Debug =>
> > 3)
> 
> my $ftp = ...
> 
> >        or die "Can't connect: $@\n";
>                                 ^^
> You are checking the wrong variable here. Check $!. $@ is for something
> else. See 'perlvar.pod' for details on all of these special variables.

actually, the Net::FTP documentation says "If the constructor fails
undef will be returned and an error message will be in $@".  a quick
look in FTP.pm shows that on failure the code manually writes any
error message to $@.  bizarre.

-eric


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

Date: 26 Feb 2003 12:12:09 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: NET::FTP cut my file ?
Message-Id: <b3iaup$iac$1@nets3.rz.RWTH-Aachen.DE>

Also sprach eric:

> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in message news:<b3hr8i$1t5$1@nets3.rz.RWTH-Aachen.DE>...

>> Also sprach The M@db@T:
>> 
>> > $ftp = Net::FTP->new($site,Timeout => 60,Passive => 1,Port => 21, Debug =>
>> > 3)
>> 
>> my $ftp = ...
>> 
>> >        or die "Can't connect: $@\n";
>>                                 ^^
>> You are checking the wrong variable here. Check $!. $@ is for something
>> else. See 'perlvar.pod' for details on all of these special variables.
> 
> actually, the Net::FTP documentation says "If the constructor fails
> undef will be returned and an error message will be in $@".  

Oh, you are right. I think Net::FTP is cheating by explicitely writing
to $@.

> a quick look in FTP.pm shows that on failure the code manually writes
> any error message to $@.  bizarre.

Thinking more about this matter, $! wouldn't be suitable either. It is
for failures of system-calls. But when the connect to an FTP server
fails, it is most often not the fault of system-calls that go wrong.

But still, $@ is the wrong place to store an error.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 26 Feb 2003 12:13:50 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: Re: newbie regexp question
Message-Id: <Cb27a.5111$EN3.40290@newsfep4-glfd.server.ntli.net>

> Seems to be that you're trying to parse - or in some way do something - a
> markup langage.  There are plenty of modules for that kind of work.  Check
> the CPAN repository;

Hi,

I just need the three lines I mentioned (the rest of the code is very
simple, designed to parse a particular file etc), and can't use pre-built
modules.

Mike




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

Date: Wed, 26 Feb 2003 07:01:13 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie regexp question
Message-Id: <slrnb5pekp.4pc.tadmc@magna.augustmail.com>

Mike <mike@luusac.co.uk> wrote:

> can't use pre-built
> modules.


Why not?


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


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

Date: 26 Feb 2003 02:03:36 -0800
From: lobbister.2.wuni@spamgourmet.com (Adrian Grigore)
Subject: Re: perl download script - how to minimize server memory usage?
Message-Id: <b4ed8910.0302260203.7ae2b34d@posting.google.com>

Malte Ubl <ubl@schaffhausen.de> wrote in message news:<b35a15$gam$1@news.dtag.de>...
> I guess, you could write to a temp file and then redirect the user to 
> that one.

I also considered this, but it is not an option since the same script
will also be used for delivering full versions of my games, meaning
that I do not want to disclose the location

> 
> The better question is, why would you want the referrer url in the file. 
> Maybe you can achieve the same by handing out a transaction id to the 
> user that you can use later to identify the referrer.

Actually I do not only write the referrer URL, but most important also
my affiliate's id (the affiliate who brought me the visitor). I even
use this script to patch the splashscreen with a co-branded version on
the fly. In other words: There is no workaround. I just need to make
this working...

Thanks,

Adrian


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

Date: 26 Feb 2003 02:07:09 -0800
From: lobbister.2.wuni@spamgourmet.com (Adrian Grigore)
Subject: Re: perl download script - how to minimize server memory usage?
Message-Id: <b4ed8910.0302260207.27b6533d@posting.google.com>

Brian McCauley <nobull@mail.com> wrote in message news:<u9heaxerlb.fsf@wcl-l.bham.ac.uk>...
> lobbister.2.wuni@spamgourmet.com (Adrian Grigore) writes:> This is a question about your web server software, it has nothing to
> so with Perl.

It has, because I was thinking maybe mod_perl could help solve this
problem.


> >  Is there some way to solve this problem without reducing the maximum
> > download speed for those downloaders who have the bandwidth?
> 
> The normal approach to CGIs that generate huge output is to create a
> temporary file and generate an internal redirect.
> 
> Furthermore, if you arrange that the temporary file is reused rather
> than regenerated in the event of an identical request this will allow
> the download to be restartable.

Not possible in this for security reasons, please see my reply to the
previous posting above. What I absolutely want to *evit* is exactly
this approach, as I will be using the same script for delvering full
versions of my games...


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

Date: Wed, 26 Feb 2003 12:54:47 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: perl download script - how to minimize server memory usage?
Message-Id: <b3id56$9dh$1@news.dtag.de>

Adrian Grigore wrote:
> Malte Ubl <ubl@schaffhausen.de> wrote in message news:<b35a15$gam$1@news.dtag.de>...
> 
>>I guess, you could write to a temp file and then redirect the user to 
>>that one.
> 
> 
> I also considered this, but it is not an option since the same script
> will also be used for delivering full versions of my games, meaning
> that I do not want to disclose the location

Your webserver or application can provide better security measures than 
the secret location of a file.

More important, you can always put mod_perl in the middle between 
request an reply. That will enably you to only let people download a 
file that have for example aquired a valid session id.

If you want your system to be secure you won't get around using a 
session id anyway, no matter whether you use a cgi script to deliver 
your file or whether the user accesses it via its direct URL.

 ...but this is getting offtopic...

->malte

-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: Wed, 26 Feb 2003 13:06:17 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: perl
Message-Id: <soep5v0tc4sbschnrou6vp65j2555fpqjh@4ax.com>
Keywords: Remove WINDOZE to reply

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



[ rearranged into chronological order ]


> >>-----BEGIN xxx SIGNED MESSAGE-----
> >>Hash: SHA1
> >>
> >>In a fit of excitement on Wed, 26 Feb 2003 12:23:59 +0000, Scott
> >><scott@mysecretworld.co.uk> managed to scribble:
> >>
> >>
> >>>Hi
> >>>
> >>>Can anyone help me by provding a snip of perl code that will ask
> >>>a user  for an input and then out put this input later on in the
> >>>html??
> >>>
> >>>Many thanks in Advance
> >>>
> >>>sp
> >>
> >>
> >>  $ perdoc perldoc
> > 
> > 
> > Typos ahoy!
> > 
> > Should read:
> > 
> > 
> >    $ perldoc perldoc
> > 


In a fit of excitement on Wed, 26 Feb 2003 12:43:31 +0000, Scott
<scott@mysecretworld.co.uk> managed to scribble:

> is really is a snippet, doesnt help unfortunately as iam not very 
> familiar with perl
> 
> sp
> 


You've failed in a few things here.


  1:> You top post.
  2:> You post to a defunct newsgroup
  3:> Although new to Perl, you haven't even attempted to RTFM.


Once you work out the above, you might have a more clear view on how
to achieve your goal.

I digress, and return to my original reply:


  $ perldoc perldoc



Regards,

  Ian

XP/FP: comp.lang.perl.misc   (the correct group for new Perl related
posts).

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPly7vWfqtj251CDhEQJsHACfZjngFH7yRDfQDhUvdoekwV+PweoAn11D
UsQLH5VhbnVGqjp//bWNO/+6
=uiA3
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Wed, 26 Feb 2003 11:42:57 -0000
From: "Spero" <spero126NOSPAM@yahoo.com>
Subject: Re: Silencing Default Error Output of getopts
Message-Id: <b3i94v$nd2$1@wisteria.csv.warwick.ac.uk>


"Alan Barclay" <gorilla@elaine.furryape.com> wrote in message
news:1046212868.34878@elaine.furryape.com...
> In article <b3fl3o$42a$1@wisteria.csv.warwick.ac.uk>,
> Spero <spero126NOSPAM@yahoo.com> wrote:
> >Hi,
> >
> >I've googled and googled, read man pages and web pages and can't find the
> >answer to this.
> >
> >How do I silence the default output of getopts?
>
> Set a WARN handler:
>
> #!/usr/bin/perl
>
> $SIG{'__WARN__'} = sub {
>         print "My error\n";
> };
>
> use Getopt::Std;
>
> getopts('hf:');
>

That's perfect, thank-you Alan. Why does it require the extra semi colon? It
seems unusual.

Spero




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

Date: Wed, 26 Feb 2003 10:07:55 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Tk::TableMatrix for ActivePerl 8xx Build?
Message-Id: <3e5c90eb.1635289542@news.cis.dfn.de>

On Tue, 25 Feb 2003 17:50:29 -0000, gort@LinxNet.com (Jim
Seymour) wrote:

>In article <3e5b7ac4.1564075912@news.cis.dfn.de>,
>	helgi@decode.is (Helgi Briem) writes:
>> On Mon, 24 Feb 2003 23:19:51 -0000, gort@LinxNet.com (Jim
>> Seymour) wrote:
>> 
>>>ActiveState apparently hasn't done the Tk::TableMatrix module for
>>>their 8xx build yet.  Anybody know where else I might find it?
>> 
>> Have you tried CPAN?
>
>For ActivePerl (build 8xx) compatible Win32 binary installs?
>

For one thing, CPAN has a PPM repository:
http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58

If a PPD package has been made ( I don't know, it'll
be there).

Why do you need a "binary install" anyway  Just get nmake
and do it yourself.  It's easy.

http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe

(expands to nmake.exe and nmake.err).  nmake.exe is what
you want to use.  Stick it in path somewhere and follow
the instructions for a Unix install, substituting nmake
for make.

-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

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


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