[13173] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 583 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 19 05:07:17 1999

Date: Thu, 19 Aug 1999 02: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)

Perl-Users Digest           Thu, 19 Aug 1999     Volume: 9 Number: 583

Today's topics:
    Re: %0 %1 %2 ???? <ricklim@vcn.bc.ca>
    Re: %0 %1 %2 ???? <ricklim@vcn.bc.ca>
    Re: A prime numbers program. (Anno Siegel)
        Any news about Win32 Threads <kangas@anlon.com>
        Globbing in PerlScript <mbruce@u.washington.edu>
    Re: Globbing in PerlScript (elephant)
    Re: How To change directories (Larry Rosler)
        OOP in perl - not modules!!! prasad@chetana.com
    Re: OOP in perl - not modules!!! (brian d foy)
        Packages and parent packages (Donovan Rebbechi)
        perl + mysql.. <mtlam@hongkong.com>
        perl-equivalent of wget - did somebody write it? (Henrik Seidel)
    Re: perl-equivalent of wget - did somebody write it? <gellyfish@gellyfish.com>
    Re: Question about date (Twarren10)
    Re: Renaming Windows NT domain users (elephant)
    Re: Renaming Windows NT domain users (Michael Blackmore)
    Re: Renaming Windows NT domain users (elephant)
    Re: shell script translation (Donovan Rebbechi)
    Re: statistical sorts <marc@interak.com>
        UDP help (Kyle Davis)
    Re: what does eq do on lists? (William Herrera)
    Re: what does eq do on lists? <nospam.newton@gmx.net>
    Re: what does eq do on lists? (Larry Rosler)
    Re: While loop being ignored (elephant)
    Re: While we are on the subject of tainting.... (I.J. Garlick)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 19 Aug 1999 06:38:48 GMT
From: Rick Lim <ricklim@vcn.bc.ca>
Subject: Re: %0 %1 %2 ????
Message-Id: <7pg8po$d8$1@sylvester.vcn.bc.ca>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:
: Rick Lim <ricklim@vcn.bc.ca> wrote:
:> brian d foy <brian@pm.org> wrote:
:> : In article <7p8bgu$1e$1@sylvester.vcn.bc.ca>, Rick Lim <ricklim@vcn.bc.ca> wrote:
:> 
:> :>are the %0 %1 %2 the same as command line parameters
:> :>in the statment
:> :>
:> :>perl -S %0 %1 %2
:> 
:> : i'm not sure what you are asking.  command line parameters
:> : show up in Perl in the @ARGV array.  the positions that you
:> : note in the above example would show up in $ARGV[0], $ARGV[1],
:> : and $ARGV[2], respectively.
:> 
:> what I am trying to find out is what do
:> the %0 %1 %2 indicate, the only perl
:> book (programming perl by oreilly)
:> doesn't say anything about this
:> 

: If they existed they would be a bunch of hashes with confusing names - 
: but they will not exist unless you define them.

: Do you mean perhaps $0 & $1 etc I wonder : most of Perls predefined variable
: are described in the perlvar manpage however you will find a better
: description of $1 ... in the perlre manpage.

This is actually a working program someone else
wrote that I have to modify , at the top of the file
listing is the statement perl -S %0 %1 %2
this I understand is the equivilant of #!/usr/bin/perl
what I don't understand is the %0 %1 %2



: /J\
: -- 
: "Mark my words, sex is never enough. Sooner of later she'll want a
: dishwasher" - Policeman, City Central

-- 
The wealth of reality, cannot be seen from your locality.


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

Date: 19 Aug 1999 06:40:48 GMT
From: Rick Lim <ricklim@vcn.bc.ca>
Subject: Re: %0 %1 %2 ????
Message-Id: <7pg8tg$d8$2@sylvester.vcn.bc.ca>

Lack Mr G M <gml4410@ggr.co.uk> wrote:
: In article <7p8bgu$1e$1@sylvester.vcn.bc.ca>, Rick Lim <ricklim@vcn.bc.ca> writes:
: |> are the %0 %1 %2 the same as command line parameters
: |> in the statment
: |> 
: |> perl -S %0 %1 %2

:    Are you by any chance a MS Windows user?  The %0 %1 etc. look like
: the way it denotes parameters in scripting.

:    If so, the "%0 %1 %2" in "perl -S %0 %1 %2" is nothing to do with
: perl, but rather it is to do with the scripting language that this
: particular line was written in. 

this perl -S %0 %1 %2 line is the first line of a perl script
that I believe runs on a dos machine

: -- 
: --------- Gordon Lack --------------- gml4410@ggr.co.uk  ------------
: This message *may* reflect my personal opinion.  It is *not* intended
: to reflect those of my employer, or anyone else.

-- 
The wealth of reality, cannot be seen from your locality.


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

Date: 19 Aug 1999 08:59:56 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: A prime numbers program.
Message-Id: <7pgh2c$7dg$1@lublin.zrz.tu-berlin.de>

 <jm_the_great@my-deja.com> wrote in comp.lang.perl.misc:
>How would I divisibility by the modulo thing?
>Can you give me an example?

Please follow the usenet standard and place your reply *after*
the quoted text you're replying to.  And trim your quotes.

if ( $a % $b ) { # $b doesn't divide $a } else { # $b divides $a }

Anno


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

Date: Thu, 19 Aug 1999 01:56:09 -0500
From: Kangas <kangas@anlon.com>
Subject: Any news about Win32 Threads
Message-Id: <37BBAA89.3296E19F@anlon.com>

I have seen sample programs in the Win32 Resource Kit but did not get
the examples to work that were in the book. I saw the thread Makefile
and stuff on the CD but my nmake doesn't work and never has. Not sure if
it works anyways.

Who knows if threads are available in Win32 yet??

--
Michael Kangas
Anlon Systems, Inc.
kangas@anlon.com




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

Date: Wed, 18 Aug 1999 23:27:28 -0700
From: "Matthew Bruce" <mbruce@u.washington.edu>
Subject: Globbing in PerlScript
Message-Id: <7pg8ji$ori$1@nntp6.u.washington.edu>

I am using PerlScript(ActivePerl in Win98)  imbedded in a
html file and trying to get the filehandles of all files with
extension *.xif

    while ($file =  <c:/windows/desktop/tmp/*.xif>)

and

    @test = glob("c:/windows/desktop/tmp/*.xif");

Neither of these return a thing.  Running from command line (DOS)
they work fine.

What am I missing ?

Thanks alot for any help

ps Also, is there a trick to get system() to run in PerlScript.




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

Date: Thu, 19 Aug 1999 18:28:33 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Globbing in PerlScript
Message-Id: <MPG.12266b3a6fd956d2989c57@news-server>

Matthew Bruce writes ..
>I am using PerlScript(ActivePerl in Win98)  imbedded in a
>html file and trying to get the filehandles of all files with
>extension *.xif
>
>    while ($file =  <c:/windows/desktop/tmp/*.xif>)
>
>and
>
>    @test = glob("c:/windows/desktop/tmp/*.xif");
>
>Neither of these return a thing.  Running from command line (DOS)
>they work fine.
>
>What am I missing ?

assuming you mean client side Javascript .. it works on WindowsNT

>ps Also, is there a trick to get system() to run in PerlScript.

this might be a pain in the butt .. but - again - works for me .. here's 
by test code for both the globbing and the system calls (two flavours)


<!-- start -->
<script language="perlscript">

  system('start notepad.exe');

  $x = `dir`;

  $window->document->write( '<pre>' . $x . '</pre>');

  while ($file = <c:/blah.*>)
  {
    open( BLAH, $file) or die "Open failed: $!\n";

    while (<BLAH>)
    {
      $window->document->write( $_ . '<BR>');
    }
    close BLAH;
  }

</script>
<!-- end -->

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Thu, 19 Aug 1999 00:03:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How To change directories
Message-Id: <MPG.12254c1314f0f41989e72@nntp.hpl.hp.com>

In article <37BB8467.7F0F0670@anlon.com> on Wed, 18 Aug 1999 23:13:27 -
0500, Kangas <kangas@anlon.com> says...
> lets say you had another perl script or whatever program in another directory...
> did you try this?
> 
> $results = `d:\programs\aFolder\runner.pl $parameter1 $parameter2`;
> 
> hope it helps.

That's not likly to help as it stands.  Backquotes create a double-
quoting environment, so those backslashes don't do what you think.  
Either double them or (better) use forward slashes intead.

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


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

Date: Thu, 19 Aug 1999 05:08:30 GMT
From: prasad@chetana.com
Subject: OOP in perl - not modules!!!
Message-Id: <7pg3g9$6ik$1@nnrp1.deja.com>

Hello,

I want to write completely object oriented programs in perl. I read the
PERLTOOT several times. I have done few small programs in C++ in my
programming class. But it still seemed to be confusing to start writing
OO perl programs.

I have the following questions,

Should the class pm files be created using h2xs or is it only for
creating CPAN type modules?

If I should type the classes in normal files myself and h2xs is not
necessary, what should be the file extension?

How do I distribute various classes in diff. files? can I include
multiple classes a single file?

In C++, I had created various classes which included the methods and
data. A  main program which had a sort of menu was calling various
object methods was the program that was calling the object methods.

I can't understand how to write ,let's say a csv file add,modify,delete
program that uses the CSV DBD module to carry out the file access
tasks
in perl. I also don't know where to get such a small sample program.
There are several OO modules in CPAN and procedural perl scripts like
most of the CGI scripts at several sites.

I think that the complete style of OOP and not the reusable CPAN
modules,the standard set of lines at the start of a typical class,the
controlling program format(similar to one containing main() in c++) etc.
needs to explained in a well paced man page by some perlwiz.

If anybody can throw some light on all this, I (and many newbees like
me) will be greatful.

,regards
prasad.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 19 Aug 1999 01:36:15 -0400
From: brian@pm.org (brian d foy)
Subject: Re: OOP in perl - not modules!!!
Message-Id: <brian-ya02408000R1908990136150001@news.panix.com>

In article <7pg3g9$6ik$1@nnrp1.deja.com>, prasad@chetana.com posted:

> Should the class pm files be created using h2xs or is it only for
> creating CPAN type modules?

start with h2xs.  it saves typing.

> If I should type the classes in normal files myself and h2xs is not
> necessary, what should be the file extension?

 .pm

> How do I distribute various classes in diff. files? can I include
> multiple classes a single file?

a class is just a package.  there can be multiple packages per
file.

> I can't understand how to write ,let's say a csv file add,modify,delete
> program that uses the CSV DBD module to carry out the file access
> tasks
> in perl. 

see the DBI docs.

> I also don't know where to get such a small sample program.

> I think that the complete style of OOP and not the reusable CPAN
> modules,

what's the difference between the modules that you want to write and
the ones on CPAN?

> the standard set of lines at the start of a typical class,the

h2xs does that all for you.

> controlling program format(similar to one containing main() in c++) etc.

just write the script and use the module like you would any other module.

> needs to explained in a well paced man page by some perlwiz.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: 19 Aug 1999 01:27:45 -0400
From: elflord@panix.com (Donovan Rebbechi)
Subject: Packages and parent packages
Message-Id: <slrn7rn5eg.im.elflord@panix3.panix.com>

Hi fellow perlers. I am interested in getting packages 
that refer to their constructing  package somehow.  
The problem I am trying to solve 
is that I want to use methods from foo in foo::bar. 
Here's my best shot at it, I'm wondering if anyone has
ideas for improvements:

#!/usr/bin/perl

package main;

my $f=foo->new;
$f->talk;

package foo;

sub new
{
    my $self={};
    $self->{bar}=foo::bar->new($self); # pass myself to constructor
    bless $self;
}
sub talk { shift->{bar}->talk; }
sub growl { print "ruff ruff ruff\n"; }

package foo::bar;

sub new
{
    my $class=shift;
    my $parent=shift;
    my $self={};
    $self->{parent}=$parent;
    bless $self;
}

# use a method from foo
sub talk { shift->{parent}->growl; }      


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

Date: Thu, 19 Aug 1999 14:39:57 +0800
From: "Teru" <mtlam@hongkong.com>
Subject: perl + mysql..
Message-Id: <7pg8ua$89j$1@thccy25.nthu.edu.tw>


I'm going  to write a program in perl to show out the databases, tables and
indexes of my MySQL databases, so that I can select databases and datas
through the web browser.
But I don't have any idea on how to do it ?
Does anyone know how ?

please give me some examples and informations. Thanks a lot.








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

Date: 19 Aug 1999 08:02:44 GMT
From: Henrik.Seidel@gmx.de (Henrik Seidel)
Subject: perl-equivalent of wget - did somebody write it?
Message-Id: <7pgdn4$t1o$1@mamenchi.zrz.TU-Berlin.DE>

I am looking for a perl implementation of the http and ftp retrieving
tool wget. I know it's not that difficult to implement using
LWP::UserAgent, but before I start coding I'd like to know if anybody
has done this already (including all the nifty stuff of getting files
recursively up to a maximum depth while staying on the same host etc).

Regards
				--- Henrik



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

Date: 19 Aug 1999 10:02:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl-equivalent of wget - did somebody write it?
Message-Id: <37bbc820_2@newsread3.dircon.co.uk>

Henrik Seidel <Henrik.Seidel@gmx.de> wrote:
> I am looking for a perl implementation of the http and ftp retrieving
> tool wget. I know it's not that difficult to implement using
> LWP::UserAgent, but before I start coding I'd like to know if anybody
> has done this already (including all the nifty stuff of getting files
> recursively up to a maximum depth while staying on the same host etc).
> 

The author of that very module includes a utility lwp-request (That is
linked to GET and POST on installation) as part of the libwww-perl
distribution - this may very well do what you want.

/J\
-- 
"I want to be like Oprah" - Sarah, Duchess of York


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

Date: 19 Aug 1999 06:22:58 GMT
From: twarren10@aol.com (Twarren10)
Subject: Re: Question about date
Message-Id: <19990819022258.08442.00000923@ng-cn1.aol.com>

>>> Can anyone tell me how I would check a date to see if two or more days
>have
>>> passed? 
>>

The time() function returns the current time in seconds since the epoch. Add
two days to that like so,

    $twodays = time() + ( 48 * 60 * 60 );

you should be able to figure it out from here.



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

Date: Thu, 19 Aug 1999 15:26:11 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Renaming Windows NT domain users
Message-Id: <MPG.122635bf944869da989c54@news-server>

Michael Blackmore writes ..
>Anybody know if it is possible to rename users within a Windows NT
>domain?  I've looked at Win32::NetAdmin and Win32::API::Net.  These
>can provide and change user details, but not it seems the username.  I
>am developing a script to rename around 400 users.

you can't change the username from within the WindowsNT User Manager 
program .. that would seem to suggest that Microsoft use the username as 
the primary key for the user record thus making it un-changeable

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Thu, 19 Aug 1999 06:24:32 GMT
From: michael.blackmore@kvaerner.com (Michael Blackmore)
Subject: Re: Renaming Windows NT domain users
Message-Id: <37bba1f1.285140119@news.kvaerner.com>

On Thu, 19 Aug 1999 15:26:11 +1000, elephant@squirrelgroup.com
(elephant) wrote:

>Michael Blackmore writes ..
>>Anybody know if it is possible to rename users within a Windows NT
>>domain?  I've looked at Win32::NetAdmin and Win32::API::Net.  These
>>can provide and change user details, but not it seems the username.  I
>>am developing a script to rename around 400 users.
>
>you can't change the username from within the WindowsNT User Manager 
>program .. that would seem to suggest that Microsoft use the username as 
>the primary key for the user record thus making it un-changeable
>
It turns out that you can using Win32::AdminMisc from Roth Consulting
http://www.roth.net/perl/adminmisc

Michael.
michael.blackmore@kvaerner.com
>-- 
> jason - elephant@squirrelgroup.com -



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

Date: Thu, 19 Aug 1999 17:09:51 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Renaming Windows NT domain users
Message-Id: <MPG.122658c8e5b370e7989c56@news-server>

Michael Blackmore writes ..
>On Thu, 19 Aug 1999 15:26:11 +1000, elephant@squirrelgroup.com
>(elephant) wrote:
>
>>Michael Blackmore writes ..
>>>Anybody know if it is possible to rename users within a Windows NT
>>>domain?  I've looked at Win32::NetAdmin and Win32::API::Net.  These
>>>can provide and change user details, but not it seems the username.  I
>>>am developing a script to rename around 400 users.
>>
>>you can't change the username from within the WindowsNT User Manager 
>>program .. that would seem to suggest that Microsoft use the username as 
>>the primary key for the user record thus making it un-changeable
>>
>It turns out that you can using Win32::AdminMisc from Roth Consulting
>http://www.roth.net/perl/adminmisc

as soon as I read that I remembered that you can change it in the User 
Manager .. just not from within the properties dialogue - you need to do 
it from the User manager (which is why (a) it took me a long time to 
work out that you could change a username in the first place and (b) I 
forget that you can do it frequently now - even though I've changed the 
Administrator on my own machine to (you guessed it) elephant)

thanks for (another) reminder about this functionality .. good to see 
that you can do it from Perl too .. sorry for the bum steer

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 19 Aug 1999 01:20:14 -0400
From: elflord@panix.com (Donovan Rebbechi)
Subject: Re: shell script translation
Message-Id: <slrn7rn50e.im.elflord@panix3.panix.com>

On Wed, 18 Aug 1999 17:51:44 -0700, Larry Rosler wrote:
>In article <slrn7rmabh.poq.elflord@panix3.panix.com> on 18 Aug 1999 
>17:45:22 -0400, Donovan Rebbechi <elflord@panix.com> says...
>...
>> in perl, like shellscript, variables are expanded inside single ( but 
>> not double ) quotes.
>
>You have that backwards.

Doh ! I knew that (-;

-- 
Donovan


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

Date: Wed, 18 Aug 1999 23:47:16 -0800
From: Marc Grober <marc@interak.com>
Subject: Re: statistical sorts
Message-Id: <37BBB683.30DCCAA2@interak.com>

I think Malcolm has it right. The distribution of a set of random samples would have
arguably the statistically same distribution as the full population, but each random
sample could be widely skewed when you think about it.  O fcourse, the argument has
been for years that sampling can represent the larger population (and a look at was is
done with human paternity testing is enough to demonstrate that this is largely a
crock..... but.....) but the reverse is another question altogether......

In any event, if the full population was large enougha random sample would be fine,
but for 2 artifacts 1) a random sampling can't serve to place the entire population in
one of the subgroups and 2) the populations I am dealing with is just several
thousand.

anyway......... any other ideas as to existing perl apps out there or CPAN stat
modules that could be useful?

Malcolm Dew-Jones wrote:

> > In article <37B9D3CD.DDE13E62@interak.com>,
> > Marc Grober  <marc@interak.com> wrote:
> ...
> >
> > >if sampling of a,population produces a specific curve showing the
> > >incidence of scores on a certain protocol and I want to then produce subsets of
> > >that sample with the same distribution I need to distribute members of the
> > >original sample such that all the subsets reflect the same statistical curve.
> >
> > No, you simply must sample the sample randomly. For example, if your
> > sample is 1,2,2,2,3, then a random selection from that sample has a 3/5
> > chance of being 2, and 1/5 each of being 1 or 3. That is the same
> > distribution you started with, assuming your initial sampling was valid.
> >
>
> A _random_ subset of a sample (such as 1,2,2,2,3) would not
> _necessarily_ have
> the same distribution as the sample.  I understand Marc to mean that he
> wants
> a subset that is _guaranteed_ to have the same distribution as the
> sample.
> (In fact it looks as if he wants to be able to generate numerous such
> subsets.)
>
> However, if the sample is so large that one needs to work with a subset
> then wouldn't a random subset would be accurate enough?



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

Date: Thu, 19 Aug 1999 07:06:40 GMT
From: ltt_kinslayer@NOSPAM.usa.net (Kyle Davis)
Subject: UDP help
Message-Id: <MPG.12252c2fd9a7fbea98968d@news.flash.net>

 Alright, I've been struggling with this all day and I just can't get it 
to work. What I'm trying to do is this: connect to a 'master server' that 
houses a list of IP addresses and ports of servers that are running games 
(in this case, Drakan). Split those apart, and then connect to each 
server and request information using UDP.

 I got the first part down. It's not perfect, but it works well enough 
for me to see that the second part doesn't. :)

 I'm not sure what it is I'm doing wrong, but any pointers would be much 
appreciated. Many thanks in advance...

 - Kyle Davis



#!/usr/bin/perl -w
use IO::Socket;       # used for the fetching of the master list
use Socket;           # used for UDP -- don't know how using IO::Socket

#######################################################################
# download master list

 $cserver = -1;
 $remote = IO::Socket::INET->new( Proto    => "tcp",
                                  PeerAddr => "master.mplayer.com",
                                  PeerPort => "http(80)", );
 print $remote "GET /drakan/servers.txt HTTP/1.0\015\012\015\012";

 while ($line = <$remote>)
 {
   if ($line =~ /text\/plain/i)     # the server IPs start
   {
     $cserver = 0;                  # start recording IPs
   }
   elsif ($cserver != -1)           # IP incoming
   {
     $allinfo[$cserver] = $line;
     $cserver++;
   }
 }

 close $remote;

#######################################################################
# set globals and print header information

 $numservs = (@allinfo - 2);              # account for lame lines I'm
                                          # too lazy to filter out
 print "Content-type: text/html\n\n";

 print "Total number of servers: $numservs\n";
 print "<br>\n";
 print "Server information:\n<pre>@allinfo</pre>";

#########################################################################
####
# cycle through each server and get information

 $cserver = 0;                     # current server number
 $scal    = "";                    # theoretically, server's response

 while ($cserver < $numservs)
 {
   ($serverip, $portx, $porty) = split(/ /, $allinfo[$cserver+1], 3);

   print "<hr noshade width=\"100%\" size=3>\n";
   print "<strong>$serverip</strong> ($portx):<p>\n";

   $port  = $portx;                        # port number
   $iaddr = inet_aton($serverip);          # convert from ASCII
                                           # dotted to numeric
   $paddr = sockaddr_in(27046, $iaddr);    # open local side
  #$proto = getprotobyname('udp');         # = needed?

   socket(SOCK, PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  #bind(SOCK, $paddr);                     # = needed?

#######################################################################
# Allright, all this is what I'm fairly unsure of. The packet with
# "\status\" might or might not actually be getting off, but I'm 99%
# sure that there is something wrong with the recv() call (or something
# wrong with opening the port above). At the moment, the script claims
# to send the request and then just pauses for an indefinate amount of
# time. Ideally, the server should respond with information about the
# players, level, server configuration, etc.
#
# This is where I really need the help. I have the feeling it's some-
# thing stupid I'm overlooking...

   send(SOCK, "\\status\\\r\n", 0, $paddr) || die "send: $!\n";
   print "Sent request <tt>\\status\\</tt>...<br>\n";
   print "Waiting for response...\n";

   ($senderip = recv(SOCK, $scal, 2, 0)) || die "recv: $!\n";
   print "\nReceived response: <tt>$scal</tt>...<br>\n";

#######################################################################
# And back to sensical code...

   closesocket(SOCK);                      # = close socket
   $cserver++;                             # and onward...
 }


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

Date: 19 Aug 1999 05:25:12 GMT
From: posting.account@lookout.com (William Herrera)
Subject: Re: what does eq do on lists?
Message-Id: <dM33c2i67iQd-pn2-jZpV4r6iEUDm@cheetah>

On Wed, 18 Aug 1999 23:31:01, "John M. Dlugosz" <john@dlugosz.com> 
wrote:

> > same as (scalar @a[0..3]) eq (scalar @b) ie compares the number of
> elements in
> > the arrays.
> 
> So I should get
>     4 eq 4

ah, did not read the post right. @a[0..3] is a list not an array. A 
perl gotcha. Sorry. Still the point is that eq forces scalar context.


> > look up join in perlfunc
> 
> Why would I want to do that?

Because it creates the actions you want in order to do an element 
compare of the list and the array.

ie

$my_sep = '\0';  # choose something never in the stuff to compare we 
hope
join($my_sep, @a[0..3]) eq join($my_sep, @b);


---
Note: The above address is spamblocked.
The real reply-to is: wherrera (at) lookout.com


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

Date: Thu, 19 Aug 1999 08:48:20 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: what does eq do on lists?
Message-Id: <37BBA8B4.D7ECFFB4@gmx.net>

John M. Dlugosz wrote:
> 
> #!perl -w
> use strict;
> 
> my @a= qw(one two three four five);
> my @b= qw(one two three four);
> 
> my $result= @a[0..3] eq @b;
> print "result is [$result]\n";
> 
> I get an empty result "[]" printed, when I expected "[1]" or some
> other TRUE value.
> 
> So I conclude that it's not comparing the strings.

That's because you changed qw(1 2 3 4 5) to qw(one two three four five)!
You bad boy! This way, then the array slice @a[0..3] (a list) is
evaluated in scalar context, it takes the last element and compares it
to the number of elements in @b (i.e. @b evaluated in scalar context).
'4' eq @b but 'four' ne @b. Result: "", which is false.

Cheers,
Philip


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

Date: Thu, 19 Aug 1999 00:39:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: what does eq do on lists?
Message-Id: <MPG.122554a38b2dc09d989e73@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <dM33c2i67iQd-pn2-jZpV4r6iEUDm@cheetah> on 19 Aug 1999 
05:25:12 GMT, William Herrera <posting.account@lookout.com> says...
> On Wed, 18 Aug 1999 23:31:01, "John M. Dlugosz" <john@dlugosz.com> 
> wrote:
 ... 
> > > look up join in perlfunc
> > 
> > Why would I want to do that?
> 
> Because it creates the actions you want in order to do an element 
> compare of the list and the array.
> 
> ie
> 
> $my_sep = '\0';  # choose something never in the stuff to compare we 
> hope
> join($my_sep, @a[0..3]) eq join($my_sep, @b);

Heh, heh, heh.  Not quite right.  Try this to see why:

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

my $sep = '\0';
join($sep => qw(a\0b c)) eq join($sep => qw(a b\0c)) and
    print "matched1\n";

$sep = "\0";
join($sep => qw(a\0b c)) eq join($sep => qw(a b\0c)) and
    print "matched2\n";

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


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

Date: Thu, 19 Aug 1999 15:45:02 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: While loop being ignored
Message-Id: <MPG.122644e6b1d0059a989c55@news-server>

Wyzelli writes ..
>I change it to
>
>while (<MAIL>){
>    print MAILTEMP $_;
>}
>
>And still get nothing...
>
>There is definitely something in the source file

then print out the value of $MailLoginFile just after the open .. make 
sure that it contains what you think it does

if it is what you think .. then post all your relevant code

>What I have found is that a debugger break-point set at the while statement
>is skipped as if it is a comment...

if the condition is false then the debugger will not break on that line 
 .. like I've been indicating - the while will happen unless it's false 
 .. it'll be false when an EOL is read from the file

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Thu, 19 Aug 1999 07:53:32 GMT
From: ijg@connect.org.uk (I.J. Garlick)
Subject: Re: While we are on the subject of tainting....
Message-Id: <FGpCL8.A6J@csc.liv.ac.uk>

In article <cYCu3.9826$x04.531970@typ11.nn.bcandid.com>,
pacman@defiant.cqc.com (Alan Curry) writes:
>>MY denseness is, everything seems to imply that you can't do
>>
>>	my @ret = exec 'myprog', 'arg1', 'arg2' or die "can't exec myprog: $!";
> 
> No, you don't do it that way.

[snip]

> The warning you have seen about "don't use exec to capture output" is just
> there because some people think exec by itself is supposed to return
> subcommand output. It doesn't. To do that, you need to make a pipe, create a
> new process, then exec and read, just as shown in the perlsec example. `` is
> a shortcut which does all that stuff for you. Unfortunately it also uses a
> shell to parse the command, which makes it harder to verify its security when
> user input is involved.

Told you I was being dense. Thanks for being patient with me Alan, got it
now. :-)


-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

Everyone is a genius.  It's just that some people are too stupid to
realize it.



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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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


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