[19255] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1450 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 6 09:05:31 2001

Date: Mon, 6 Aug 2001 06:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997103109-v10-i1450@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 6 Aug 2001     Volume: 10 Number: 1450

Today's topics:
        3 very easy ones 4 u <paul@net366.com>
    Re: 3 very easy ones 4 u <ilya@martynov.org>
        [Q] Trying to streamline a simple comparison (Robert)
    Re: [Q] Trying to streamline a simple comparison <Tassilo.Parseval@post.rwth-aachen.de>
    Re: ActiveState Perl <-> Cygwin perl and newlines... <simon.andrews@bbsrc.ac.uk>
    Re: Allowing ONLY letters and spaces in regular express <Tassilo.Parseval@post.rwth-aachen.de>
    Re: config for @INC ... more info <tom.melly@ccl.com>
        FAQ: Why don't my tied hashes make the defined/exists d <faq@denver.pm.org>
    Re: frustrated beginner's question (Anno Siegel)
    Re: how to change environnement variable in perl (Win32 <bol@adv.magwien.gv.at>
    Re: how to find free disk space (Win32) (John Stumbles)
        IO::Socket and signal problems <shashanka.sj@in.bosch.com>
        IO::Socket and signal problems <shashanka.sj@in.bosch.com>
    Re: IO::Socket and signal problems <philippe.perrin@sxb.bsf.alcatel.fr>
    Re: Optimum Sum? (Mark Jason Dominus)
    Re: Optimum Sum? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Perl OO Help needed (again) (Kate T. Porter)
    Re: Save memory and measure used memory??? <nospam-abuse@ilyaz.org>
    Re: Strange IE cookie behaviour <ceverett@cobalt.physemp.com>
        string inside string <bart@nijlen.com>
    Re: string inside string <Tassilo.Parseval@post.rwth-aachen.de>
        substring matching  <joerivdv007@hotmail.com>
        Translate VB-Script into Perl <axel.dieter.weiss@t-online.de>
    Re: Uploading files to a sever. <dbe@wgn.net>
    Re: Uploading files to a sever. (george hart)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 6 Aug 2001 10:13:24 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: 3 very easy ones 4 u
Message-Id: <997089125.14312.0.nnrp-13.d4f094e4@news.demon.co.uk>

Sorry to bother you gurus, I learnt some Perl at the weekend and I have
realised that it is a fantastically easy language to learn and very, very
powerful. however, I can't find 3 things in the FAQ. Could anyone help me? I
am at home with C/C++/Java etc.

1) How do I equivalent a #include? I have some subroutines which I don't
want to edit anymore, but I don't want them cluttering up my code some I
want do the equivalent of #include mysub.pl

2) How do I find the number of occurrences of "abc" in "abcdefabc" for
example? m// and s/// do everything but return the count as far as I can
see. Also can I m// for an exact match, eg a password without checking the
match and the string length?

3) not so important, my code works but I can't help thinking it's not as
clever/small/efficient as it could be. I want to find all the files
containing a string, and how many of them there are, and what the highest
numbered suffix is. the files are called filetype.1, filetype.2 etc. I have
written
$fn="./";
opendir DH, $fn;
@fils=readdir(DH);
$type="filetype.";
@this=grep (/$type/, @fils);
foreach $this (@mail) {
$this=~s/$type//g;
}
@this = sort {$b <=> $a} @this;
$count=@this;
print "$type files : the largest one is $this[0], and the total number is
$count\r\n";
exit;

Thanks in advance and sorry to be so boring! Maximum respect to those of you
who have mastered this strange and wonderful language ...
Paul





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

Date: 06 Aug 2001 13:51:21 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: 3 very easy ones 4 u
Message-Id: <87wv4ha546.fsf@abra.ru>


PF> Sorry to bother you gurus, I learnt some Perl at the weekend and I have
PF> realised that it is a fantastically easy language to learn and very, very
PF> powerful. however, I can't find 3 things in the FAQ. Could anyone help me? I
PF> am at home with C/C++/Java etc.

PF> 1) How do I equivalent a #include? I have some subroutines which I don't
PF> want to edit anymore, but I don't want them cluttering up my code some I
PF> want do the equivalent of #include mysub.pl

Either 'do', or 'require', or 'use'. Read documentation on them in
'perldoc perlfunc'.

PF> 2) How do I find the number of occurrences of "abc" in "abcdefabc" for
PF> example? m// and s/// do everything but return the count as far as I can
PF> see.

$count = () = $string =~ m/abc/g;

() forces array context thus $string =~ m/abc/g returns a list of all
the matched strings. Later conversion to scalar $count gives a number
of list elements: thus a number of matches. See 'perldoc perlop' for
more info.

PF> Also can I m// for an exact match, eg a password without checking
PF> the match and the string length?

You use ($str1 =~ /^\Q$str2\E$/) to check exact match beetween $str1
and $str2 but it is much easier to do ($str1 eq $str2).

PF> 3) not so important, my code works but I can't help thinking it's not as
PF> clever/small/efficient as it could be. I want to find all the files
PF> containing a string, and how many of them there are, and what the highest
PF> numbered suffix is. the files are called filetype.1, filetype.2 etc. I have
PF> written
PF> $fn="./";
PF> opendir DH, $fn;
PF> @fils=readdir(DH);
PF> $type="filetype.";
PF> @this=grep (/$type/, @fils);
PF> foreach $this (@mail) {
PF> $this=~s/$type//g;
PF> }
PF> @this = sort {$b <=> $a} @this;
PF> $count=@this;
PF> print "$type files : the largest one is $this[0], and the total number is
PF> $count\r\n";
PF> exit;

First of all your code contains a bug. It will match filenames like
'filetypex.1', 'filetypey.2', 'ttfiletype.3' and so on because '.' in
pattern "filetype." matches any char and because you do not anchor
your matches on the begining of filename. You should use

    $type="filetype.";
    @this=grep (/^\Q$type\E/, @fils);

See 'perldoc perlre' for more info.

Second of all it is good idea always check what returns opendir

    $fn="./";
    opendir DH, $fn or die "Can't open directory $fh: $!";

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 6 Aug 2001 00:42:42 -0700
From: rpfries@my-deja.com (Robert)
Subject: [Q] Trying to streamline a simple comparison
Message-Id: <4e521e59.0108052342.41a19ff6@posting.google.com>

I have a small script where someone can enter up to 2 search terms,
      then I see if they match two values in my script.  Here's how I'm
      doing it:

      - - - - - - -
      if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
        blah blah;
      }
      - - - - - - -

      If $term1 or $term2 are null, the above does not work as desired.  I
      can do this:

      - - - - - - -
      if ($term1 eq "" ) {
         if ($term2 =~ /$myterm2/) {
            blah blah;
         }
      elsif ($term2 eq "" ) {
         if ($term1 =~ /$myterm1/) {
            blah blah;
         }
      else {
         if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
            blah blah;
         }
      }
      - - - - - - -

      This basically says "If term 1 is null, then only compare term2."

      This is obviously not very streamlined ... I was hoping to do
      something like:

      - - - - - - -
      if ($term1 eq "" ) {
         $term=".*";
      }
      if ($term2 eq "" ) {
         $term=".*";
      }
      if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
         blah blah;
      }
      - - - - - - -

      This way, if a term is null, it will match anything.  The above
      doesn't work, though.  I'm sure there's an easy way to do this ... can
      anyone point me in the right direction?

      Thanks for your help,

      Robert


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

Date: Mon, 06 Aug 2001 10:23:02 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: [Q] Trying to streamline a simple comparison
Message-Id: <3B6E53E6.8030902@post.rwth-aachen.de>

Robert wrote:

>I have a small script where someone can enter up to 2 search terms,
>      then I see if they match two values in my script.  Here's how I'm
>      doing it:
>
>      - - - - - - -
>      if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
>        blah blah;
>      }
>      - - - - - - -
>
>      If $term1 or $term2 are null, the above does not work as desired.  I
>      can do this:
>
>      - - - - - - -
>      if ($term1 eq "" ) {
>         if ($term2 =~ /$myterm2/) {
>            blah blah;
>         }
>      elsif ($term2 eq "" ) {
>         if ($term1 =~ /$myterm1/) {
>            blah blah;
>         }
>      else {
>         if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
>            blah blah;
>         }
>      }
>      - - - - - - -
>
>      This basically says "If term 1 is null, then only compare term2."
>
>      This is obviously not very streamlined ... I was hoping to do
>      something like:
>
>      - - - - - - -
>      if ($term1 eq "" ) {
>         $term=".*";
>      }
>      if ($term2 eq "" ) {
>         $term=".*";
>      }
>      if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
>         blah blah;
>      }
>      - - - - - - -
>
>      This way, if a term is null, it will match anything.  The above
>      doesn't work, though.  I'm sure there's an easy way to do this ... can
>      anyone point me in the right direction?
>

Perhaps using an or:

if ( (not $term1 or $term1 =~ /$myterm1/) and (not $term2 or $term2 =~ 
/$myterm2/) ) {
    ...
}

$term(1|2) will only be matched against the regex if they are not empty. 
If they are, true is returned.


Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};





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

Date: Mon, 06 Aug 2001 12:52:38 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: ActiveState Perl <-> Cygwin perl and newlines...
Message-Id: <3B6E8506.9F3A52B0@bbsrc.ac.uk>

nobody wrote:
> 
> I'm sure this is a common question, and I tried to find answers
> in the newsgroups, but I just can't find a simple solution.
> 
> Using ActiveState Perl, newlines are handled in the msdos way,
> and doing a:
> 
> print "hello\nHow are you?\n";
> 
> will print correct newlines.
> 
> Running the same line of code in cygwin perl, it won't print
> the newlines, because cygwin only outputs a \n.
> 
> Is there a simple setting that makes cygwin behave like
> activeperl, without doing many changes in the code?


You could just do print "Whatever\r\n" to get windows line endings.  

I seem to remember that there is also a global variable you can set to
change the default line ending (hopefully someone will leap in and
remind me which one!).  Changing that at the top of your script should
generate the correct line endings from that point on (it changes the
characters output by \n).  Perldoc perlvar will probably have the
details you need.

	TTFN

	Simon.


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

Date: Mon, 06 Aug 2001 10:14:43 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Allowing ONLY letters and spaces in regular expression??
Message-Id: <3B6E51F3.1080505@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:

>This is what can make Perl so confusing sometimes.  That different 
>symbols can mean different things in the context.  When Perl is confusing 
>like this I suppose it is tantamount to learning how to speak Chinese.  I 
>understand that words in that language are also somewhat dependent on the 
>context in which they are spoken.
>

Yes, as to context Perl is complex and subtle. There is one thing that 
can be said about Perl, for the good or for the bad: It is friendly to 
the beginner in the sense that it provides a new user with the means to 
tackle respectable problems that he wouldn't even get close with other 
languages. After a while it gets immensly rich. You compare it with 
Chinese...well, it is not that hard. ;-) But to me Perl always appeared 
to be the computer language being closest to a human languages. The 
design and concept of this language are marvellous.


Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};





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

Date: Mon, 6 Aug 2001 13:59:35 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: config for @INC ... more info
Message-Id: <3b6e94b8$0$3763$ed9e5944@reading.news.pipex.net>

"Dan Baker" <dan@nospam_dtbakerprojects.com> wrote in message
news:3B6E06B2.837F07E3@nospam_dtbakerprojects.com...

<snip>

As a starting point, I would check what the assoc. action is for the .pl
extension.




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

Date: Mon, 06 Aug 2001 12:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Why don't my tied hashes make the defined/exists distinction?
Message-Id: <1Vvb7.59$T3.170727936@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  Why don't my tied hashes make the defined/exists distinction?

    They may or may not implement the EXISTS() and DEFINED() methods
    differently. For example, there isn't the concept of undef with hashes
    that are tied to DBM* files. This means the true/false tables above will
    give different results when used on such a hash. It also means that
    exists and defined do the same thing with a DBM* file, and what they end
    up doing is not what they do with ordinary hashes.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.60
-- 
    This space intentionally left blank


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

Date: 6 Aug 2001 08:26:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: frustrated beginner's question
Message-Id: <9klkca$48r$1@mamenchi.zrz.TU-Berlin.DE>

According to Anthony_Barker <anthony_barker@hotmail.com>:

> >     my ( $first, $last) = ( split /,/)[ 2, 3];
> >     $seen{ substr( $first, 0, 3) . $separator . $last}++; # mark as seen
> 
> data going into the hash looks like "fir:lastname"

Yes, that's the key.

> what does the ++ do in this case?

It counts.  When a key (first:last combination) appears for the first
time, the corresponding value is undefined.  "++" takes that to be
0 and increments it to 1.  If the same combination appears again,
the value (now 1) is further incremented to 2, and so on.  So after
the first pass every key with a value of 2 or above must be a duplicate.

> Hashes I guess don't have to have unique values... (I thought they
> did...)

They do.  At any one time there is only one value corresponding to
each key.  The value may change over the course of the program.

Anno


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

Date: Mon, 06 Aug 2001 11:39:12 +0200
From: Ferry Bolhar <bol@adv.magwien.gv.at>
Subject: Re: how to change environnement variable in perl (Win32)
Message-Id: <997090757.964273@mozart.adv.magwien.gv.at>

666.diablo@wanadoo.fr schrieb:
> 
> I would like to change the environnement variable called Hi
> 
> In batch file, I decare it like this:
> SET Hi=Hello
> And use it :
> ECHO %Hi%
> After I call a perl script, and I can import this value using:
> $ENV{Hi}
> 
> It works for reading, but if I change $ENV{Hi}in the perl scrip:
> $ENV{Hi}="Good Bye";
> 
> after the perl script is finished, the %Hi% variable is still set to Hello
> instead of "Good Bye".
> 
> Do you know how to make environnement variable change in my perl script
> still available after execution?

You can't. Your Perl script runs as separate child process, with its own
environment (a copy of the environment of your shell). Changes in the
environment apply to this child process only, not to the environment of
your shell.

There is a workaround for this - in your Perl script, write the changes
you want to made to a temporary shell script and, after running the Perl
script, execute the shell script:

Shell script with sh or ksh:

export Hi=Hello
perl -w changes.pl >x.sh
 . x.sh
rm x.sh


or with csh or tcsh:

setenv Hi Hello
perl -w changes.pl >x.sh
source x.sh
rm x.sh


and Perl script changes.pl:

print "export Hi='Good bye'"; 	(sh/ksh)

print "setenv Hi 'Good by'";	(csh/tcsh)

Greetings, Ferry

-- 
Ing. Ferry Bolhar-Nordenkampf
Municipality of Vienna
Municipality Department 14
A-1010 Vienna
E-mail: bol@adv.magwien.gv.at

"Wenn hier einer schuld ist, dann immer nur der Computer."


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

Date: 6 Aug 2001 04:29:10 -0700
From: john.stumbles@ntlworld.com (John Stumbles)
Subject: Re: how to find free disk space (Win32)
Message-Id: <7f40850b.0108060329.24794f53@posting.google.com>

ansok@alumni.caltech.edu (Gary E. Ansok) wrote in message news:<9k9ccf$fkd@gap.cco.caltech.edu>...
> In article <b65eb2a6.0108010241.119537fd@posting.google.com>,
> John Stumbles <jstumbles@bluearc.com> wrote:
> >Is there a module? Or some fairly portable way to do this? On windoze
> >even grepping `dir` for 'bytes free' fails if the disk is empty :-(
> 
> For Windows, there's Win32::DriveInfo, available from CPAN.
> 
> I've used $bytes_free = Win32::DriveInfo::GetDiskFreeSpaceEx('g:')
> successfully in the past.
> 
> -- Gary Ansok

Thanks.

I think it's worth mentioning that this module requires Win32::API,
and the latter as supplied on CPAN doesn't include the .dlls necessary
to make it work (though it has a Makefile.PL if you have to tools to
build them). If you follow the links in the docs (I think) to the
Win32::API developer's website and get the appropriate .PPM (or if PPM
works for you, install that way) you can get the DLLs that way.

regards


-- 
John Stumbles                                
http://www.stumbles.org/John
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


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

Date: Mon, 06 Aug 2001 14:28:07 +0530
From: Emmanuel E <shashanka.sj@in.bosch.com>
Subject: IO::Socket and signal problems
Message-Id: <3B6E5C1F.1E48E50E@in.bosch.com>

hi,

i want to timeout my socket after 2 minutes. the timeout() method in
IO::Socket dosent work.
so i used a signal handler.below is a portion of my code:

$SIG{ALRM} = \&windup();

windup()
{
close ($sock);
goto ACCEPT;
}

ACCEPT:
for(;;)
{
    $sock = $server->accept();
    alarm (120);
   if( $sock->read($data,100) <=0) {windup();}
    alarm(0);
/* other stuff
*/
}

when the signal goes off perl says cannot find ACCEPT and exits.

when i call the function windup() if recv returns error then it works
fine.

what am i doing wrong? or rather how do i correctly exit a signal
handler.

and what could be the problem with IO::Socket->timeout? i am on a rh 7.0
perl 5.6.0

on the other hand if i dont use goto ACCEPT in the signal handler the
program just goes back in to the blocking recv() (that is if i dont
close the socket).

thanks in advance

Emmanuel


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

Date: Mon, 06 Aug 2001 14:28:52 +0530
From: Emmanuel E <shashanka.sj@in.bosch.com>
Subject: IO::Socket and signal problems
Message-Id: <3B6E5C4C.92896EB1@in.bosch.com>

hi,

i want to timeout my socket after 2 minutes. the timeout() method in
IO::Socket dosent work.
so i used a signal handler.below is a portion of my code:

$SIG{ALRM} = \&windup();

windup()
{
close ($sock);
goto ACCEPT;
}

ACCEPT:
for(;;)
{
    $sock = $server->accept();
    alarm (120);
   if( $sock->read($data,100) <=0) {windup();}
    alarm(0);
/* other stuff
*/
}

when the signal goes off perl says cannot find ACCEPT and exits.

when i call the function windup() if recv returns error then it works
fine.

what am i doing wrong? or rather how do i correctly exit a signal
handler.

and what could be the problem with IO::Socket->timeout? i am on a rh 7.0
perl 5.6.0

on the other hand if i dont use goto ACCEPT in the signal handler the
program just goes back in to the blocking recv() (that is if i dont
close the socket).

thanks in advance

Emmanuel


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

Date: Mon, 06 Aug 2001 13:43:22 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: IO::Socket and signal problems
Message-Id: <3B6E82DA.DEC02D5A@sxb.bsf.alcatel.fr>

I don't know IO::Socket much, but I know that in C, the "usual" way to
timeout a socket is to use select(). Since select() exists in Perl as
well, with the same meaning, maybe you could simply use it ?

--
PhP

Emmanuel E wrote:
> 
> hi,
> 
> i want to timeout my socket after 2 minutes. the timeout() method in
> IO::Socket dosent work.
> so i used a signal handler.below is a portion of my code:
> 
> $SIG{ALRM} = \&windup();
> 
> windup()
> {
> close ($sock);
> goto ACCEPT;
> }
> 
> ACCEPT:
> for(;;)
> {
>     $sock = $server->accept();
>     alarm (120);
>    if( $sock->read($data,100) <=0) {windup();}
>     alarm(0);
> /* other stuff
> */
> }
> 
> when the signal goes off perl says cannot find ACCEPT and exits.
> 
> when i call the function windup() if recv returns error then it works
> fine.
> 
> what am i doing wrong? or rather how do i correctly exit a signal
> handler.
> 
> and what could be the problem with IO::Socket->timeout? i am on a rh 7.0
> perl 5.6.0
> 
> on the other hand if i dont use goto ACCEPT in the signal handler the
> program just goes back in to the blocking recv() (that is if i dont
> close the socket).
> 
> thanks in advance
> 
> Emmanuel


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

Date: Mon, 06 Aug 2001 10:28:13 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Optimum Sum?
Message-Id: <3b6e713d.1938$3bf@news.op.net>

In article <3B6E35A7.80303@post.rwth-aachen.de>,
Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>While it is true that you get decent results with your method, which is 
>actually called Greedy, 

In English, this method is called 'first fit decreasing'.  'Greedy' is
an adjective; there are many 'greedy' algorithms, such as the one
that omits the initial sort.

>without the need for backtracking, you nonetheless have a NP-complete
>problem if you want to find the optimum.

Fortunately, the original poster was not interested in finding the
optimum.  He specifically asked how to find packings that were close
to optimum without being brute force.

Just saying that a problem is NP-complete is not the end of the story.
For many applications, there are still heuristics that have acceptable
performance even though they do not always deliver the optimum
solution, or have exponential worst-case running time.  Waving off a
real-world problem by saying "that is NP-complete, so no solution is
better than brute force" is wrong in many cases.  It is a good answer
if you are trying to look clever and learned, and a bad answer if you
are trying to solve the problem.

People need to learn that NP-complete does not mean that you have to
give up.  People solve NP-complete problems every day.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 06 Aug 2001 12:58:48 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Optimum Sum?
Message-Id: <3B6E7868.9030000@post.rwth-aachen.de>

Mark Jason Dominus wrote:

>In article <3B6E35A7.80303@post.rwth-aachen.de>,
>Tassilo von Parseval  <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>
>>While it is true that you get decent results with your method, which is 
>>actually called Greedy, 
>>
>
>In English, this method is called 'first fit decreasing'.  'Greedy' is
>an adjective; there are many 'greedy' algorithms, such as the one
>that omits the initial sort.
>

Well, well, well. Even though greedy is of course an adjective, it 
denotes a certain approach in terms of algorithms, namely an approximate 
solution in contrast to a definite one.
Admittedly, now I am splitting hairs. ;-)


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};





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

Date: 6 Aug 2001 12:02:05 GMT
From: katetal@ugcs.caltech.edu (Kate T. Porter)
Subject: Re: Perl OO Help needed (again)
Message-Id: <9km0vt$okv@gap.cco.caltech.edu>

>
>And this is the message that appears in the browser (courtesy of Carp):
>Software error:
>Can't call method "unescape" on an undefined value at
>/usr/lib/perl5/5.6.1/CGI.pm line 112.
>
>I am simply trying to call a method via an object reference.  I have had
>a lot of help and great advice up to this point, and from all I
>understand, this should work just fine.  What am I still missing??  
>
<snip>
>
>use CGI qw(:standard);
>
This is the non-OO interface for CGI.pm.  
Replace this with use CGI; and you should be fine.

>my $cmod = new CgiMOD;
>my $q    = new CGI;
>
>print $q->header();

if you are using CGI qw(:standard) print header() is the correct form of
calling its functions

>print "test";
>
>my ($log, $lev) = $cmod->Read_Cookie();

Good luck


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

Date: Mon, 6 Aug 2001 08:37:51 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Save memory and measure used memory???
Message-Id: <9kll0v$1vmu$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Eric Bohlman
<ebohlman@omsdev.com>], who wrote in article <9kirtm$s0m$1@bob.news.rcn.net>:
> > or this:
> > $rules{'A MPN NP'} = 1;
> > $rules{'A MPN NP $.'} = 1;
> > $rules{'A MPN NP CARD $.'} = 1;
> 
> That's going to be rather awkward to work with; if you need something like 
> it, you might as well use an array rather than a hash.

Let me remind a handy syntax

  $rules{'A','MPN','NP'} = 1;

It is a pity it is not supported by the tied API (but see my RFC)...

Ilya


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

Date: Mon, 06 Aug 2001 04:40:34 -0500
From: "Christopher L. Everett" <ceverett@cobalt.physemp.com>
Subject: Re: Strange IE cookie behaviour
Message-Id: <3B6E6612.CD9C3203@cobalt.physemp.com>

Nevermind, 

I made a typical newbie mistake assuming IE had the correct 
time and date ... Argh!

  --Christopher


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

Date: Mon, 06 Aug 2001 11:16:44 GMT
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: string inside string
Message-Id: <w0vb7.15735$lB.3025510@afrodite.telenet-ops.be>

$F{'k1'}="hello";
$i=1;
print $F{'k$i'};

Is there a way so that $F{'k$i'} will display "hello" ?

Thanks,
Bart






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

Date: Mon, 06 Aug 2001 13:28:59 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: string inside string
Message-Id: <3B6E7F7B.3040205@post.rwth-aachen.de>

Bart Van der Donck wrote:

>$F{'k1'}="hello";
>$i=1;
>print $F{'k$i'};
>
>Is there a way so that $F{'k$i'} will display "hello" ?
>

Yes. You were using single quotes which will not expand a variable.
print $F{"k$i"};


Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};





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

Date: Mon, 06 Aug 2001 12:31:47 GMT
From: "fishy" <joerivdv007@hotmail.com>
Subject: substring matching 
Message-Id: <T6wb7.15846$lB.3063636@afrodite.telenet-ops.be>

Hiya,

I need to match a substring from a string which contains non-alphanumeric
characters and assing a variable to them or push them to a list. Here is
what I would like to do:

if(/alpha.*/) {$alpha = substr(/alpha.*/, 7, -3);
                     print "\tspelling=\"$alpha\"\n";}

OR
if (/alpha.*/) {push @alpha substr(/alpha.*/, 7, -3);
                     print "\tspelling=\"@alpha\"\n";}

The normal string that contains 'alpha' looks like this:
alpha('verb'),

The above expressions work when the string only contains the
characters[a-zA-Z]. I have tried to delete the "(" and "'" , but that causes
problems further in the code.

The problem with the above statements is that they do not return anything.
If I state $alpha = substr(alpha, 0, 4); then I get the expected return.

I will post here a piece of the input file and what I want as output, to
make clear what I want.

v(60,'aanbranden',

[ex('L/ de aardappelen zijn aangebrand'),

tr([attacher,coller,bru^ler]),

p(p0,['_t','er..er
zoveel','hoeveel..er','hij','ze','wat','die','diedaar','dat']),

p(reform,['perfectum zijn']),

restr_lex(p0,['voedsel']),

parts(aan,branden),

alpha('aanbranden'),

prefix_cat(voorz),

root(v),

separable,

uitdr('gauw aangebrand zijn')]).

Here is what I want:

<Item name="aaien", (#whatever stands between brackets and single quotes
behind "alpha.*")

            sample-sentence="(whatever is behind "[ex('L/"  )",

            French="(whatever stands behind "tr(["  )",

            subjects='(whatever stands behind "p(p0,"  )",

            restr_lex="(whatever stands behind "restr_lex("  )",

            parts="(whatever stands behind "parts(" )",

            expression="(whatever is behind "uitdr('  )"

/>

Thanks for the help.

J.





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

Date: Sun, 5 Aug 2001 22:12:08 +0200
From: "Axel Weiß" <axel.dieter.weiss@t-online.de>
Subject: Translate VB-Script into Perl
Message-Id: <9klkcu$8s1$05$1@news.t-online.com>

I've to write a perl-programm that install printer on a W2K-Printserver. I
use from the ResourceKit the PRNADMIN.DLL. There are a sample sourcecode
(VisualBasic-Script) in the Doku to check the installed Printerdriver. I
don't know how to translate this to perl, special the marked line.

dim oMaster
dim oDriver
Rem creating the PrintMaster object
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
Rem the property that enumerates drivers take an optional parameter for
server name
Rem if it is missing, the drivers on the local computer will be enumerated
for each oDriver in oMaster.Drivers("\\Servername")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Rem get the driver name
wscript.echo "DriverName    : " & oDriver.ModelName
Rem get a number as driver version
wscript.echo "Version       : " & oDriver.Version
Rem get a string description of the driver. Ex "Windows 2000"
        wscript.echo "DriverVersion : " & oDriver.DriverVersion
Rem get the path where the files are
       wscript.echo "DriverPath    : " & oDriver.Path
Rem environment of the driver ex: Windows NT x86
        wscript.echo "Environment   : " & oDriver.Environment
Rem architecture of the driver, ex Intel
        wscript.echo "DriverEnv     : " & oDriver.DriverArchitecture
 Rem monitor name, if any
        wscript.echo "MonitorName   : " & oDriver.MonitorName
next

Thanks Axel




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

Date: Mon, 06 Aug 2001 00:21:11 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: Uploading files to a sever.
Message-Id: <3B6E4567.AAD4C65E@wgn.net>

Just Some Guy wrote:
> 
> Hi,
> 
> I am hoping that somebody can help me. I am using perl to do cgi scripting
> and I would like to find a tutorial explaning the basic of uploading a file
> onto the server from a client webbrowser.

You'll find an example of an upload script on my Webjump site.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


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

Date: 6 Aug 2001 03:31:05 -0700
From: gehart24@yahoo.com (george hart)
Subject: Re: Uploading files to a sever.
Message-Id: <c490a7ae.0108060231.75fb80b0@posting.google.com>

seeing the examples at http://cgi-lib.berkeley.edu/  for file
uploading should start you in the right direction.


George Hart

"Just Some Guy" <one@two.com> wrote in message news:<9klf67$98a$1@mosquito.HL.Siemens.DE>...
> Hi,
> 
> I am hoping that somebody can help me. I am using perl to do cgi scripting
> and I would like to find a tutorial explaning the basic of uploading a file
> onto the server from a client webbrowser.
> 
> Any help would be appreciated.
> 
> Thanx in advance,
> me, myself and I


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

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


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