[7400] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1025 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 15 04:17:14 1997

Date: Mon, 15 Sep 97 01:00:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 15 Sep 1997     Volume: 8 Number: 1025

Today's topics:
     Automation of NT 4.0 Workstation Installation <adriaand@redflex.com.au>
     Re: Can't call method ... <jefpin@bergen.org>
     CGI and Mail on NT <tlawallANTISPAM@concentric.net>
     Re: Comparing dates?? <rbush@up.net>
     Re: Comparing dates?? <ajohnson@gpu.srv.ualberta.ca>
     Re: Free Perl CGI Script michael.nilsson@maze.se
     How to redirect standard output of a backtick command <Pierre.Bergdolt@ansf.alcatel.fr>
     Re: Howto Parse data in spaced columns??? <rbush@up.net>
     Inserting \n in a string (Matt Weber)
     Re: is there a better way to do this subroutine? rbush@up.net
     Re: is there a better way to do this subroutine? <rbush@up.net>
     Re: is there a better way to do this subroutine? (Martien Verbruggen)
     Re: Is there a more efficient way to interweave 2 array (Jason Gloudon)
     pattern matching problem <xuchu@iscs.nus.edu.sg>
     Premature End Of Script Headers (Capt. COBOL)
     Simple question. <bremenlee@12345.hk>
     use Socket -> core dump on SunOS <wschow@Comp.HKBU.Edu.HK>
     Re: Why don't my <<HERE documents work?  Attempt #2! <jefpin@bergen.org>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 15 Sep 1997 16:18:56 +1000
From: "Adriaan" <adriaand@redflex.com.au>
Subject: Automation of NT 4.0 Workstation Installation
Message-Id: <5vik3i$i27$1@eplet.mira.net.au>

 Hi,

I have a task of installing Windows NT Workstation on around 50 hard drives.
I want to be able to start the installation, and then forget about the rest
of it (allowing for automation). I would like a script which could automate
NT's installation process while I continue on the other ones. I can't do it
my self because I don't understand any of the programming languages!

Thanks!





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

Date: Sun, 14 Sep 1997 21:05:20 -0400
From: Anagrams of the Word 'A' <jefpin@bergen.org>
To: Manolis <manolis@cytanet.com.cy>
Subject: Re: Can't call method ...
Message-Id: <Pine.SGI.3.95.970914210436.26205B-100000@vangogh.bergen.org>


>Can't call method "import" in empty package "Rcor_module" at
>./rcor_copies.pl line 7.
>BEGIN failed--compilation aborted at ./rcor_copies.pl line 7.
>
>line 7 has this:
>use Rcor_module;

I suggest you make sure to include the directory of Rcor_module...
use this line:
	use lib "/dir/of/your/module";

that should fix it...

----------------
| "To be a rock, and not to roll."
| 	- Led Zeppelin
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem?  Let me know!

webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS

- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>+++1094++++ L E--->---- W++++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y? 
- geek code -



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

Date: Sun, 14 Sep 1997 22:13:27 -0600
From: "T. LaWall" <tlawallANTISPAM@concentric.net>
Subject: CGI and Mail on NT
Message-Id: <341CB5E7.2725@concentric.net>


Does anyone know out there of a way to interface to the Windows NT
Mail system through Perl?  I need a way for an NT Perl CGI script
to e-mail results to some individuals with Internet email addresses.
Pointers to sites with info on this, or some examples would help.
Please email me when you post.

Thanks in advance,
Todd
-- 
  -------------------------------------------------
  T. LaWall
  To reply, remove ANTISPAM from my address
  -------------------------------------------------
  Where do I want to go today? 
  With Linux, Anywhere I want, TOLL FREE!
  -------------------------------------------------


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

Date: Sun, 14 Sep 1997 23:14:27 -0400
From: Ray Bush <rbush@up.net>
Subject: Re: Comparing dates??
Message-Id: <341CA813.324E@up.net>


Andrew Johnson wrote:
> 
> Raymond K. Bush wrote:
> !
> 
> [snip]
> 
> ! ( i think people take the system administrator chainsaw
> ! analogy off the deep end ...why use a chainsaw when scissors
> ! will do ...people and their bloody modules!)
> !
> ! from the command line:
> !
> ! perl -e '$bd = "09101981";
> ! require "ctime.pl";
> ! $d=ctime(time);
> ! ($j,$j,$j,$j,$j,$t)=split / /,$d,6;
> ! $y=$t-substr($bd,4);
> ! print "$y\n";
> ! '
> ! 16
> !
> ! I hope this helps.
> 
> [danger:ajohnson:~]$ perl -e 'require "ctime.pl";print ctime(time);'
> Sat Sep 13 14:09:57 1997
> ^^^ ^^^ ^^ ^^^^^^^^ ^^^^
> even after fixing your example to actually put the year into $t on my
> machine---it would only help if you didn't care that not all
> people born in 1979 are 18 years old yet.
> 
> why 'hack' around with scissors (and risk cutting yourself)
> when you can use a tool designed for the task at hand??

Really, and scissiors werent designed for cutting paper ... didn't we 
learn scissors in grade school.  But i guess i asked for that 'cause i'm 
probly more in the gradeschool perl anyway.  Does the Date module come
 stock with perl ... hmm ... not mine.

I would hope the person could assign a mapping for the variuous
months/days
and take it from this one liner to an actual dirthday function.  
(In less than 50 or so ugly lines ... not more than 63 k for sure and 
definitely no download/install stuff)

That's the beauty of it though right? There is more than one way to do
it?

> 
> #!/usr/bin/perl -w
> use Date::Manip;
> $bday="12311979"; # birthday in mmddyyyy format
> $bday=~s/^(\d\d)(\d\d)(\d\d\d\d)$/$1-$2-$3/;
> $bdate=&ParseDate($bday);
> $today=&ParseDate("today");
> &DateCalc($bdate,$today,undef,1)=~/([+-]\d+)/;
> print "$1:over 18\n" if $1>=18;
> print "$1:under 18\n" if $1<18;
> __END__
> 
> regards
> andrew

Nifty, thanks for the info, maybe this would be usefull in the long
haul.  
I will keep this in mind. 

--Ray


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

Date: Sun, 14 Sep 1997 23:14:40 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Comparing dates??
Message-Id: <341CB630.4AC4CC87@gpu.srv.ualberta.ca>

Ray Bush wrote:
! 
! Andrew Johnson wrote:
! >
! > Raymond K. Bush wrote:
! > !
! >
! > [snip]
! >
! > ! ( i think people take the system administrator chainsaw
! > ! analogy off the deep end ...why use a chainsaw when scissors
! > ! will do ...people and their bloody modules!)

[snip]

! > why 'hack' around with scissors (and risk cutting yourself)
! > when you can use a tool designed for the task at hand??
!
! Really, and scissiors werent designed for cutting paper ...
! didn't we learn scissors in grade school.  But i guess i

well, I personally don't consider proper date
manipulation/calculation to necessarily be a
grade-school paper-cutting exercise---but maybe
that's just me...

! asked for that 'cause i'm probly more in the gradeschool
!  perl anyway.  Does the Date module come stock with perl ...
!  hmm ... not mine.

negligent on my part, I apologize. ...the Date::Manip module
is available on CPAN under:
/CPAN/modules/by-category/06_Data_Type_Utilities/Date/
as with most (maybe even all?) modules on CPAN, it is relatively
painless to retrieve and install and it comes with very
complete built in documentation in POD format.

! That's the beauty of it though right? There is more than one
! way to do it?

very true...I'll usually pick the easy way whenever
circumstances allow, and for me, in this case, that would
be using a module.

[snip]
 
! Nifty, thanks for the info, maybe this would be usefull in the long
! haul.
! I will keep this in mind.

you're welcome

regards
andrew


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

Date: Sun, 14 Sep 1997 21:01:57 -0600
From: michael.nilsson@maze.se
Subject: Re: Free Perl CGI Script
Message-Id: <874288704.6539@dejanews.com>

In article <Pine.GSO.3.96.970914090639.17242N-100000@julie.teleport.com>,
  Tom Phoenix <rootbeer@teleport.com> wrote:
>
> On Sat, 13 Sep 1997 michael.nilsson@maze.se wrote:
>
> > I am aware of the potentially problem if some one that uses a proxy does
> > a failed log ins and block out the proxy address.
>
> So it's okay with you that any AOL user can block out all of the others?
> :-)

I don't now much about AOL but most of the ISP's use dynamic IP addresses
with means that you get ever changing IP address every time you log in.
So if you reconnect you will get a new IP address and 3 new tries to log
in to protect.pl

What I try to do here is to make it harder to write a program that
automatically hack protect.pl but if you want to use the script and don't
like this feature you can easily change the code.

The time lock we talk about here is not for ever the addresses are only
blocked until 00:00 (the script just checks the day number of the year)

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Mon, 15 Sep 1997 09:42:06 +0200
From: Pierre BERGDOLT <Pierre.Bergdolt@ansf.alcatel.fr>
Subject: How to redirect standard output of a backtick command
Message-Id: <341CE6CE.41C6@ansf.alcatel.fr>

Hi perl fans,

I'm trying to redirect the standard output of a perl backtick command
(wich is run in a subshell) to the standard output of my perl script.

A solution to get the output of the backtick command to standard output
is to write:

@log=`cmd`;
print @log;

but in this case I had to wait till `cmd` ends to print what's in @log
variable. And I don't want to wait.

Anyone got an idea? Thanks to answer me by e-mail.
-- 
-----------------------------------------------------------
Pierre Bergdolt            Pierre.Bergdolt@ansf.alcatel.fr
Alcatel TELECOM
1 a 7, rue Ampere               tel: + 33 (0)1.69.81.12.79
91300 Massy - FRANCE            fax: + 33 (0)1.69.81.17.23
-----------------------------------------------------------


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

Date: Sun, 14 Sep 1997 21:50:56 -0400
From: Ray Bush <rbush@up.net>
Subject: Re: Howto Parse data in spaced columns???
Message-Id: <341C9480.6699@up.net>

Raymond K. Bush wrote:
> 
> Gip wrote:
> >
> > How do I parse data out of the following computed text file, you can
> > assume no tabs, just plain old spaces:
> >
> >
> > column 1         column 2               column 3                column
> > 4
> >
> > aaa                  bbb                       ccc
> > ddd
> > eee                                                     fff
> >
> an off the top of my head inneficient way (in a pinch) might be (i'm
> open to suggestion myself):
> 
> open(file,"cat filename|cut -c$range1|");
> while(defined($=<file>){
> #check for item
> }
> open(file,"cat filename|cut -c$range2|");
> while(defined($=<file>){
> #check for item
> }
> open(file,"cat filename|cut -c$range3|");
> while(defined($=<file>){
> #check for item
> }
> open(file,"cat filename|cut -c$range4|");
> while(defined($=<file>){
> #check for item
> }
> 
> > I want to be able to know that fff is in column 4, and that ccc is in
> > column 3.
> >
> > Thanks for your time,
> > CG
> 

hmmm that is a useless use of cat ... oops sorry ...


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

Date: 15 Sep 1997 01:54:22 GMT
From: mweber@vt.edu (Matt Weber)
Subject: Inserting \n in a string
Message-Id: <5vi4ge$3ll$1@solaris.cc.vt.edu>

I want to insert a new line (\n) every 75 charectors in a string...any 
suggestions?  I just don't know what function to use.

MW
http://www.weberworld.com



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

Date: Sun, 14 Sep 1997 21:36:19 -0600
From: rbush@up.net
Subject: Re: is there a better way to do this subroutine?
Message-Id: <874286265.4719@dejanews.com>

In article <5veg61$d0a@shoga.wwa.com>,
  scribble@shoga.wwa.com (Tushar Samant) wrote:
>
> rbush@up.net writes:
> >Since you dont understand perl i shall tell you what it does.
>
> No, he doesn't understand YOU. Given your horrendous code, it's not
> surprising; I am surprised someone risked their neurons by actually

I hear it is horrendous .. i know it is ... that was why i posted it but
if you cannot understand a simple subroutine that takes a pair of arrays
and does some thing with them i'm afraid you are lost even as an "average
programmer"

> reading it. By the way, all of us average programmers know that code
> by itself has (a syntactic structure and) a function, but no meaning
> until coupled with the assumptions in the coder's head and the rest

I disagree, existence is all the meaning there will ever be and all there
ever need be. Some code has inherent meaning accross the board. I wonder
if you could spot self replicating code in any kind of medium.	I didnt
think this one wasx "so hard" for the "average" programmer.  Or is it
perhaps that a lot of "programmers" are just hackers from other fields
monkeying where they dont really have much of a clue.

This is not about meaning; meaning is a pointless issue. Meaning was not
needed for the task i had asked about.	Anyone who makes assumptions so
errroneous in my book doesn't know what he is or should be doing.

> of the universe. When you understand that, you will start progressing
> towards averageness. Good luck ..

Who in the hell want's to be average.  I'd rather bounce around a bit.  I
suppose you dont like rolercoasters either.

The average are doomed to die of boredom.


--ray

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Sun, 14 Sep 1997 22:42:32 -0400
From: Ray Bush <rbush@up.net>
Subject: Re: is there a better way to do this subroutine?
Message-Id: <341CA098.7AF4@up.net>

Matthew Cravit wrote:
> 
> >> >         local(*p,*plog)=@_;
> >>                 ^^^^^^^^
> >
> >oh really cant recognize two arrays being passed in ... this is right
> >out of the perl5 book example

My apologies, but, where does it say this is bad?  
Either i missed it or havent got that far in the new book.

> 
> Yes, but if you read the rest of the page that's on (the bottom of page 117
> in the blue Camel), it says that you're effectively doing symbol table
> aliasing, and you then need to invoke this function like:
> 
>         (*something) = Function(\@p, \@plog);
> 
> Is that what you used?

Nope i used:

       @REPORT= &SPL(\@P,\@PLOG);         

> 
> In any case, the safer way to pass multiple arrays to a subroutine is to
> use a reference, like so:
> 
> # Call with Subname(\@array1, \@array2)
> sub Subname {
>     my ($ary1ref, $ary2ref) = @_;
>     my (@ary1)              = @$ary1ref;
>     my (@ary2)              = @$ary2ref;
> 
>     ...
> }

hmmm ... safer ... could it be that i had called the function wrong and
got 
addresses instead of array entries and that is why i didnt use this ...

> Passing typeglobs around was a perl 4 way of doing stuff, in general, and
> is frowned upon in perl 5 except in 2 specific cases:
> 

I'm not sure why this is frowned upon.  Please explain?

>      - Passing a filehandle:    Do_Something(\*STDIN);
>      - Symbol table aliasing (like above)
> 
> >if my string is empty then append $ple
> >
> >else do this cause i dont want leading pipes
> 
> It might be faster to always do the append, and then strip off the leading
> pipe when you're done. That way you don't have to do the decision logic in
> your loop every time. If you're iterating over a large number of entries,
> you might find it worth it to do a quick test with the Benchmark module and
> see how much time you'd save by leaving out the if.
> 

Trying this as i type.

The array is rather large.  I'm wondering if theres a way i can fork it
out as smaller groups 
and get a quicker psudo "sort".  Mayabe put the pieces back together
afterward.

Guess i'm going to have to read a bit further and a lot closer.  

> /MC
> 
> --
> Matthew Cravit, N9VWG               | Experience is what allows you to
> E-mail: mcravit@best.com (home)     | recognize a mistake the second
>         mcravit@taos.com (work)     | time you make it.

Thanks for the help ...

--Ray


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

Date: 15 Sep 1997 06:39:24 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: is there a better way to do this subroutine?
Message-Id: <5vil6s$grm$1@comdyn.comdyn.com.au>

In article <874286265.4719@dejanews.com>,
	rbush@up.net writes:
> Who in the hell want's to be average.  I'd rather bounce around a bit.  I
> suppose you dont like rolercoasters either.
> 
> The average are doomed to die of boredom.

hmm, this starts to sound a bit like a troll :)



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

Date: 15 Sep 1997 00:59:06 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: Is there a more efficient way to interweave 2 arrays?
Message-Id: <5vi18q$73o$1@daily.bbnplanet.com>

In article <Pine.GSO.3.96.970913070542.12359J-100000@julie.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>On Fri, 12 Sep 1997, Nim Chu wrote:
>
>> Is there a more efficient way (less cpu, and/or no need to generate a
>> third array) to do the equivalent of following code:
>> 
>> @odd=(1,3,5,7);
>> @even=(2,4,6,8);
>> foreach $i (0..$#even) {
>> push @all, $odd[$i], $even[$i];
>> }

I don't think there is a way that you could do this with fewer memory 
operations, which is the hog with this operation with big arrays.

Things to think about:
1. Do you need to create the two arrays before trying to merge ? 
2. Do you really need to create the new array as an array ? 

In response to 2, if you need to access only a few elements you might get 
away with figuring out which array (odd or even) and subscript it 
corresponds to from the subscript in the merged array.
You know that all[i] = a[i/2] or b[i/2] - not real code.

If you need to access all the elements of the array then trying what Tom 
mentioned is really the best you can do.

Jason Gloudon


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

Date: 15 Sep 1997 03:38:40 GMT
From: wings <xuchu@iscs.nus.edu.sg>
Subject: pattern matching problem
Message-Id: <5viak0$kt3@nuscc.nus.sg>

Hi, can someone help me with this pattern matching problem? what i wanna do is 
to extract the contents between two certain tags. look at this example:

<date>970915</date>line test test
abcdef<date>970916</date>
test test<date>123
970717
test test test
</date>
example<date>
test 97-07-18 </date>
example

Say i want to print all b/w <date> and </date>. but using s/<date>(.*?)<\date>/
and print $1 will only get "970915" and "970916" since other dates tags pairs are
not within the same line. however, using 
 while (($_ = $lines) !~ /<date>/i) {};
 while (($_ = $lines) !~ /<\/date>/i { print;} 
wont print the "123" and "test 97-07-18". 

is there any brain who can teach me how to solve this? thx.

-- 
wings
------
You cannot learn anything unless you almost know it already.



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

Date: Mon, 15 Sep 1997 03:44:07 GMT
From: slundy@mer.cioe.com (Capt. COBOL)
Subject: Premature End Of Script Headers
Message-Id: <341daecb.129927551@newsread.cioe.com>

What does this mean and where should I look for the error.  It sounds
like it's not processing the headers correctly, but I'm not sure,
kinda new to perl and cgi...thanks for any help


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

Date: Mon, 15 Sep 1997 12:16:52 +0800
From: Bremen Lee <bremenlee@12345.hk>
Subject: Simple question.
Message-Id: <341CB6B4.4B3@12345.hk>

Hi,

How can I write a simple perl script to check if the file is
modified exactly today.



Cheers,

Bremen


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

Date: 15 Sep 1997 06:58:58 GMT
From: "Mr. Chow Wing Siu" <wschow@Comp.HKBU.Edu.HK>
Subject: use Socket -> core dump on SunOS
Message-Id: <5vimbi$5eu$1@power42t.hkbu.edu.hk>



This is 5.004_03 on SunOS 4.1.x. I do not know how to fix the core
dump problem on using Socket. The simple program:
- -------------------------------------------------------------------------
#!/usr/local/bin/perl5
use Socket;
- -------------------------------------------------------------------------
/usr/local/packages/perl5.004_03/sunos/lib/sun4-sunos/5.00403/Socket.pm:
package Socket;

use vars qw($VERSION @ISA @EXPORT);
$VERSION = "1.6";

=head1 NAME

Socket, sockaddr_in, sockaddr_un, inet_aton, inet_ntoa - load the C socket.h defines and structure manipulators 

=head1 SYNOPSIS

    use Socket;

    $proto = getprotobyname('udp');
    socket(Socket_Handle, PF_INET, SOCK_DGRAM, $proto);
    $iaddr = gethostbyname('hishost.com');
    $port = getservbyname('time', 'udp');
    $sin = sockaddr_in($port, $iaddr);
    send(Socket_Handle, 0, 0, $sin);

    $proto = getprotobyname('tcp');
    socket(Socket_Handle, PF_INET, SOCK_STREAM, $proto);
    $port = getservbyname('smtp');
    $sin = sockaddr_in($port,inet_aton("127.1"));
    $sin = sockaddr_in(7,inet_aton("localhost"));
    $sin = sockaddr_in(7,INADDR_LOOPBACK);
    connect(Socket_Handle,$sin);

    ($port, $iaddr) = sockaddr_in(getpeername(Socket_Handle));
    $peer_host = gethostbyaddr($iaddr, AF_INET);
    $peer_addr = inet_ntoa($iaddr);

    $proto = getprotobyname('tcp');
    socket(Socket_Handle, PF_UNIX, SOCK_STREAM, $proto);
    unlink('/tmp/usock');
    $sun = sockaddr_un('/tmp/usock');
    connect(Socket_Handle,$sun);

=head1 DESCRIPTION

This module is just a translation of the C F<socket.h> file.
Unlike the old mechanism of requiring a translated F<socket.ph>
file, this uses the B<h2xs> program (see the Perl source distribution)
and your native C compiler.  This means that it has a 
far more likely chance of getting the numbers right.  This includes
all of the commonly used pound-defines like AF_INET, SOCK_STREAM, etc.

In addition, some structure manipulation functions are available:

=over

=item inet_aton HOSTNAME

Takes a string giving the name of a host, and translates that
to the 4-byte string (structure). Takes arguments of both
the 'rtfm.mit.edu' type and '18.181.0.24'. If the host name
cannot be resolved, returns undef. For multi-homed hosts (hosts
with more than one address), the first address found is returned.

=item inet_ntoa IP_ADDRESS

Takes a four byte ip address (as returned by inet_aton())
and translates it into a string of the form 'd.d.d.d'
where the 'd's are numbers less than 256 (the normal
readable four dotted number notation for internet addresses).

=item INADDR_ANY

Note: does not return a number, but a packed string.

Returns the 4-byte wildcard ip address which specifies any
of the hosts ip addresses. (A particular machine can have
more than one ip address, each address corresponding to
a particular network interface. This wildcard address
allows you to bind to all of them simultaneously.)
Normally equivalent to inet_aton('0.0.0.0').

=item INADDR_BROADCAST

Note: does not return a number, but a packed string.

Returns the 4-byte 'this-lan' ip broadcast address.
This can be useful for some protocols to solicit information
from all servers on the same LAN cable.
Normally equivalent to inet_aton('255.255.255.255').

=item INADDR_LOOPBACK

Note - does not return a number.

Returns the 4-byte loopback address. Normally equivalent
to inet_aton('localhost').

=item INADDR_NONE

Note - does not return a number.

Returns the 4-byte 'invalid' ip address. Normally equivalent
to inet_aton('255.255.255.255').

=item sockaddr_in PORT, ADDRESS

=item sockaddr_in SOCKADDR_IN

In an array context, unpacks its SOCKADDR_IN argument and returns an array
consisting of (PORT, ADDRESS).  In a scalar context, packs its (PORT,
ADDRESS) arguments as a SOCKADDR_IN and returns it.  If this is confusing,
use pack_sockaddr_in() and unpack_sockaddr_in() explicitly.

=item pack_sockaddr_in PORT, IP_ADDRESS

Takes two arguments, a port number and a 4 byte IP_ADDRESS (as returned by
inet_aton()). Returns the sockaddr_in structure with those arguments
packed in with AF_INET filled in.  For internet domain sockets, this
structure is normally what you need for the arguments in bind(),
connect(), and send(), and is also returned by getpeername(),
getsockname() and recv().

=item unpack_sockaddr_in SOCKADDR_IN

Takes a sockaddr_in structure (as returned by pack_sockaddr_in()) and
returns an array of two elements: the port and the 4-byte ip-address.
Will croak if the structure does not have AF_INET in the right place.

=item sockaddr_un PATHNAME

=item sockaddr_un SOCKADDR_UN

In an array context, unpacks its SOCKADDR_UN argument and returns an array
consisting of (PATHNAME).  In a scalar context, packs its PATHNAME
arguments as a SOCKADDR_UN and returns it.  If this is confusing, use
pack_sockaddr_un() and unpack_sockaddr_un() explicitly.
These are only supported if your system has E<lt>F<sys/un.h>E<gt>.

=item pack_sockaddr_un PATH

Takes one argument, a pathname. Returns the sockaddr_un structure with
that path packed in with AF_UNIX filled in. For unix domain sockets, this
structure is normally what you need for the arguments in bind(),
connect(), and send(), and is also returned by getpeername(),
getsockname() and recv().

=item unpack_sockaddr_un SOCKADDR_UN

Takes a sockaddr_un structure (as returned by pack_sockaddr_un())
and returns the pathname.  Will croak if the structure does not
have AF_UNIX in the right place.

=back

=cut

use Carp;

require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(
	inet_aton inet_ntoa pack_sockaddr_in unpack_sockaddr_in
	pack_sockaddr_un unpack_sockaddr_un
	sockaddr_in sockaddr_un
	INADDR_ANY INADDR_BROADCAST INADDR_LOOPBACK INADDR_NONE
	AF_802
	AF_APPLETALK
	AF_CCITT
	AF_CHAOS
	AF_DATAKIT
	AF_DECnet
	AF_DLI
	AF_ECMA
	AF_GOSIP
	AF_HYLINK
	AF_IMPLINK
	AF_INET
	AF_LAT
	AF_MAX
	AF_NBS
	AF_NIT
	AF_NS
	AF_OSI
	AF_OSINET
	AF_PUP
	AF_SNA
	AF_UNIX
	AF_UNSPEC
	AF_X25
	MSG_DONTROUTE
	MSG_MAXIOVLEN
	MSG_OOB
	MSG_PEEK
	PF_802
	PF_APPLETALK
	PF_CCITT
	PF_CHAOS
	PF_DATAKIT
	PF_DECnet
	PF_DLI
	PF_ECMA
	PF_GOSIP
	PF_HYLINK
	PF_IMPLINK
	PF_INET
	PF_LAT
	PF_MAX
	PF_NBS
	PF_NIT
	PF_NS
	PF_OSI
	PF_OSINET
	PF_PUP
	PF_SNA
	PF_UNIX
	PF_UNSPEC
	PF_X25
	SOCK_DGRAM
	SOCK_RAW
	SOCK_RDM
	SOCK_SEQPACKET
	SOCK_STREAM
	SOL_SOCKET
	SOMAXCONN
	SO_ACCEPTCONN
	SO_BROADCAST
	SO_DEBUG
	SO_DONTLINGER
	SO_DONTROUTE
	SO_ERROR
	SO_KEEPALIVE
	SO_LINGER
	SO_OOBINLINE
	SO_RCVBUF
	SO_RCVLOWAT
	SO_RCVTIMEO
	SO_REUSEADDR
	SO_SNDBUF
	SO_SNDLOWAT
	SO_SNDTIMEO
	SO_TYPE
	SO_USELOOPBACK
);

sub sockaddr_in {
    if (@_ == 6 && !wantarray) { # perl5.001m compat; use this && die
	my($af, $port, @quad) = @_;
	carp "6-ARG sockaddr_in call is deprecated" if $^W;
	pack_sockaddr_in($port, inet_aton(join('.', @quad)));
    } elsif (wantarray) {
	croak "usage:   (port,iaddr) = sockaddr_in(sin_sv)" unless @_ == 1;
        unpack_sockaddr_in(@_);
    } else {
	croak "usage:   sin_sv = sockaddr_in(port,iaddr))" unless @_ == 2;
        pack_sockaddr_in(@_);
    }
}

sub sockaddr_un {
    if (wantarray) {
	croak "usage:   (filename) = sockaddr_un(sun_sv)" unless @_ == 1;
        unpack_sockaddr_un(@_);
    } else {
	croak "usage:   sun_sv = sockaddr_un(filename)" unless @_ == 1;
        pack_sockaddr_un(@_);
    }
}


sub AUTOLOAD {
    my($constname);
    ($constname = $AUTOLOAD) =~ s/.*:://;
    my $val = constant($constname, @_ ? $_[0] : 0);
    if ($! != 0) {
	my ($pack,$file,$line) = caller;
	croak "Your vendor has not defined Socket macro $constname, used";
    }
    eval "sub $AUTOLOAD { $val }";
    goto &$AUTOLOAD;
}

bootstrap Socket $VERSION;

1;

- -- 
PGP PUBLIC KEY: https://www.comp.hkbu.edu.hk/~wschow/pgp.html
Key fingerprint = 15 C4 36 D6 EC CF 1D A4  7F D8 F9 EF 2E D7 32 A6


Version: 2.6.3i
Charset: noconv

iQCVAwUBNBzfS73ixeOqBhAdAQH5FwQAsp09WwK/XbKzd9XBPIEhezDErl+v1PMk
nJCJjla/DTbOpwcOMS13Llcr5P76yShHX/fBcuc8ayZO6zY7uzAMPaq2F4zspW8V
nVMGZ3ERXxkQfd7tRfwVqWVQf5e9s/+dy7v0sdDLmL+rusmuFmuZoJwGkFZFJtNu
Zlry4m/nCLs=
=6sTG
-----END PGP SIGNATURE-----


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

Date: Sun, 14 Sep 1997 21:07:16 -0400
From: Anagrams of the Word 'A' <jefpin@bergen.org>
To: Faust Gertz <faust@wwa.com>
Subject: Re: Why don't my <<HERE documents work?  Attempt #2!
Message-Id: <Pine.SGI.3.95.970914210604.26205C-100000@vangogh.bergen.org>


>#!/user/local/bin/perl -w
>use strict;   #   'cause it's in the FAQ :-)
>print <<EOF;
>This is a test!
>EOF
>exit;

correct syntax i:

#!/user/local/bin/perl -w
use strict;   #   'cause it's in the FAQ :-)
print <<EOF
This is a test!
EOF
exit;

notice there is NO semicolon after the <<EOF
also, I don't think the exit is required... semicolon would do just fine.

----------------
| "Shooting is NOT too good for my enemies!"
| 	- "The Overlord List"
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem?  Let me know!

webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS

- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>+++1094++++ L E--->---- W++++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y? 
- geek code -



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1025
**************************************

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