[15556] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2969 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 7 00:05:41 2000

Date: Sat, 6 May 2000 21:05:10 -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: <957672310-v9-i2969@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 6 May 2000     Volume: 9 Number: 2969

Today's topics:
    Re: @array holding %hash <lr@hpl.hp.com>
    Re: @array holding %hash <nospam@devnull.com>
    Re: @array holding %hash (brian d foy)
    Re: Clinet/Server and inetd <gellyfish@gellyfish.com>
        converting input to <p></p> pairs via perl <nospam@devnull.com>
    Re: converting input to <p></p> pairs via perl <nospam@devnull.com>
    Re: converting input to <p></p> pairs via perl (brian d foy)
        File Locking? <grichards@flashcom.net>
    Re: File Locking? <rootbeer@redcat.com>
    Re: File Locking? <nospam@devnull.com>
    Re: Flame my code <lr@hpl.hp.com>
    Re: Help! Which disrtibution should I get? <gellyfish@gellyfish.com>
        how to link my dinamic result html page into home page. <yoonjung@cs.tamu.edu>
        how to rx and tx thru a remote socket k_ahg@my-deja.com
    Re: how to rx and tx thru a remote socket <rootbeer@redcat.com>
    Re: How to tell if <> operator will work on a given sca <Tbone@pimpdaddy.com>
    Re: How to tell if <> operator will work on a given sca (Ilya Zakharevich)
    Re: How to tell if <> operator will work on a given sca <Tbone@pimpdaddy.com>
        How to use Perl script in Windows Logon  <pangjo@hotmail.com>
        More CPerl-mode problems under NT <aperrin@davis.DEMOG.Berkeley.EDU>
    Re: More CPerl-mode problems under NT <rootbeer@redcat.com>
    Re: More CPerl-mode problems under NT (Ilya Zakharevich)
    Re: Parallel port (David Efflandt)
        Posting to News <osca003@attglobal.net>
    Re: Posting to News <rootbeer@redcat.com>
    Re: Quality of perl implementations (Was: Re: if file a <lr@hpl.hp.com>
    Re: search.bat - errors on Win32 (Steve A. Taylor)
    Re: search.bat - errors on Win32 (Steve A. Taylor)
        sorting hashes by value rather than by key in a foreach <nospam@devnull.com>
    Re: sorting hashes by value rather than by key in a for <nospam@devnull.com>
    Re: sorting hashes by value rather than by key in a for <lr@hpl.hp.com>
    Re: sorting hashes by value rather than by key in a for <rootbeer@redcat.com>
    Re: Why are files required to return true values? (brian d foy)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 6 May 2000 18:31:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: @array holding %hash
Message-Id: <MPG.137e675f184f4fdd98aa1b@nntp.hpl.hp.com>

In article <qcm8hs8pj3gt1p2t3sldi5cmdd7v5lbhui@4ax.com> on Sat, 06 May 
2000 20:27:31 +0200, Abe Timmerman <abe@ztreet.demon.nl> says...
+ On Sat, 6 May 2000 09:57:01 -0700, Larry Rosler <lr@hpl.hp.com> wrote:

 ...

+ >                                         It is better to create a 
+ > reference to an anonymous hash instead:
+ > 
+ >   push @array, { %table };
+ 
+ I find this interesting, a few weeks ago I said in a similar post:
+ > > 	$All{classC} = \@tt;
+ > This is OK if you only do this once (and never alter @tt). Better to
+ > use:
+ > 	$All{classC} = [ @tt ];
+ 
+ You replied:
+ 	In real life, it would be done in a loop, in which case every
+ 	execution of the 'my @tt;' declaration would allocate new 
+ 	storage.  So copying the array into another anonymous array 
+ 	would be wasted effort.
+ 
+ I understand what you say here, and I can't argue with that.
+ My point was indeed to bring the scope of @tt to attention.
+ 
+ perldsc says:
+     In summary:
+ 
+         $AoA[$i] = [ @array ]; # usually best
+         $AoA[$i] = \@array;    # perilous; just how my() was that 
array?
+         @{ $AoA[$i] } = @array; # way too tricky for most programmers
+ 
+ 
+ As I do take your advice serious, I am a bit puzzled.
+ Is this a style issue?

I'm not sure I understand your question.  My only point in *this* post 
was to correct the questioner's use of [ %hash ] to { %hash }.

If one were sure that the value of %hash would not be overwritten 
inadvertantly, one could use \%hash.  Declaring the hash in a loop using 
'my %hash;' guarantees new storage, so one could and should use \%hash 
without creating an unnecessary copy.

It is a question of reliability and efficiency, not a question of style.
  
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com 


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

Date: 7 May 2000 02:02:37 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: @array holding %hash
Message-Id: <8f2irt$qmo$1@216.155.33.54>

In article <MPG.137e675f184f4fdd98aa1b@nntp.hpl.hp.com>, Larry Rosler 
<lr@hpl.hp.com> wrote:

I'm just curious, being a *gag choke* newbie to some pf the more elegant 
ways that perl works. what is so 'tricky' about 

 | +         @{ $AoA[$i] } = @array; # way too tricky for most programmers

and how and when would I use such a construct? 

y'see I LIKE elegant tricky solutions to things :D

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Sat, 06 May 2000 23:07:06 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: @array holding %hash
Message-Id: <brian-0605002307060001@75.providence-05-10rs.ri.dial-access.att.net>

In article <8f2irt$qmo$1@216.155.33.54>, The WebDragon <nospam@devnull.com> wrote:

>In article <MPG.137e675f184f4fdd98aa1b@nntp.hpl.hp.com>, Larry Rosler 
><lr@hpl.hp.com> wrote:
>
>I'm just curious, being a *gag choke* newbie to some pf the more elegant 
>ways that perl works. what is so 'tricky' about 
>
> | +         @{ $AoA[$i] } = @array; # way too tricky for most programmers
>
>and how and when would I use such a construct? 

   it's probably better just to write

      $array[$i] = \@array;

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: 6 May 2000 22:57:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Clinet/Server and inetd
Message-Id: <8f24fl$lg2$1@orpheus.gellyfish.com>

On Sat, 06 May 2000 14:55:25 GMT Thomas Åhlen" wrote:
> Hi!
> 
> My perl server take advantage of inetd handling socket connections.
> 
> Q: What is the best way to get ip's of clients connecting to my server?
> 
> Since i only got STDIN, STDOUT, STDERR to play with and i need the socket
> 

You can treat STDIN as if were a socket.

/J\
-- 
Whenever Marge turns on one of her non-violent programs, I take a walk. I
go to a bar, I pound a few, then I stumble home in the mood for looooove.
-- 
fortune oscar homer


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

Date: 6 May 2000 23:35:10 GMT
From: The WebDragon <nospam@devnull.com>
Subject: converting input to <p></p> pairs via perl
Message-Id: <8f2a7e$cvg$0@216.155.33.54>

Larry, thanks again for the help with this, but after some further 
testing, I can see that the output isn't exactly what I had in mind.. 

given default review text of 

$reviewText = <<'EOM';
Enter your comments separated by double-returns like normal paragraphs.

If you want lines to break
like this, then enter it that way.

The parser will automatically produce the correct paragraph and 
linebreak tags so please DO NOT enter them on your own... they'll get 
removed =)

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam 
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation 
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse 
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero 
eros et accumsan et iusto odio dignissim qui blandit praesent luptatum 
zzril delenit augue duis dolore te feugait nulla facilisi.
EOM


and the script snippet: 
-=-
use CGI::Pretty; 
my(@reviewText, $reviewBody)
  {
    local $/ = ""; # Set 'paragraph mode' -- see perlvar.
    @reviewText = map { chomp; "<p>$_</p>\n" } param('reviewtext');
   }
foreach (@reviewText) { s/\n/<br>\n/g };
foreach (@reviewText) { $reviewBody .= shift(@reviewText) };
-=-

results: 
-=-
<p>Enter your comments separated by double-returns like normal 
paragraphs. <br>
<br>
If you want lines to break <br>
like this, then enter it that way. <br>
<br>
The parser will automatically produce the correct paragraph and 
linebreak tags so please DO NOT enter them on your own... they'll get 
removed =)<br>
<br>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam 
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation 
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse 
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero 
eros et accumsan et iusto odio dignissim qui blandit praesent luptatum 
zzril delenit augue duis dolore te feugait nulla facilisi.<br>
</p><br>
-=-
I don't know what character the '' is. 

obviously not exactly what I wanted.. 

preferred output would be: 
-=-
<p>Enter your comments separated by double-returns like normal 
paragraphs.</p>

<p>If you want lines to break<br>
like this, then enter it that way.</p>

<p>The parser will automatically produce the correct paragraph and 
linebreak tags so please DO NOT enter them on your own... they'll get 
removed =)</p>

<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam 
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation 
ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse 
molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero 
eros et accumsan et iusto odio dignissim qui blandit praesent luptatum 
zzril delenit augue duis dolore te feugait nulla facilisi.</p>

-=-

Any ideas on how I can accomplish what I want? 

also important is to make sure that the last paragraph has a closing 
</P> at the end..

this text will eventually be input from a TEXTAREA field in a 
cgi-generated html form, but the perlish problem still remains, hence my 
posting it here, rather than over there.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 7 May 2000 02:09:15 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: converting input to <p></p> pairs via perl
Message-Id: <8f2j8b$qmo$2@216.155.33.54>

In article <8f2a7e$cvg$0@216.155.33.54>, The WebDragon 
<nospam@devnull.com> wrote:

 | preferred output would be: 
 | -=-
 | <p>Enter your comments separated by double-returns like normal 
 | paragraphs.</p>
 | 
 | <p>If you want lines to break<br>
 | like this, then enter it that way.</p>
 | 
 | <p>The parser will automatically produce the correct paragraph and 
 | linebreak tags so please DO NOT enter them on your own... they'll get 
 | removed =)</p>
 | 
 | <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam 
 | nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat 
 | volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation 
 | ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 
 | Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse 
 | molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero 
 | eros et accumsan et iusto odio dignissim qui blandit praesent luptatum 
 | zzril delenit augue duis dolore te feugait nulla facilisi.</p>
 | 
 | -=-
 | 
 | Any ideas on how I can accomplish what I want? 
 | 
 | also important is to make sure that the last paragraph has a closing 
 | </P> at the end..
 | 
 | this text will eventually be input from a TEXTAREA field in a 
 | cgi-generated html form, but the perlish problem still remains, hence my 
 | posting it here, rather than over there.

breaking this down into a two-pass procedure, what I can derive that I 
need to do is this: 

first search for every \n that is not also followed by another \n, and 
replace it with <br>

then for every chunk of data terminated with \n\n, surround the chunk 
with <p></p> and put the \n\n after the </p>

if the last chunk of data has no \n\n after it, or has a <br> at the end 
(from the first pass), be sure to also wrap it in a <p></p> pair and 
REMOVE the terminating <br>, adding back a \n\n after the final </p>

if that looks correct mostly, how would I write sugh beasts using 
regexps? Anyone? 

(man, I GOTTA get that O'Reilly book everyone keeps mentioning)

Thanks for any followup assistance .

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Sat, 06 May 2000 23:11:25 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: converting input to <p></p> pairs via perl
Message-Id: <brian-0605002311250001@75.providence-05-10rs.ri.dial-access.att.net>

In article <8f2j8b$qmo$2@216.155.33.54>, The WebDragon <nospam@devnull.com> wrote:

>breaking this down into a two-pass procedure, what I can derive that I 
>need to do is this: 

>first search for every \n that is not also followed by another \n, and 
>replace it with <br>

>then for every chunk of data terminated with \n\n, surround the chunk 
>with <p></p> and put the \n\n after the </p>

>if the last chunk of data has no \n\n after it, or has a <br> at the end 
>(from the first pass), be sure to also wrap it in a <p></p> pair and 
>REMOVE the terminating <br>, adding back a \n\n after the final </p>

>if that looks correct mostly, how would I write sugh beasts using 
>regexps? Anyone? 

this seems like a rather complicated way of doing this.  it's much
easier to:

   $/ = "\n\n";

   while( <> )
      {
      print "<p>$_</p>";
      }

if all of this is wrapped in <p> tags, then there is no need for
the <br> tags.  if there are going to be <br> tags everywhere, why
use <p>? ;)

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Sat, 6 May 2000 17:50:56 -0700
From: "Gabe" <grichards@flashcom.net>
Subject: File Locking?
Message-Id: <sh9fajv4qil77@corp.supernews.com>

A CGI script opens up a text database and writes to it.

What happens if that script is executed simultaneously by two separate
users? Do I have a problem? Will the data get mangled? Do I need to look
into some sort of file locking module? Where can I find information about
this issue? A perldoc reference would be fine.

Thanks!
Gabe




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

Date: Sat, 6 May 2000 18:05:19 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: File Locking?
Message-Id: <Pine.GSO.4.10.10005061804590.6766-100000@user2.teleport.com>

On Sat, 6 May 2000, Gabe wrote:

> What happens if that script is executed simultaneously by two separate
> users? Do I have a problem? Will the data get mangled? Do I need to look
> into some sort of file locking module? Where can I find information about
> this issue? 

I think you could use the methods in Randal's fourth Web Techniques
column, which explains how to use flock() to avoid problems when multiple
processes need to modify one file. Hope this helps! 

   http://www.stonehenge.com/merlyn/WebTechniques/

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 7 May 2000 01:54:44 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: File Locking?
Message-Id: <8f2id4$qmo$0@216.155.33.54>

In article <sh9fajv4qil77@corp.supernews.com>, "Gabe" 
<grichards@flashcom.net> wrote:

 | A CGI script opens up a text database and writes to it.
 | 
 | What happens if that script is executed simultaneously by two separate
 | users? Do I have a problem? Will the data get mangled? Do I need to look
 | into some sort of file locking module? Where can I find information about
 | this issue? A perldoc reference would be fine.
 

flock()

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Sat, 6 May 2000 18:18:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Flame my code
Message-Id: <MPG.137e64478a2d16ef98aa18@nntp.hpl.hp.com>

In article <5zYQ4.271$c71.1009@saturn.ipass.net> on Sat, 6 May 2000 
13:24:18 -0400, E. Preble <preble@ipass.net> says...
> I have a code snippet below.  Can it be better? (of course
> it can)

It can be enormously better.

> purpose:
> Search a list of names in a array and create a new array
> with unique names only.
> For Example, if the array is:
> file1.txt
> file2.txt
> file2.txt
> file3.txt
> file2.txt
> 
> The new array will have:
> file1.txt
> file2.txt
> file3.txt
> 
> with NO duplicate entries of file2.txt. Here's my code
> (written in PerlAmateur v1.0):
> 
> foreach $FileName (@File) {
>   $found = 0;
>   foreach $Entry (@ListOfFileNames) {
>    if ($FileName eq $Entry) {
>     $found=1;

A 'last;' statement here would improve this code.

>    }
>   }
>   if ($found == 0) {
>    @ListOfFileNames = (@ListOfFileNames, "$FileName");

A push() call here would improve this code.

>   }
> }

Nevertheless, that code should be canned completely.  That is called an 
O(N * 2) algorithm, because its running time is proportional to the 
square of the number of elements in the array.  When this is large, the 
running time can be enormous.

What you want are algorithms that are O(N).  You can find some in the 
voluminous Perl FAQ.

Type this at the command line:

perldoc -q duplicate

and you will come immediately on this entry in perlfaq4: "How can I 
remove duplicate elements from a list or array?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 7 May 2000 00:04:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help! Which disrtibution should I get?
Message-Id: <8f28de$29m$1@orpheus.gellyfish.com>

On Sun, 07 May 2000 00:19:26 +0800 Preston wrote:
> I'm a beginner to perl.
> I'm intended to write perl scripts to be run on Debian Linux Server.
> However, my system is Win98. I see on activestate.com that there are two
> binary distribution (one for Win9X, one for Debian Linux).

The 'Debian Linux Server' almost certainly has Perl installed on it.  If
you want to run Perl programs on your windows machine you will need to
get the appropriate one.  If for some reason you dont have Perl installed
on your Linux machine you would be far better compiling it from the source
anyhow rather than installing a precompiled binary (mostly people do the
latter only when they have no choice)

> do perl scripts writen in perl for win32 work in debian linux server?

What Larry Said.

/J\
-- 
This perpetual motion machine she made is a joke: It just keeps going
faster and faster. Lisa, get in here! In this house, we obey the laws
of THERMODYNAMICS!
-- 
fortune oscar homer


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

Date: Sat, 6 May 2000 22:05:48 -0500
From: "yoon" <yoonjung@cs.tamu.edu>
Subject: how to link my dinamic result html page into home page.
Message-Id: <8f2m3c$rg4$1@news.tamu.edu>

My simple perl script is just "to read file of specified directory and make
hyperlink with file name " so that user clicks link and download file.

What I want to do is that user see this dynamic html (because it will
generate the different hyperlink whenever the directory name is changed).

FORM which links my script  without "INPUT" didn't work

How can I make my html so that user can be connected to  this dinamic page
(the result of script)?

$path = "/pub/web-faculty/proj619/html/SPIS/assignments/";
opendir(BASE,$path);
@names = readdir(BASE);
closedir(BASE);
print "Content-type:text/html\n\n";
$script = "http://csweb2.xxx.yyy:8000;

$dir_url = "web-faculty/proj619/html/SPIS/assignments";

foreach $name (@names) {
        $string = "$script/$dir_url/$name";
        print "$string,$name\n";
        print "<a href=\"$string\">$name</a>\n";
}

Thanks!







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

Date: Sun, 07 May 2000 02:25:54 GMT
From: k_ahg@my-deja.com
Subject: how to rx and tx thru a remote socket
Message-Id: <8f2k76$3qm$1@nnrp1.deja.com>

hi,

   I'm currently using perl version : 5.004_04 in Unix to write a
program to receive and send files thru a socket. But I'm not so sure how
to send and receive my data. Can any one help me on this?
 Below is part of the program:


 #!/usr/bin/perl -w

 use IO::Socket;

 $remote = IO::Socket::INET ->new ( Proto => 'tcp',
                                   PeerAddr
=>'xxx.xxx.xx.xx',                                   PeerPort
=>'telnet(23)',
                                   Reuse =>  1);
 unless ($remote) {die " cannot connect"}
 $remote->autoflush(1);
   print $remote "UserID\r\n";
   print $remote "PassWD\r\n";
   while (<$remote>) {
     print $_;
     print $remote "ls,a\r\n";
     #print $remote "logout\r\n";
     }
 close $remote;



 thanx.


 Ken



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 6 May 2000 19:54:49 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: how to rx and tx thru a remote socket
Message-Id: <Pine.GSO.4.10.10005061953350.3921-100000@user2.teleport.com>

On Sun, 7 May 2000 k_ahg@my-deja.com wrote:

> Subject: how to rx and tx thru a remote socket

>  $remote = IO::Socket::INET ->new ( Proto => 'tcp',
>                                    PeerAddr
> =>'xxx.xxx.xx.xx',                                   PeerPort
> =>'telnet(23)',
>                                    Reuse =>  1);

It's not what you asked for, but does the Expect module perhaps provide an
easier way to do whatever you're trying to do? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 6 May 2000 22:35:28 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: How to tell if <> operator will work on a given scalar?
Message-Id: <8f26ng$2ok6$1@news.enteract.com>

ilya@math.ohio-state.edu writes:
>And check whether $foo overloads '<>'...

How does one overload <>?



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

Date: 7 May 2000 00:58:40 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How to tell if <> operator will work on a given scalar?
Message-Id: <8f2f40$3rd$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Intergalactic Denizen of Mystery 
<Tbone@pimpdaddy.com>],
who wrote in article <8f26ng$2ok6$1@news.enteract.com>:
> How does one overload <>?

???  The same way as with any other overload.  perldoc overload.

Ilya


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

Date: 7 May 2000 02:07:20 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: How to tell if <> operator will work on a given scalar?
Message-Id: <8f2j4o$avq$1@news.enteract.com>

ilya@math.ohio-state.edu writes:
>[A complimentary Cc of this posting was sent to Intergalactic Denizen of Mystery 
><Tbone@pimpdaddy.com>],
>who wrote in article <8f26ng$2ok6$1@news.enteract.com>:
>> How does one overload <>?
>
>???  The same way as with any other overload.  perldoc overload.

Looks like I wasn't in tune with the zeitgeist... I have found it
now, thanks.



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

Date: Sat, 6 May 2000 22:21:04 -0400
From: "JP" <pangjo@hotmail.com>
Subject: How to use Perl script in Windows Logon 
Message-Id: <8i4R4.37102$Xk2.135118@tor-nn1.netcom.ca>

I am trying to put a logon script into the NT Netlogon share so that users
have to run the script during a login.  The script is called by a batch file
and the domain controllers are all installed with Perl.

The problem I have is that the script keeps complaining that the dynamic
library PerlCRT.dll cannot be located. There is no Perl installed on the
client.  But I can run the script if I log on to the server.

How can I have the logon script runs probably when the client log on from a
workstation?

TIA.






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

Date: 06 May 2000 18:21:54 -0700
From: Andrew Perrin - Demography <aperrin@davis.DEMOG.Berkeley.EDU>
Subject: More CPerl-mode problems under NT
Message-Id: <u5kitwr5f4d.fsf@davis.DEMOG.Berkeley.EDU>

Folks - any ideas here?

I'm using cperl-mode under gnu emacs for NT; versions are now emacs
20.6.1 and cperl-mode 4.27, both downloaded today.  The same behavior
happened with previous versions.

The problem is that commonly, when I begin a new line by typing the
characters m or s (possibly others, but these are the ones I've
noticed because they begin 'my' and 'sub', respectively), cperl syntax
coloring turns off, and the following message appears in the buffer:

Invalid search bound (wrong side of point)

This behavior is reproducible under the following condition:

1. Type a shebang in the first line of the buffer:
#!/usr/local/bin/perl -2

2. Insert several (at least three) blank lines below the shebang.

3. Move up (at least) two lines.

4. Begin typing either 'my $foo' or 'sub foo'.

Any advice will be appreciated.

-- 
---------------------------------------------------------------------
Andrew J. Perrin - aperrin@demog.berkeley.edu - NT/Unix Admin/Support
Department of Demography    -    University of California at Berkeley
2232 Piedmont Avenue #2120  -    Berkeley, California, 94720-2120 USA
http://demog.berkeley.edu/~aperrin --------------------------SEIU1199


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

Date: Sat, 6 May 2000 18:31:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: More CPerl-mode problems under NT
Message-Id: <Pine.GSO.4.10.10005061830110.3921-100000@user2.teleport.com>

On 6 May 2000, Andrew Perrin - Demography wrote:

> The problem is that commonly, when I begin a new line by typing the
> characters m or s (possibly others, but these are the ones I've
> noticed because they begin 'my' and 'sub', respectively), 

I don't have a solution, but I'd guess that they're trying to be m// and
s/// - do you also notice this with the letter y? If so, maybe that's a
clue about where to look in the code to see what to fix.

> Any advice will be appreciated.

Turn off syntax coloring. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 7 May 2000 03:47:13 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: More CPerl-mode problems under NT
Message-Id: <8f2p01$6v9$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Andrew Perrin - Demography 
<aperrin@davis.DEMOG.Berkeley.EDU>],
who wrote in article <u5kitwr5f4d.fsf@davis.DEMOG.Berkeley.EDU>:

Btw, 4.28 is out.

> 1. Type a shebang in the first line of the buffer:
> #!/usr/local/bin/perl -2
> 
> 2. Insert several (at least three) blank lines below the shebang.
> 
> 3. Move up (at least) two lines.
> 
> 4. Begin typing either 'my $foo' or 'sub foo'.

Thanks, I can reproduce it.  [Sound of deleting 4.28...]

Ilya


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

Date: 6 May 2000 22:06:31 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Parallel port
Message-Id: <slrn8h95s0.o8.efflandt@efflandt.xnet.com>

On Sat, 6 May 2000, Christian Goebel <christian.goebel@luxmail.lu> wrote:
>Hi,
>how I can send a byte to the parallel port (linux,apache)?
>Can you give me an example?
>best regards,
>
>Christian

open(LP,"> /dev/lp0") || die "Can't write lp0: $!";
select LP; $| = 1; select STDOUT;
print LP "a";
close LP;

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sat, 06 May 2000 23:18:58 -0500
From: Oscar Rau <osca003@attglobal.net>
Subject: Posting to News
Message-Id: <3914EEB1.A10B0186@attglobal.net>

I have been advised not to do cross posting in newsgroups. I believe it
is the
etiquette.

There are times when I have to post some error messages or compilation
messages
to different newgroups. If I write up a file explaining the problem, how
can I post it
from command line to my ISP's newserver. TRN and TIN type application
are as
slow as GUI based news readers. Is there any script that will allow me
to post
from the command line on Linux?

Thanks for any help.

Oscar Rau
osca003@attglobal.net



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

Date: Sat, 6 May 2000 20:38:09 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Posting to News
Message-Id: <Pine.GSO.4.10.10005062029500.3921-100000@user2.teleport.com>

On Sat, 6 May 2000, Oscar Rau wrote:

> I have been advised not to do cross posting in newsgroups. I believe
> it is the etiquette.

Perhaps someone has misinformed you. If something is on-topic to two or
three newsgroups (rarely four or five), rather than make separate
postings, you should cross-post. Generally, you should also set follow-ups
to appear in the most on-topic group. See the posting "Rules for posting
to Usenet" which appears regularly in news.announce.newusers for more
information on cross-posting.

> If I write up a file explaining the problem, how can I post it from
> command line to my ISP's newservers. 

Use a suitable news client; your local expert can probably recommend one.
Or you could write your own with Net::NNTP.

> TRN and TIN type application are as slow as GUI based news readers.

Chances are, at least some of the slowness you're seeing is your NNTP
server. So anything else might be just about as slow. But I don't use TRN
and TIN, so I can't say.

> Is there any script that will allow me to post from the command line
> on Linux?

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 6 May 2000 17:36:25 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Quality of perl implementations (Was: Re: if file already exists then remove...)
Message-Id: <MPG.137e5a5744f6439f98aa17@nntp.hpl.hp.com>

In article <htp-6B969B.06332407052000@news.metropolis.net.au> on Sun, 07 
May 2000 06:33:24 +0930, Henry <htp@mac.com> says...
> In article <MPG.137cc17b59c765498aa08@nntp.hpl.hp.com>, Larry Rosler 
> <lr@hpl.hp.com> wrote:
> 
> > > Look, don't get me wrong, I think Perl's great.  It forgives me when I 
> > > make mistakes, and I forgive it when it makes mistakes.  That makes for 
> > > a very warm and fuzzy relationship.  Tolerance is, however, not a trait 
> > > of mission-critical programming languages (and compilers) - they are 
> > > cold, prickly, but can be relied upon when the <objectionable object> 
> > > hits the fan.
> ...
> > I am troubled by your laissez-faire attitude with regard to perl.  
> 
> ???  My dictionary (getting a lot of use lately, it seems) defines 
> laissez-faire as a government policy of non-interference.  Given that 
> definition, I'm not sure I understand the above sentence.  Sorry.

http://www.m-w.com/

Main Entry: lais·sez-faire
        Pronunciation: "le-"sA-'far, "lA-, -"zA-, -'fer
        Function: noun
        Etymology: French laissez faire, imperative of
                   laisser faire to let (people) do (as they choose)
        Date: 1825
        1 : a doctrine opposing governmental interference in economic
            affairs beyond the minimum necessary for the maintenance of
            peace and property rights
        2 : a philosophy or practice characterized by a usually
            deliberate abstention from direction or interference
            especially with individual freedom of choice and action
      - laissez-faire adjective 

I am troubled by your philosophy of abstention from directing the 
attention of Perl implementors toward reliability as opposed to new 
features.  

> > Should encouraging willing contributors to invest more time on quality 
> > of implementation become a higher priority than continually adding 
> > features?
> 
> I don't think so.  If someone needs mission-critical code, they already 
> have plenty of languages and compilers to choose from that will give it 
> to them.  I don't think we need another one.
> 
> Perl has snuggled into its Swiss-army-knife role admirably.  Flexibility 
> is the prime attribute for such tools, and they are vastly more useful 
> for the average camper, casually exploring the great unknown.
> 
> I consider myself to be a somewhat average camper, and Perl (as it is) 
> suits me to a tee.  I'd rather see people push the limits of what Perl 
> can do, and not get bogged down benchmarking how well it does them.
> 
> Four-wheel drives do not race Formula 1 for precisely the same reason, 
> yet they still have a role to play.

I said nothing about performance.  I would rather have a Swiss-army 
knife with fewer blades, if they could be relied on not to break and 
lacerate my fingers.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sun, 07 May 2000 00:17:02 GMT
From: an400@freenet.carleton.ca (Steve A. Taylor)
Subject: Re: search.bat - errors on Win32
Message-Id: <3914b0ff.47787021@news.ncf.carleton.ca>

On Fri, 05 May 2000 11:45:36 +1000, Peter Hill <phill@modulus.com.au>
wrote:

>Steve A. Taylor wrote:
>> 
>> It's Jeff Friendl's search.bat script, but the most recent I've found
>> is 97-03-29.
>> When I run it on the command line with
>> search -i 'perl';
>> it returns an error message:
>> search.bat internal error: Bad name after perl' at (eval 5) line 260.
>> That line is
>>               push(@regex_tests, "m'$regex'$iflag$mflag");
>> Any explanation would be appreciated.
>>  He's making up a regex for a later eval().
>Assuming t ARGV values are going in as we see them (and 20 other
>assumptions), don't you end up with
>push(@regex_tests, "m''perl''");
>after interpolation, i.e. what happens when:
>- you omit the quoting around perl or
>- change line 260 to push(@regex_tests, "m/$regex/$iflag$mflag");

It's all the changes: (#'d lines are the old lines)

 $regex .= shift(@ARGV) . ' ' while @ARGV;
# $regex = shift(@ARGV); # ~ line 652, earlier

	     ($literal || $regex !~ m/[ ?*+{}()\\.|^\$[]/)) # space added
#temp	     ($literal || $regex !~ m/[?*+{}()\\.|^\$[]/))  # pre-line
709

	      push(@regex_tests, "(index(\$_, $regex)>=0)");
#712	      push(@regex_tests, "(index(\$_, q\001$regex\001)>=0)");

#740
          # remove ' around args unless midword
          @regex_tests = split(" ", $regex);
          for (@regex_tests) {
            s/^\s*\'//;
            s/\'\s*$//;
            # warn $_;
          }
          $regex = join ("|",@regex_tests) ;# if @regex_tests;
          @regex_tests = ();
          
#temp          
	      push(@regex_tests, "m", "$regex", "$iflag$mflag");
#	      push(@regex_tests, "m'$regex'$iflag$mflag");

    	  $REGEX_TEST = join('||', @regex_tests);
#temp, added at ll 775, this:
    	  $REGEX_TEST = join('/', @regex_tests) if $#regex_tests;


It takes too many changes; even this code could be tightened, I;m
sure. The root of my question: how did the original work. It's used
whether this is searched with index() or m/// -- except it crashes.



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

Date: Sun, 07 May 2000 00:59:25 GMT
From: an400@freenet.carleton.ca (Steve A. Taylor)
Subject: Re: search.bat - errors on Win32
Message-Id: <3914bf6e.51482140@news.ncf.carleton.ca>

On Fri, 05 May 2000 11:45:36 +1000, Peter Hill <phill@modulus.com.au>
wrote:

>Steve A. Taylor wrote:
>> 
>> It's Jeff Friendl's search.bat script, but the most recent I've found
>> is 97-03-29.
>> When I run it on the command line with
>> search -i 'perl';
>> it returns an error message:
>> search.bat internal error: Bad name after perl' at (eval 5) line 260.
>> That line is
>>               push(@regex_tests, "m'$regex'$iflag$mflag");
>> Any explanation would be appreciated.
>>  He's making up a regex for a later eval().
>Assuming t ARGV values are going in as we see them (and 20 other
>assumptions), don't you end up with
>push(@regex_tests, "m''perl''");
>after interpolation, i.e. what happens when:
>- you omit the quoting around perl or
>- change line 260 to push(@regex_tests, "m/$regex/$iflag$mflag");

It's all the changes: (#'d lines are the old lines)

 $regex .= shift(@ARGV) . ' ' while @ARGV;
# $regex = shift(@ARGV); # ~ line 652, earlier

	     ($literal || $regex !~ m/[ ?*+{}()\\.|^\$[]/)) # space added
#temp	     ($literal || $regex !~ m/[?*+{}()\\.|^\$[]/))  # pre-line
709

	      push(@regex_tests, "(index(\$_, $regex)>=0)");
#712	      push(@regex_tests, "(index(\$_, q\001$regex\001)>=0)");

#740
          # remove ' around args unless midword
          @regex_tests = split(" ", $regex);
          for (@regex_tests) {
            s/^\s*\'//;
            s/\'\s*$//;
            # warn $_;
          }
          $regex = join ("|",@regex_tests) ;# if @regex_tests;
          @regex_tests = ();
          
#temp          
	      push(@regex_tests, "m", "$regex", "$iflag$mflag");
#	      push(@regex_tests, "m'$regex'$iflag$mflag");

    	  $REGEX_TEST = join('||', @regex_tests);
#temp, added at ll 775, this:
    	  $REGEX_TEST = join('/', @regex_tests) if $#regex_tests;


It takes too many changes; even this code could be tightened, I;m
sure. The root of my question: how did the original work. It's used
whether this is searched with index() or m/// -- except it crashes.

If you want a slightly more coherent picture, the whole file, three
others are at <<http://steptayl.vr9.com/search.zip. No the code is not
final, most of it is J. Friedl's and very useful. Enjoy!


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

Date: 7 May 2000 02:15:46 GMT
From: The WebDragon <nospam@devnull.com>
Subject: sorting hashes by value rather than by key in a foreach loop
Message-Id: <8f2jki$qmo$3@216.155.33.54>

right now I have 

my %gameplayMult = (
    fun  => '0.35', 
    play => '0.2', 
    bots => '0.2', 
    flow => '0.15', 
    weap => '0.1',
); 

and it's pretty easy to 

foreach my $keys (sort(keys %gamePlayMult)) {
    # do something
}

but if I wanted to still use the keys, but sort by the VALUE of that key 
for %gamePlayMult, how would I write this? 

for some (perlish) reason the hash doesn't retain the original sorting, 
so 
    foreach my $keys (keys %gamePlayMult) { 
doesn't work for me.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 7 May 2000 02:43:24 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: sorting hashes by value rather than by key in a foreach loop
Message-Id: <8f2l8c$vab$0@216.155.33.54>

In article <8f2jki$qmo$3@216.155.33.54>, The WebDragon 
<nospam@devnull.com> wrote:

 | right now I have 
 | 
 | my %gameplayMult = (
 |     fun  => '0.35', 
 |     play => '0.2', 
 |     bots => '0.2', 
 |     flow => '0.15', 
 |     weap => '0.1',
 | ); 
 | 
 | and it's pretty easy to 
 | 
 | foreach my $keys (sort(keys %gamePlayMult)) {
 |     # do something
 | }
 | 
 | but if I wanted to still use the keys, but sort by the VALUE of that key 
 | for %gamePlayMult, how would I write this? 
 | 
 | for some (perlish) reason the hash doesn't retain the original sorting, 
 | so 
 |     foreach my $keys (keys %gamePlayMult) { 
 | doesn't work for me.

ok so I found something resembling an answer in perlfaq4, HOWEVER, it 
doesn't work ..

use strict is in effect, and my(@Gkeys) is defined at the top, in 
addition to the namesList hash

my %namesList = (
    fun => "Fun Factor", 
    play => "Playability", 
    bots => "Bots", 
    flow => "Flow", 
    weap => "Items", 
    theme => "Theme", 
    arch => "Architecture", 
    light => "Lighting", 
    textu => "Textures", 
    sound => "Sound"  
);

    @Gkeys = sort {
                $scoresG{$a} <=> $scoresG{$b}
                          ||
                length($namesList{$a}) <=> length($namesList{$b})
                          ||
                $namesList{$a} cmp $namesList{$b}
    } keys %scoresG;

all I wind up with is tons of this: 

Diagnostic Output

# [Sat May  6 22:28:24 2000] Dev:Pseudo: # Use of uninitialized value.
[Sat May  6 22:28:24 2000] Dev:Pseudo: File 'Primus 8.5GB:Web 
Pages:cgi-scripts:ncrp:nctest4.acgi'; Line 249
# [Sat May  6 22:28:24 2000] Dev:Pseudo: # Use of uninitialized value.
[Sat May  6 22:28:24 2000] Dev:Pseudo: File 'Primus 8.5GB:Web 
Pages:cgi-scripts:ncrp:nctest4.acgi'; Line 249
# [Sat May  6 22:28:24 2000] Dev:Pseudo: # Use of uninitialized value.
[Sat May  6 22:28:24 2000] Dev:Pseudo: File 'Primus 8.5GB:Web 
Pages:cgi-scripts:ncrp:nctest4.acgi'; Line 249
# [Sat May  6 22:28:24 2000] Dev:Pseudo: # Use of uninitialized value.

I looked up the error in the docs but I guess my newbieness is eluding 
me, because I can't figure out what I'm doing wrong, unless $a and $b 
aren't the REAL values that sort expects to see. (and if that's the case 
why is the faq written that way?)

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Sat, 6 May 2000 19:41:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: sorting hashes by value rather than by key in a foreach loop
Message-Id: <MPG.137e779a9c8a354598aa1c@nntp.hpl.hp.com>

In article <8f2jki$qmo$3@216.155.33.54> on 7 May 2000 02:15:46 GMT, The 
WebDragon <nospam@devnull.com> says...

 ...

> but if I wanted to still use the keys, but sort by the VALUE of that key 
> for %gamePlayMult, how would I write this? 

perlfaq4: "How do I sort a hash (optionally by value instead of key)?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 6 May 2000 19:53:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: sorting hashes by value rather than by key in a foreach loop
Message-Id: <Pine.GSO.4.10.10005061951330.3921-100000@user2.teleport.com>

On 7 May 2000, The WebDragon wrote:

>     @Gkeys = sort {
>                 $scoresG{$a} <=> $scoresG{$b}
>                           ||
>                 length($namesList{$a}) <=> length($namesList{$b})
>                           ||
>                 $namesList{$a} cmp $namesList{$b}
>     } keys %scoresG;
> 
> all I wind up with is tons of this: 

> # [Sat May  6 22:28:24 2000] Dev:Pseudo: # Use of uninitialized value.

Could you have some keys in %scoresG which don't have defined values in
%namesList? Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 06 May 2000 21:30:49 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Why are files required to return true values?
Message-Id: <brian-0605002130500001@202.portland-05rs.me.dial-access.att.net>

In article <8f0ak5$26s$1@bob.news.rcn.net>, "David Allen" <s2mdalle@titan.vcu.edu> wrote:


>I'm still somewhat used to C where everything is
>so agonizingly explicit.  Sometimes, I do contract work in perl,
>and it feels unethical taking money for some of the stuff I do
>considering how much effort it REALLY takes with perl...

it's not how much your time is worth necessarily, but how much 
value you provide to the client. :)

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 2969
**************************************


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