[18201] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 369 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 27 18:06:01 2001

Date: Tue, 27 Feb 2001 15:05:20 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983315120-v10-i369@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Feb 2001     Volume: 10 Number: 369

Today's topics:
    Re: -e and empty file name <peter.lerup@ecs.ericsson.se>
    Re: Any way to modify a script while executing it? <donkan7@yahoo.com>
        dereferencing an array of references using join <joeykid6@yahoo.com>
    Re: dereferencing an array of references using join (Tad McClellan)
    Re: dereferencing an array of references using join <godzilla@stomp.stomp.tokyo>
    Re: dereferencing an array of references using join (Greg Bacon)
    Re: dereferencing an array of references using join <ren@tivoli.com>
        Easy REGEX question <todd@ti.com>
        els <xeno@bigger.aa.net>
    Re: els <iltzu@sci.invalid>
    Re: Etymology of hash (Eric Bohlman)
    Re: Etymology of hash (Abigail)
        GRATIS: SCARICA IL TUO NOME IN ARABO <nabillat@tin.it>
    Re: HELP needed on a simple Parse::RecDescent program ( <ekliao@pacbell.net>
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Casper H.S. Dik - Network Security Engineer)
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari <iltzu@sci.invalid>
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Mikko Tyolajarvi)
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari <uri@sysarch.com>
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
    Re: if $line =~ /ref\d+/ <ren@tivoli.com>
        Learning Perl <Trebor_Clark@btinternet.com>
    Re: Learning Perl <gtoomey@usa.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Feb 2001 20:41:42 +0100
From: "Peter Lerup" <peter.lerup@ecs.ericsson.se>
Subject: Re: -e and empty file name
Message-Id: <97gv9u$2fa$1@newstoo.ericsson.se>

> Does anyone know why the file test operator -e return a true value when an
> empty file name is used in Perl version 5.6.0? This was not the case in
> 5.003.
>

Downloaded latest Win32 version from ActiveState (build 623) and now it
works! My old version that didn't work was build  613

/Peter



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

Date: Tue, 27 Feb 2001 09:08:15 -0800
From: "Dick" <donkan7@yahoo.com>
Subject: Re: Any way to modify a script while executing it?
Message-Id: <3a9bdf01$1_3@huge.aa.net>

I want to thank Logan Shaw, Godzilla!, and Ian Boreham for taking the
trouble to answer my question. My usual news server was/is screwed up and I
just now found your replies by using a different server. I'll give each of
the three replies some hard study. I'm pleased that there are ways to do
what I want to, even if at present I don't completely understand them. Maybe
I should add that it seems Godzilla!'s solution changes the default to a
random integer -- not what I had in mind, but the code is interesting.

Dick




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

Date: Tue, 27 Feb 2001 14:25:37 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: dereferencing an array of references using join
Message-Id: <97gv4c$6ao$1@slb2.atl.mindspring.net>

I'm having a bit of trouble dereferencing an array of arrays using join the
way I want.  This first bit pulls the data in from a tab-delimited textfile:

    open (WEEKR,"<../cluster/test.txt") ||
    die ("Couldn't find data file: $!");

    while (<WEEKR>) {
     chomp;
     @row_items = split("\t");
     push @all_file_data,[@row_items];
    }
    close (WEEKR);

#Then the values of some scalars are changed (not all of
#the var manipulation is included, but you get the idea):

    if ($all_file_data["$rm_row"]["$name_loc"] eq "") {
     $all_file_data["$rm_row"]["$name_loc"] = $t_name;
     $all_file_data["$rm_row"]["$email_loc"] = $t_email;

#Then I want to reform the tab-delimited rows, and send the
#data back to overwrite the textfile, but I'm having
#trouble:

 open (WEEKW,">../cluster/test.txt") ||
 die ("Couldn't find data file: $!");

#you can see that what I'm looking for here is a way to
#make a for loop reconstruct all the tab rows, but I just
#can't figure out the syntax.  I'm pretty new to array
#references (and to perl in general)

 for (@all_file_data) {
     $i = 0;
     $row_str = join("\t",@{$all_file_data["$i"]});
     print WEEKW "$row_str\n";
     $i++;
 }
 close (WEEKW);

I looked through the archive, but I have the darndest time finding anything
now that deja.com is down.  Any help would be greatly appreciated.  Thank
you.




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

Date: Tue, 27 Feb 2001 14:56:52 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: dereferencing an array of references using join
Message-Id: <slrn99o1k3.bdm.tadmc@tadmc26.august.net>

Joe Williams <joeykid6@yahoo.com> wrote:
>I'm having a bit of trouble dereferencing an array of arrays using join the
>way I want.  This first bit pulls the data in from a tab-delimited textfile:
>
>    open (WEEKR,"<../cluster/test.txt") ||
>    die ("Couldn't find data file: $!");
>
>    while (<WEEKR>) {
>     chomp;
>     @row_items = split("\t");

   my @row_items = split(/\t/);       # declare a new array variable
   ^^                    ^  ^
   ^^                    ^  ^

A pattern match should *look like* a pattern match.


>     push @all_file_data,[@row_items];

   push @all_file_data, \@row_items;  # take a reference to the new array var
                                      # no need for an anon array


No need for a named array either, come to think of it:

   push @all_file_data, [ split /\t/ ]


>    }
>    close (WEEKR);
>
>#Then the values of some scalars are changed (not all of
>#the var manipulation is included, but you get the idea):
>
>    if ($all_file_data["$rm_row"]["$name_loc"] eq "") {
                        ^       ^  ^         ^
                        ^       ^  ^         ^

Those are useless uses of double quotes. You should not use
useless stuff, it just gets in the way of understanding your code.

   if ($all_file_data[$rm_row][$name_loc] eq "") {


>     $all_file_data["$rm_row"]["$name_loc"] = $t_name;
>     $all_file_data["$rm_row"]["$email_loc"] = $t_email;
>
>#Then I want to reform the tab-delimited rows, and send the
>#data back to overwrite the textfile, but I'm having
>#trouble:
>
> open (WEEKW,">../cluster/test.txt") ||
> die ("Couldn't find data file: $!");
>
>#you can see that what I'm looking for here is a way to
>#make a for loop reconstruct all the tab rows, but I just
>#can't figure out the syntax.  I'm pretty new to array
>#references (and to perl in general)
>
> for (@all_file_data) {


That puts each array reference into $_. You never use $_ in
the loop body...


>     $i = 0;
>     $row_str = join("\t",@{$all_file_data["$i"]});
>     print WEEKW "$row_str\n";
>     $i++;


   foreach my $aref ( @all_file_data ) {
      my $row_str = join "\t", @{$aref};
      print WEEKW "$row_str\n";
   }

>I looked through the archive, but I have the darndest time finding anything
>now that deja.com is down.


Yeah, it has disappointed my several times already. I hope they
fix it soon...


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


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

Date: Tue, 27 Feb 2001 13:03:30 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: dereferencing an array of references using join
Message-Id: <3A9C1622.76161981@stomp.stomp.tokyo>

Joe Williams wrote:
 
> I'm having a bit of trouble dereferencing an array of
> arrays using join the way I want.

(snipped)

>  for (@all_file_data) {
>      $i = 0;
>      $row_str = join("\t",@{$all_file_data["$i"]});
>      print WEEKW "$row_str\n";
>      $i++;
>  }


You have a serious logic error you need to repair
before attempting any debugging.

Godzilla!
--

TEST SCRIPT:
____________

#!perl

print "Content-type: text/plain\n\n";

@Array = (1 .. 5);

print "Incorrect Syntax:\n";

for (@Array)
 {
  $i = 0;
  print "$Array[$i]\n";
  $i++;
 }

print "\n\nCorrect Syntax:\n";

$i = 0;

for (@Array)
 {
  print "$Array[$i]\n";
  $i++;
 }

exit;


PRINTED RESULTS:
________________

Incorrect Syntax:
1
1
1
1
1


Correct Syntax:
1
2
3
4
5


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

Date: Tue, 27 Feb 2001 21:03:37 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: dereferencing an array of references using join
Message-Id: <t9o5h9rnanuee3@corp.supernews.com>

In article <97gv4c$6ao$1@slb2.atl.mindspring.net>,
    Joe Williams <joeykid6@yahoo.com> wrote:

: I'm having a bit of trouble dereferencing an array of arrays using join the
: way I want.  This first bit pulls the data in from a tab-delimited textfile:
: 
:     open (WEEKR,"<../cluster/test.txt") ||
:     die ("Couldn't find data file: $!");
: 
:     while (<WEEKR>) {
:      chomp;
:      @row_items = split("\t");
:      push @all_file_data,[@row_items];
:     }
:     close (WEEKR);

I would write the loop as

    while (<WEEKR>) {
        chomp;
        push @all_file_data => [ split /\t/ ];
    }

: #Then the values of some scalars are changed (not all of
: #the var manipulation is included, but you get the idea):
: 
:     if ($all_file_data["$rm_row"]["$name_loc"] eq "") {
:      $all_file_data["$rm_row"]["$name_loc"] = $t_name;
:      $all_file_data["$rm_row"]["$email_loc"] = $t_email;
:     }

Why are you building new strings, e.g., "$rm_row" and "$name_loc", only
to convert them back to numbers?  Kill the double quotes.

: #you can see that what I'm looking for here is a way to
: #make a for loop reconstruct all the tab rows, but I just
: #can't figure out the syntax.  I'm pretty new to array
: #references (and to perl in general)
: 
:  for (@all_file_data) {
:      $i = 0;
:      $row_str = join("\t",@{$all_file_data["$i"]});
:      print WEEKW "$row_str\n";
:      $i++;
:  }

There are a couple of ways to do it.  Here's a verbose way:

    for (@all_file_data) {
        print WEEKW join("\t", @$_), "\n";
    }

You can also do it without the explicit outer loop:

    print WEEKW join("\n", map join("\t", @$_), @all_file_data), "\n";

Greg
-- 
When going to visit the woman, do not forget the whip.
    -- Nietzsche


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

Date: 27 Feb 2001 14:11:13 -0600
From: Ren Maddox <ren@tivoli.com>
Subject: Re: dereferencing an array of references using join
Message-Id: <m3ofvnkhsu.fsf@dhcp9-175.support.tivoli.com>

On Tue, 27 Feb 2001, joeykid6@yahoo.com wrote:

>     if ($all_file_data["$rm_row"]["$name_loc"] eq "") {
>      $all_file_data["$rm_row"]["$name_loc"] = $t_name;
>      $all_file_data["$rm_row"]["$email_loc"] = $t_email;

Don't use quotes like that -- it works, but only in spite of, not
because of the quotes.  First of all, putting a single scalar in
quotes servers very little purpose; and second, arrays are indexed by
numbers, so why would you use strings?

>  for (@all_file_data) {
>      $i = 0;

This resets $i each time through the loop....

>      $row_str = join("\t",@{$all_file_data["$i"]});
>      print WEEKW "$row_str\n";
>      $i++;
>  }
>  close (WEEKW);

Try this:

    foreach my $row (@all_file_data) {
        print WEEKW join "\t", @$row;
    }



-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 27 Feb 2001 16:51:21 -0600
From: Todd Bair <todd@ti.com>
Subject: Easy REGEX question
Message-Id: <3A9C2F69.5582D40@ti.com>


--------------EAF9AA078A2A9B9377A09E3B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I just can't seem to get this to work.  How do a split a line
based on two or more spaces, but leave single spaces alone.

ie...

$line = 'column one     column two   column three';
@row = split/  /,$line;

so that

$row[0] eq 'column one';
$row[1] eq 'column two';

Thanks,

Todd


--------------EAF9AA078A2A9B9377A09E3B
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt>I just can't seem to get this to work.&nbsp; How do a split a line</tt>
<br><tt>based on two or more spaces, but leave single spaces alone.</tt><tt></tt>
<p><tt>ie...</tt><tt></tt>
<p><tt>$line = 'column one&nbsp;&nbsp;&nbsp;&nbsp; column two&nbsp;&nbsp;
column three';</tt>
<br><tt>@row = split/&nbsp; /,$line;</tt><tt></tt>
<p><tt>so that</tt><tt></tt>
<p><tt>$row[0] eq 'column one';</tt>
<br><tt>$row[1] eq 'column two';</tt><tt></tt>
<p><tt>Thanks,</tt><tt></tt>
<p><tt>Todd</tt>
<br><tt></tt>&nbsp;</html>

--------------EAF9AA078A2A9B9377A09E3B--



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

Date: 27 Feb 2001 11:14:49 -0800
From: Xeno Campanoli <xeno@bigger.aa.net>
Subject: els
Message-Id: <3a9bfca9$1_2@huge.aa.net>

I have the following program in Perl:

> cat els.pl
#!/usr/bin/perl -w
if ( 1 )
{
        print "Here I am!!\n";
}
els
{
        print "...and here I am again!!  Woe!\n";
}
print "...and sometimes this doesn't yield any error at all!!\n";
                                                                                

---

Anyway, the point is, els is an easy mistake to make, and it doesn't diagnose
right in my present version, especially when I perl -cw the script...I get
a:

> perl -cw els.pl
els.pl syntax OK

I do get a runtime diagnostic, in one of two circumstances.
-- 
Xeno Campanoli (erstwhile Xeno Whitenack, and Rick Burgess)
Email:	xeno@aa.net	(Web pages:  http://www.aa.net/~xeno)


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

Date: 27 Feb 2001 21:21:36 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: els
Message-Id: <983308376.28517@itz.pp.sci.fi>

In article <3a9bfca9$1_2@huge.aa.net>, Xeno Campanoli wrote:
>I have the following program in Perl:
 [snip]
>Anyway, the point is, els is an easy mistake to make, and it doesn't diagnose
>right in my present version, especially when I perl -cw the script...I get
>
>> perl -cw els.pl
>els.pl syntax OK

  $ perl -MO=Deparse
  if ( 1 )
  {
	  print "foo\n";
  }
  els
  {
	  print "bar\n";
  }
  print "foobar\n";
  __END__
  - syntax OK
  print "foo\n";;
  do { print "bar\n" }->els(print("foobar\n"));

So you see, it doesn't give a syntax error because it's valid Perl
syntax.  This, of course, is an argument against having indirect
object syntax in Perl at all, but we're rather stuck with it now.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"..so either I'm off to ams.nl on sunday with [my laptop] or I'm without
 it BECAUSE IT SITS RECTALLY IN SOMEONE."     -- Måns Nilsson in the SDM

Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: 27 Feb 2001 19:20:12 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Etymology of hash
Message-Id: <97gulc$e8f$1@bob.news.rcn.net>

Bart Lateur <bart.lateur@skynet.be> wrote:
> Because of how it's implemented: using a hashing function. A string is
> first reduced to a small number, that will hopefully be rather unique
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
Sounds like a grammarian describing a nightmare he had :)

> over the set of existing keys. Then, only the items with that particular
> hash value for their key still need to be checked.

> So the group of all keys is subdivided (hashed) in quite a few lots
> smaller sets.

AIUI, "hash" here really means "scramble" in the sense that a good hash 
function scrambles up the bits of the key so that similar keys lead to 
dissimilar function values.

> Hash functions are typically closely related to checksums.

And to cryptography.



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

Date: 27 Feb 2001 21:03:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Etymology of hash
Message-Id: <slrn99o5h8.t3c.abigail@tsathoggua.rlyeh.net>

Lou Moran (lmoran@wtsg.com) wrote on MMDCCXXXVII September MCMXCIII in
<URL:news:1ktn9tk2qa7uh3caja819tpbiiaa7rid0d@4ax.com>:
|| On 27 Feb 2001 15:56:53 GMT, abigail@foad.org (Abigail) wrote
|| wonderful things about sparkplugs:
|| 
|| 
|| >Mapping (in LPC)
|| 
|| See now that makes sense to me.  I know exactly what that's going to
|| do.  I have no idea what LPC is, however.


Lars Pensj\"o C


Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: Tue, 27 Feb 2001 21:10:40 GMT
From: "NABIL LATFAOUI" <nabillat@tin.it>
Subject: GRATIS: SCARICA IL TUO NOME IN ARABO
Message-Id: <kJUm6.25661$Mx3.349248@twister2.tin.it>

Ciao, vai sul mio sito e scarica il tuo nome in arabo, gratis. veramente è
un'opera d'arte. puoi lasciarmi un mess. in "discussione" mandarmi un
e-mail.

             Ciao   a presto
http://digilander.iol.it/nbl




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

Date: 27 Feb 2001 15:54:10 -0600
From: Eric Liao <ekliao@pacbell.net>
Subject: Re: HELP needed on a simple Parse::RecDescent program (problem: some rules are matched twice)
Message-Id: <k16o9togmejk1rfbbuqpgn948vpn57osbr@4ax.com>

Gwyn,

Thanks!  It seems that LL has stricter conditions than LR. I am still
learning it.  I don't mind using either type of grammar and I don't
mind the backtracking, as long as the grammar is correct, has no left
recursion, and is good for Parse::Recdescent.  My initial problem was
solved.  As was pointed out, I simply printed at the wrong place (I
have since then learned how to pass the appropriate data upwards.),
and I naively thought that

execution of action = successful match of subrule

which is incorrect.


On Tue, 27 Feb 2001 03:42:58 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
wrote:

>>You can't print out your result while you are parsing it, because you
>>can't "unprint" a backtrack.  You backtracked in "expression" from the
>>first subrule to the second subrule, but you'd already printed out the
>>result of a successful first step of that first subrule.
>>
>>Don't do that. Pass the data upstairs, and have the final top-level
>>rule do all the work.
>
>Alternatively, you could make the grammar LL(1) so there is no need for
>backtracking. There is only the one problematic non-terminal so it
>shouldn't be too hard. Simply replace this:
>
>expression      :       unary_expr PLUS_OP expression
>                        |       unary_expr
>
>with this:
>
>expression      :       unary_expr plus_expression
>
>plus_expression :       PLUS_OP expression
>                        |       # nothing



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

Date: 27 Feb 2001 13:43:58 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97h01u$7rc$1@yin.interaccess.com>

In article <97gted$k53$1@new-usenet.uk.sun.com>,
Casper H.S. Dik - Network Security Engineer <Casper.Dik@Holland.Sun.Com> wrote:
 ...
>>and under Solaris:
>
>>% egrep 'SOL_SOCKET|REUSEA' /usr/include/*/*.h
>>/usr/include/sys/socket.h:#define       SO_REUSEADDR    0x0004
>>/usr/include/sys/socket.h:#define       SOL_SOCKET      0xffff
>
>
>
>You shouldn't care about that.
>
>if you use a modern version of perl, you simply use "use Socket" and
>import the properly set variables that way.

Which part of "I can't depend on any external files" didn't you understand?

Obviously, if you can use external files (Socket.p*), then the problem is
trivial.  The issue is how to do it when you can't use external files.

It is amazing to me how no matter how explicit one is about the parameters
of the problem, you will always get posts that assume the contrary of one or
more of those parameters.


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

Date: 27 Feb 2001 20:21:26 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97h286$n3i$1@new-usenet.uk.sun.com>

[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

gazelle@yin.interaccess.com (Kenny McCormack) writes:

>It is amazing to me how no matter how explicit one is about the parameters
>of the problem, you will always get posts that assume the contrary of one or
>more of those parameters.

In that case, you cannot solve the problem.

Unless you figure out that you can build the Socket module statically
and that it is the socket loadable module that defines all the
constants (and not Socket.pm); Socket.pm can the be inlined.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: 27 Feb 2001 14:54:17 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97h45p$8pa$1@yin.interaccess.com>

In article <97h286$n3i$1@new-usenet.uk.sun.com>,
Casper H.S. Dik - Network Security Engineer <Casper.Dik@Holland.Sun.Com> wrote:
>[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]
>
>gazelle@yin.interaccess.com (Kenny McCormack) writes:
>
>>It is amazing to me how no matter how explicit one is about the parameters
>>of the problem, you will always get posts that assume the contrary of one or
>>more of those parameters.
>
>In that case, you cannot solve the problem.

I *know* the problem cannot be "solved" (as that term is generally
interpreted in newsgroups).  That's the whole point.  The point is that in
the real world, we often have to "make do" and accept less than perfect
solutions (*).

The question was: how much variation is there?  My reason for posting was to
get people with access to Unixes other than L & S to post what the values
are on their systems.

I am still hoping that I will get some useful responses to this thread.

(*) It is also possible that there is some magic bullet in Perl that could
do this.  Clearly, Perl (something with which I am only moderately
familiar-with/skilled-in) "knows" the values of these constants (gathered
while it was being compiled) and it is not inconceivable that it could be
possible for a running Perl program to determine these constants at runtime
thereby.  I assume this is not the case, but it is not inconceivable.


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

Date: 27 Feb 2001 21:10:43 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <983307864.28040@itz.pp.sci.fi>

In article <97h01u$7rc$1@yin.interaccess.com>, Kenny McCormack wrote:
>In article <97gted$k53$1@new-usenet.uk.sun.com>,
>Casper H.S. Dik - Network Security Engineer <Casper.Dik@Holland.Sun.Com> wrote:
>>
>>if you use a modern version of perl, you simply use "use Socket" and
>>import the properly set variables that way.
>
>Which part of "I can't depend on any external files" didn't you understand?

The part where you define "external files" to include parts of the
standard perl distribution.  Any perl that lacks Socket.pm is broken.


>Obviously, if you can use external files (Socket.p*), then the problem is
>trivial.  The issue is how to do it when you can't use external files.

The issue is also trivial if you can't use the perl interpreter, which
is an external file if you use a sufficiently broad definition.  So do
tell us what the real situation is, and maybe someone can help you.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"if _they_ do it, it's sniping. If somebody else does it, it's camping."
                                  -- Juergen Nieveler in the monastery

Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: 27 Feb 2001 21:12:26 GMT
From: mikko@dynas.se (Mikko Tyolajarvi)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97h57q$2926$1@xlerb.dynas.se>

gazelle@yin.interaccess.com (Kenny McCormack) writes:

>This question arose in the context of a Perl program, but my real purpose is
>to find out how much variation there is in Unix flavors other than Linux and
>Solaris (which are the [only] two I have access to at the moment).

>I have the following line in a Perl program:

>    die $! unless setsockopt(S,$SOL_SOCKET,$SO_REUSEADDR,pack("l",1));

>and this depends on having SOL_SOCKET and SO_REUSEADDR defined.  Now, I know
>that there are "officially correct" ways of doing this in Perl, that depend
>on having the full Perl installation online.  But I cannot use those
>methods, because of the old/standard "Can I expect my clients to have the
>development environment installed?" question, to which the answer has to be
>"No."  All I can rely on is that they have the Perl executable.

>Under Linux, I have found:

>% egrep 'SOL_SOCKET|REUSEA' /usr/include/*/*.h
>/usr/include/asm/socket.h:#define SOL_SOCKET    1
>/usr/include/asm/socket.h:#define SO_REUSEADDR  2

>and under Solaris:

>% egrep 'SOL_SOCKET|REUSEA' /usr/include/*/*.h
>/usr/include/sys/socket.h:#define       SO_REUSEADDR    0x0004
>/usr/include/sys/socket.h:#define       SOL_SOCKET      0xffff

>Now, where this is all coming from is that in the past, I've found that
>Solaris seems to do things differently than most other Unixes.  So, I've

s/Solaris/Linux/

>done this:

>    $SOCK_STREAM = $ENV{'OSTYPE'} =~ /solaris/ ? 2 : 1;

Apart from this being a bad idea from a mainatanence perspective,
Solaris, AIX, HP-SUX, FreeBSD and even M$ winsock use the same
definitions - most likely inheritance from the BSD TCP/IP stack.

    $.02,
    /Mikko
--
 Mikko Työläjärvi_______________________________________mikko@rsasecurity.com
 RSA Security


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

Date: 27 Feb 2001 16:22:52 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97h9bs$9r8$1@yin.interaccess.com>

In article <983307864.28040@itz.pp.sci.fi>,
Ilmari Karonen  <usenet11380@itz.pp.sci.fi> wrote:
 ...
>>trivial.  The issue is how to do it when you can't use external files.
>
>The issue is also trivial if you can't use the perl interpreter, which
>is an external file if you use a sufficiently broad definition.  So do
>tell us what the real situation is, and maybe someone can help you.

The real situation is that I want my application to work on machines where,
in your opinion, the Perl installation is "broken".  I can assume the
existence of the Perl executable, but nothing more.

Seems clear enough to me.  But this *is* the sort of thing that makes people
want to write stuff in C, and not dick around with scripting languages.


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

Date: Tue, 27 Feb 2001 22:30:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <x7n1b7g3nu.fsf@home.sysarch.com>

>>>>> "KM" == Kenny McCormack <gazelle@yin.interaccess.com> writes:

  KM> The real situation is that I want my application to work on
  KM> machines where, in your opinion, the Perl installation is
  KM> "broken".  I can assume the existence of the Perl executable, but
  KM> nothing more.

  KM> Seems clear enough to me.  But this *is* the sort of thing that
  KM> makes people want to write stuff in C, and not dick around with
  KM> scripting languages.

no, it is the reason we flame those who claim that all perl needs is the
binary and none of its support libraries. ok, write it in c and remove
most of /usr/lib and /usr/local/lib. see how far you get.

and most of us don't dick around in c anymore since perl is more
portable! most perl programs run untouched on most unix flavors BECAUSE
of stuff like Socket.pm and not despite it. try even compiling a socket
based program on different platforms without massive use of cpp and
autoconf stuff. and forget about distributing one binary instead of one
script. some people just don't get it.

if the perl installastion does not have Socekt.pm, it is NOT a perl
installation. it is some stupid copy of a perl binary put into
/usr/local/bin. deal with it yourself. those sites are BROKEN!!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 27 Feb 2001 16:36:01 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97ha4h$a0d$1@yin.interaccess.com>

In article <97h57q$2926$1@xlerb.dynas.se>,
Mikko Tyolajarvi <mikko@dynas.se> wrote:
 ...
>>Now, where this is all coming from is that in the past, I've found that
>>Solaris seems to do things differently than most other Unixes.  So, I've
>
>s/Solaris/Linux/
>
>>done this:
>
>>    $SOCK_STREAM = $ENV{'OSTYPE'} =~ /solaris/ ? 2 : 1;
>
>Apart from this being a bad idea from a mainatanence perspective,
>Solaris, AIX, HP-SUX, FreeBSD and even M$ winsock use the same
>definitions - most likely inheritance from the BSD TCP/IP stack.

Interesting.  At last, a useful reply.

I based my position on the following fact.  The source code for the camel
book, specifically, the file camel-book/ch6/server, dated 1-08-91,
contains the line:

	$SOCK_STREAM = 1;

So, I assumed that to be the standard.  When I tried it out under Solaris, I
found I had to change it to 2.  Of course, I have no idea on which system
the camel book code was originally developed, but there you have it.

And, in fact, every piece of networking code that I've done in Perl has been
based on the examples (client & server) given in the camel book.

I seem to remember, but I can't say definitively, that I have done this sort
of thing under HP/UX and found it to use the same values as Linux.


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

Date: 27 Feb 2001 15:18:40 -0600
From: Ren Maddox <ren@tivoli.com>
Subject: Re: if $line =~ /ref\d+/
Message-Id: <m3k86bkeof.fsf@dhcp9-175.support.tivoli.com>

On Tue, 27 Feb 2001, kmojar@bmjgroup.com wrote:

> open(OUTPUT, $output);

Others have answered your question, and I expect this is likely a
typo, but you aren't going to get very much written to $output if you
don't open it for writing:

  open OUTPUT, ">$output" or die "Could not create $output, $!\n";

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 27 Feb 2001 20:49:25 -0000
From: "Robert Clark" <Trebor_Clark@btinternet.com>
Subject: Learning Perl
Message-Id: <97h3r4$fk0$1@plutonium.btinternet.com>

How can i go about learning perl??

--
Steve Wright

schumie@totalise.co.uk




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

Date: Wed, 28 Feb 2001 07:27:46 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Learning Perl
Message-Id: <kLUm6.4838$v5.17682@newsfeeds.bigpond.com>

On the web:
Perl tutorials at perl.com:
http://www.perl.com/reference/query.cgi?section=tutorials&x=17&y=8
General perl documentation: www.perldoc.com

Beginners Books:
Don't laugh, I first learnt Perl with "Perl for Dummies" by Paul Hoffman.
Cheap, comes with a CD, 4/5 stars at Amazon.com.

Advanced Books:
Programming Perl, by Larry Wall et al.
Perl Cookbook, by Tom Christiansen et al.

 ------------------------------
"Robert Clark" <Trebor_Clark@btinternet.com> wrote in message
news:97h3r4$fk0$1@plutonium.btinternet.com...
> How can i go about learning perl??
>
> --
> Steve Wright
>
> schumie@totalise.co.uk
>
>




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

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 V10 Issue 369
**************************************


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