[10685] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4277 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 23 05:08:06 1998

Date: Mon, 23 Nov 98 02:00:23 -0800
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, 23 Nov 1998     Volume: 8 Number: 4277

Today's topics:
        any more pattern matching (complex...) examples ? <khan@cadence.com>
        Difficult Pattern matching problem in PERL <khan@cadence.com>
    Re: Difficult Pattern matching problem in PERL <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Does (.*?) do what I think it does? (Edward Broyles)
    Re: Does (.*?) do what I think it does? <bnies@hsr.ch>
        flock question (Antti-Jussi Korjonen)
    Re: help with a new game <trikiw@hotmail.com>
    Re: help with a new game <jhoglund@mirage.skypoint.net>
    Re: How to make a pattern non-greedy in Perl 4 (Bart Lateur)
        How to tell if a file is being written to? <scott.searle@noway.nz>
    Re: HTTP_REFERER and Browser History <dan@clockwork.net>
    Re: Mastering Regular Expressions (was Re: Recommend Pe (Ilya Zakharevich)
    Re: Mastering Regular Expressions (was Re: Recommend Pe <uri@sysarch.com>
    Re: Mastering Regular Expressions (was Re: Recommend Pe (Ilya Zakharevich)
    Re: NT perl and mail (M.)
        Passing parameters and returning values <amcnulty@nortel.co.uk>
    Re: Passing parameters and returning values (Sam Holden)
        Perl 4 - Non-greedy regexp <minich@globalnet.co.uk>
        Question on dbmopen( ) and dbmclose( ). <cjs@shinbiro.com>
        Quickie <amcnulty@nortel.co.uk>
    Re: Raw Sockets <jshaw@vellocet.insync.net>
    Re: Raw Sockets <jshaw@vellocet.insync.net>
    Re: Regular expression problem... (Ilya Zakharevich)
        Seeking Win32::DES.pm <xyz-andrew_lee@earthlink.net>
        Self Replicating Sites? <jjarrett@ecpi.com>
    Re: shopping cart <jhoglund@mirage.skypoint.net>
        Socket Programming in Perl <hayati@ocf.Berkeley.EDU>
    Re: Socket Programming in Perl (Sam Holden)
    Re: Socket Programming in Perl <xyz-andrew_lee@earthlink.net>
        Sorting DB but starting in middle (Mark Thompson)
    Re: supressing output from external program in perl (Larry Rosler)
        sysread / need help w/ single byte I/O, urgent!  please (Ralph Forsythe)
        Trouble installing Date::Manip module <grant.ozolins@anu.edu.au>
        Using multiple dbm files <jposey@mindspring.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 23 Nov 1998 01:22:04 -0800
From: Han Kim <khan@cadence.com>
Subject: any more pattern matching (complex...) examples ?
Message-Id: <3659293C.7A55C3B@cadence.com>

Hi There,

Is there any pattern matching examples I can get thru the internet?

Thank you in advance...

Han at khan@cadence.com




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

Date: Mon, 23 Nov 1998 01:19:59 -0800
From: Han Kim <khan@cadence.com>
Subject: Difficult Pattern matching problem in PERL
Message-Id: <365928BE.216F3827@cadence.com>

Hi There,

I am struggling to find out any easy way of eliminating any thing
inbetween "/*" and "*/"
 ....

eg: If I have a line like:

"/*Hi there*/ dont touch this /*please get this out*/  please"

How can I use the substitution method in pearl to just get:


"dont touch this please"

Again, I want to use the substitution method...
I tried the following but it erases the "dont touch this" portion....
 $_ =~ s/\/\*.+\*\///g;

(The above writes out "please" only....)

Another way is to use the list......I really do not like this since this
basically reads
every character...longer run time...

________________________________________
$A = "d;sjf; /*fee*/ module han /*bee*/";

@A = split("", $A);

$isComment = 0;
$B = "" ;
for ($i=0; $i<scalar(@A)-0; $i++)
{
  if (@A[$i] eq "/" && @A[$i+1] eq "*")
  {
      $isComment = 1;
      $i = $i+ 2;
  }
  if (@A[$i] eq "*" && @A[$i+1] eq "/")
  {
      $isComment = 0;
      $i = $i + 2;
  }
  if ($isComment == 0)
  {
      $B = $B . "@A[$i]";
  }
}


print "$B\n";
_________________________
Please help.......................

Han  at khan@cadence.com
Thanks in advance....



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

Date: 23 Nov 1998 10:31:10 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Difficult Pattern matching problem in PERL
Message-Id: <83yap2dach.fsf@vcpc.univie.ac.at>

Re: Difficult Pattern matching problem in PERL, Han
<khan@cadence.com> said:

Han> Hi There, I am struggling to find out any easy way of
Han> eliminating any thing inbetween "/*" and "*/" ....

Han> eg: If I have a line like:

Han> "/*Hi there*/ dont touch this /*please get this out*/
Han> please"

Han> How can I use the substitution method in pearl to just

                                              ^^^^^ perl

Han> "dont touch this please"

Han> Again, I want to use the substitution method...  I
Han> tried the following but it erases the "dont touch this"
Han> portion....  $_ =~ s/\/\*.+\*\///g;

This is because the pattern is greedy and so gobbles both
comments in one go.  The _maximal_ match for "one or more
any-character followed by */" takes out both comments.

So you need to make the match more frugal, e.g.

    s(/\*[^*]*\*/)()g;

(I'd use the * closure instead of + because that also
matches /**/ "smash" comments)

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 23 Nov 1998 07:24:33 GMT
From: ez065718@dogbert.ucdavis.edu (Edward Broyles)
Subject: Does (.*?) do what I think it does?
Message-Id: <73b2jh$3s9$1@mark.ucdavis.edu>

Will this do what I want:

/(.*?),(.*?),(.*?)/

$abc = $1;
$def = $2;
$ghi = $3;

What I want to do is read each comma delimited item into its own variable.  The Camel book was unclear
whether I could use parens in this way or if I need to put . for each char (and know the length of each
var, which I do not.

Thanks!

 -- 
Edward Broyles
ewbroyles@ucdavis.edu


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

Date: Mon, 23 Nov 1998 09:26:25 +0100
From: Bernd Nies <bnies@hsr.ch>
Subject: Re: Does (.*?) do what I think it does?
Message-Id: <36591C31.ED7D26CD@hsr.ch>

Edward Broyles wrote:
> 
> Will this do what I want:
> 
> /(.*?),(.*?),(.*?)/
> 
> $abc = $1;
> $def = $2;
> $ghi = $3;
> 
> What I want to do is read each comma delimited item into its own variable.  The Camel book was unclear
> whether I could use parens in this way or if I need to put . for each char (and know the length of each
> var, which I do not.

Better this way:

  ($abc,$def,$ghi) = split(/,/,$yourstringhere);

 .*  means a character apperars zero or more times (a comma
    is also a charachter)
 .?  means a charachter may or may not match.
 .*? useless

Regards,
Bernd
       _
_____ | | ___________________________________________
\__  \| | Bernd Nies         bernd.nies@astroinfo.org
 / __ \\| Chindismuelistr.6  http://www.astroinfo.org
(____  /_ CH-8626 Ottikon 
     \/\/


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

Date: 23 Nov 1998 09:30:04 GMT
From: aajii@raaseri.ton.tut.fi (Antti-Jussi Korjonen)
Subject: flock question
Message-Id: <73b9us$b17$1@baker.cc.tut.fi>

Hi!

How does perl behave, when trying to open a file locked with flock,
does it try again or does it give up after one try?
Is it possible to alter the number of tries not using any loops?

--
  
         __/                __/ __/  __/     Antti-Jussi Korjonen
      __/ __/    __/       __/ __/__/       Vaajakatu 5 D 85
    __/    __/      __/   __/ __/__/       33720 TAMPERE, FINLAND
  __/       __/    __/__/__/ __/  __/     tel. +358-(0)40-577 83 23
                                         Antti-Jussi.Korjonen@sonera.fi
   --------->>  http://www.students.tut.fi/~k150556  <<---------
     


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

Date: Mon, 23 Nov 1998 04:12:44 GMT
From: Ricardo Dague <trikiw@hotmail.com>
Subject: Re: help with a new game
Message-Id: <3658E087.3676C557@hotmail.com>

dragonelf@webtv.net wrote:
> 
> what would be better to use to build a text multiplayer
> game? perl, c++,
> basic? any responses please

A text adventure played on two computers via the internet?
That's called a MUD (Multi User Domain), I think. You might
look up the rec.arts.int-fiction newsgroup, and check out
http://fovea.retina.net:4001.

-- Ricardo


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

Date: 23 Nov 1998 09:30:34 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: help with a new game
Message-Id: <73b9vq$50r$2@shadow.skypoint.net>

dragonelf@webtv.net wrote:

: what would be better to use to build a text multiplayer game? perl, c++,
: basic? any responses please

Probably english. (depending of course on who is playing it)

Jamie


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

Date: Mon, 23 Nov 1998 08:41:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to make a pattern non-greedy in Perl 4
Message-Id: <365c1aac.725998@news.skynet.be>

Martin wrote:

>I've just found out the the ? modifier won't work in Perl 4.
>
>I have the regexp:
>
>s/abc(.*?)abc/$FOO{$1}/sg;
>
>which works fine under Perl 5 but Perl 4 won't accept the ? modifier to make
>the match .* non-greedy. I normally use Perl 5 so have never come across
>this problem before. How can regexps be made non-greedy in Perl 4?

This smells like template filling. The simple solution would be to
change the template definition, so you no longer need minimal matching:
replace the delimeters to symmetrical and non-word, and demand that the
variable names will be one word. This will make your templates less
confusing.

Compare:

	My name is abcname of blokeabc, and I'm from 
	abccountry or stateabc.
to
	My name is {name}, and I'm from {country_state}.

So all you need is:

	s/{(\w+)}/$FOO{$1}/sg;


And now, for an answer to your actual question: the only way you can do
that in Perl 4 is by using multiple matches, deleting what came before
in the process. Something like this:

	while (/abc/) {
		print $`; # copy what came before
		$_ = $';  # keep only what follows
		if(/abc/) { # end delimiter
			print $FOO{$`}; # replace
			$_ = $';  # keep only what follows
		}
	}
	print;	# all the rest


Note that the behaviour is still somewhat different to what you wrote
for Perl5, in particular with regards to improper matches.
	
HTH,
Bart.


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

Date: Mon, 23 Nov 1998 14:33:47 +1200
From: Scott Searle <scott.searle@noway.nz>
Subject: How to tell if a file is being written to?
Message-Id: <3658BB7B.27D3ABE5@noway.nz>

Gidday folks,

    Just a quick question here, but how might I go about seeing if a
process is idle, or if it is active.  I am trying to restart a database
server, but it is critical that no records are being
added/deleted/modified etc, while the database accessed.  My first
attempt was to run the truss command on the pid of the database (truss
-p pid), which worked -- it showed me that my file was not being written
to, however there has to be a much easier way to do this.

    I will try to give a detailed description here.  A C program fires
up and forks copies of itself to load and monitor 6 databases which are
multiplexed (for lack of a better word) to reduce the load to one single
database.  When the databases are larger than 80MB, they are to be
killed, and restarted (the parent process takes care of restarting
them).  I need to find a way that when say Database0 is larger than
80MB, and *NOT* being written to, the perl script kills it.

    When the pid of Database0 is passed through truss, and isn't active,
it shows sleeping, which I presume means it is inactive.  Therefore it
should be ok to kill the database, and have the parent reload it.  One
problem, truss doesn't appear to end, unless it receives a ctrl-c.  Do I
need to fork a copy of my kill script, load truss in the child, then
kill it after I get my reading?  Seems kind of flakey.  Can anyone offer
any suggestions?


Cheers,

Scott

-------------------------------------------
Scott Searle - Wholesale UNIX Support
National Bank of New Zealand Limited
Ph: +64 4 382 7841 Fax: +64 4 802 2356
email: scott.searle@nbnz.co.nz




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

Date: Sun, 22 Nov 1998 22:26:21 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: HTTP_REFERER and Browser History
Message-Id: <3658E3ED.F22484D1@clockwork.net>

Whether specified in the RFC or not, it's still a web server dependent
variable, as in, the web server sets the variable? If you had read the
original question, you would see that the poster didn't understand this
fact. I also prefaced my comments with "I don't know" ... so get off it.

I'm always amused by petty criticisms of those who try to help by posting
very *relevant* responses to questions.


Martien Verbruggen wrote:

> In article <365751B6.23AF1FD3@clockwork.net>,
>         Dan Brian <dan@clockwork.net> writes:
>
> > HTTP_REFERER (and all CGI ENV variables) are web-server-dependent
> > variables; I don't know if HTTP_REFERER exists outside of Apache.
>
> Nonsense. HTTP_REFERER is specified by the RFC and the original NCSA
> documentation on CGI.
>
> Of course, it is not specified by name, but under the general header
> of 'The header lines received from the client' in the original NCSA
> documentation, and under the HTTP_* header in the RFC.
>
> You didn't only post irrelevant and off-topic material to clp.misc,
> but it is also incorrect.
>
> Martien
> --
> Martien Verbruggen                  |
> Webmaster www.tradingpost.com.au    | The gene pool could use a little
> Commercial Dynamics Pty. Ltd.       | chlorine.
> NSW, Australia                      |





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

Date: 23 Nov 1998 03:09:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Mastering Regular Expressions (was Re: Recommend Perl books?)
Message-Id: <73ajm2$qhb$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x7k90n1ac7.fsf@sysarch.com>:
> >>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
> 
>   IZ> I think most things *are* wrong now.  (Except the simplest ones, which
>   IZ> one should not bother to look into any book for.)
> 
> i beg to differ. 

Well, I know whose opinion *I* would trust.  ;-)

> table. it even refers to 5.002. so for the great majority of perl users
> and most hackers it covers the regex stuff we need. and it explains the
> guts and logic of using the main features better than any other text
> (printed or online) anywhere.

 ...

> i agree that specific details of bleeding edge features are not covered
> but anyone who knows about them would know enough to check the online
> docs.

You still think that the principal change to REx engine in 5.005 was
an addition of new features.

Ilya


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

Date: 22 Nov 1998 22:23:35 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Mastering Regular Expressions (was Re: Recommend Perl books?)
Message-Id: <x767c71494.fsf@sysarch.com>


>>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:

  >> i beg to differ. 

  IZ> Well, I know whose opinion *I* would trust.  ;-)

i can handle that. :-)

  >> i agree that specific details of bleeding edge features are not covered
  >> but anyone who knows about them would know enough to check the online
  >> docs.

  IZ> You still think that the principal change to REx engine in 5.005 was
  IZ> an addition of new features.

well, what else would invalidate MRE? a speedier engine doesn't change
the functionality (it shouldn't). qr// is new and very useful for all. i
know you can roll your own parser and engine but again that is for
experts (like you! :-). i consider myself competent in regexes but i
don't envision myself using that feature soon. is there a good listing
of just the new regex stuff in 5.005 that would be of use to most regex
users?  from what i gather most of the new stuff is only for the elite.

my main point is that MRE is great for what it is (BTW IMO it is a great
computer book in general) and it should be promoted as a useful tool to
improve your regex abilities. the fact that it is out of date (by
different measures according to you or me) is irrelevant to its ability
to improve regex skills. the subset (large or small) it covers is larger
than most users will ever use or need, so it is valid from that point of
view. yes, a second edition would be nice but how long will that take?
o'reilly doesn't pump out new versions as fast as p5p does! :-)

humbly, your lessor regex user,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 23 Nov 1998 04:44:28 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Mastering Regular Expressions (was Re: Recommend Perl books?)
Message-Id: <73ap7c$su$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x767c71494.fsf@sysarch.com>:
>   IZ> You still think that the principal change to REx engine in 5.005 was
>   IZ> an addition of new features.
> 
> well, what else would invalidate MRE? a speedier engine doesn't change
> the functionality (it shouldn't).

The Hip Owl is about what is good, what is bad and what is ugly.  A
speedier REx engine will change all this.  An engine without bugs will
change this (well, I know about 3 obscure bugs with the currentn code ;-).

Ilya


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

Date: Mon, 23 Nov 1998 09:52:23 GMT
From: pub @ alma . ch (M.)
Subject: Re: NT perl and mail
Message-Id: <36593026.26829229@news.urbanet.ch>

Have a look at http://alma.ch/perl/mail.htm

>I know how to do mail from unix perl scripts. (sendmail)
>
>Is there a way, or module to do mail from NT perl scripts.  If so, sample
>please, and what needs to be set up on the machine running the perl.
>
>I have a script that is looking at database issues and needs to notify a
>person if there is problems, since they won't take the time to read the log
>on the machine.
>
>Thanks
>
>ruth
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    



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

Date: Mon, 23 Nov 1998 07:37:20 -0000
From: "Antony" <amcnulty@nortel.co.uk>
Subject: Passing parameters and returning values
Message-Id: <73b3dl$gc@bmdhh222.europe.nortel.com>

Can this be done with the sub-routines in Perl ?

i.e the following situation....

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

&mysub("hello world\n");

:
:

sub mysub ($string) {
    print STDOUT $string;
}

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



It would make most of my scripts easier if you could.


Cheers,

Antony





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

Date: 23 Nov 1998 07:48:06 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Passing parameters and returning values
Message-Id: <slrn75i4pm.4ha.sholden@pgrad.cs.usyd.edu.au>

On Mon, 23 Nov 1998 07:37:20 -0000, Antony <amcnulty@nortel.co.uk> wrote:
>Can this be done with the sub-routines in Perl ?
>
>i.e the following situation....
>
>---------------------------------------------
>
>&mysub("hello world\n");
>
>:
>:
>
>sub mysub ($string) {
>    print STDOUT $string;
>}
>
>---------------------------------------------
>
>
>
>It would make most of my scripts easier if you could.

No... perl doesn't work like that you can use :
sub mysub
{
	my ($arg1, $arg2, $arg3, $arg4) = @_;
	...
)
 
Which is really the same as what you have the argument names have just
been moved down a bit. When passing non-scalars references are needed but
that is a another story...

-- 
Sam

So I did some research. On the Web, of course. Big mistake...
	--Larry Wall


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

Date: Sun, 22 Nov 1998 17:09:49 -0000
From: "Martin" <minich@globalnet.co.uk>
Subject: Perl 4 - Non-greedy regexp
Message-Id: <739gfe$cs4$1@newnews.global.net.uk>

I've just found out the the ? modifier won't work in Perl 4.

I have the regexp:

s/abc(.*?)abc/$FOO{$1}/sg;

which works fine under Perl 5 but Perl 4 won't accept the ? modifier to make
the match .* non-greedy. I normally use Perl 5 so have never come across
this
problem before. How can regexps be made non-greedy in Perl 4?

Martin




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

Date: Mon, 23 Nov 1998 16:16:58 +0900
From: Jun Sam Choi <cjs@shinbiro.com>
Subject: Question on dbmopen( ) and dbmclose( ).
Message-Id: <36590BEA.725D@shinbiro.com>

I have a problem in Perl CGI programming using dbmOpen() & dbmClose();
dbmOpen() created two files person.dir & person.pag. 
 .dir file size is 0 and .pag's is 1024Byte.
I could insert serveral records in dbm file and could see them through
web browser.  
But, After some records is inserted dbm file denied to allow records any
more.
I assume It's OK until the file size is to be 1024Byte but when a new
record
cause overflow out of 1024Byte it won't allow any records, I guess.
Is there any solutions or advices.
Source code I made is as below...

==================================================================================

dbmopen(%person,"person",0644) || die "Can't open a database file.\n";
  $newRecord      = "nbr"          . "=" . "$in{recNbr}"       . "&" .
                    "name"         . "=" . "$in{name}"         . "&" .
                    "sex"          . "=" . "$in{sex}"          . "&" .
                    "email"        . "=" . "$in{email}"        . "&" .
                    "organization" . "=" . "$in{organization}" . "&" .
                    "hobby"        . "=" . "$in{hobby}"        . "&" .
                    "phone"        . "=" . "$in{phone}"        . "&" .
                    "homepage"     . "=" . "$in{homepage}"     . "\0";
  $person{data}  .= $newRecord;
dbmclose(%person);

==================================================================================

Thanks very much.


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

Date: Mon, 23 Nov 1998 08:24:08 -0000
From: "Antony" <amcnulty@nortel.co.uk>
Subject: Quickie
Message-Id: <73b65r$3ns@bmdhh222.europe.nortel.com>

Hey Expert-Type People,

I want to finish a small program that I am working on, but have one little
problem.

My script needs to be run a subroutine every time the timestamp of a certain
file is altered.

I tried a couple of ideas but most seem to impractical and too memory
consuming.


Also, anyone ever come up with many problems in porting UNIX perl scripts
over to WinNT ?
Got any hints for doing it quicker?
Because I'm here all weekend doing just that and it's really starting to get
on my nerves.


Awaiting all helpful comments,

Antony
MMP Release Management
590-4499





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

Date: Mon, 23 Nov 1998 03:39:59 -0600
From: Joe  Shaw <jshaw@vellocet.insync.net>
Subject: Re: Raw Sockets
Message-Id: <Pine.SOL.4.05.9811230338450.28481-100000@vellocet.insync.net>

I think this is an excercise best done in C.  I love perl, but I don't
think you're going to be able to create a raw socket in perl like you can
in C.  If you can, I'll be quite suprised.

Regards,
Joseph Shaw        - jshaw@insync.net
NetAdmin/Security  - Insync Internet Services
Free UNIX advocate - "I hack, therefore I am."

On Fri, 13 Nov 1998, Marquis de Carvdawg wrote:

> What you have provided is good, and I do appreciate your time,
> but it is not at all what I am looking for...I am looking for "raw"
> sockets.
> 
> I need to be able to specify the header information...TCP flags, even
> addresses (to check for source routing problems).
> 
> What you have provided below for the client is the standard TCP connect()
> code...I have already written port scanners, etc.  What I need to do now
> is craft my own packets.
> 
> Thanks again,
> 
> Carv
> 
> xaqtnr@my-dejanews.com wrote:
> 
> > In article <364B38FE.A2D255B6@patriot.net>,
> >   keydet89@yahoo.com wrote:
> > > Does anyone have links to code or information on
> > > creating raw sockets in Perl?  I am trying to write a
> > > script to do just that, in order to test firewalls, ID systems,
> > > etc.
> > >
> > > I posted my code to comp.lang.perl.misc and comp.protocols.tcpip,
> > > with no responses....
> > >
> > > Thanks
> > >
> > > Carv
> >
> > Here is some code for a 'server' / 'client' using sockets:
> >
> > ---------- Server ----------
> >
> > $line = "Test\n"; #Data to send
> >
> > $port = 5000;
> >
> > ($d1, $d2, $prototype) = getprotobyname ("tcp");
> > ($d1, $d2, $d3, $d4, $client) = gethostbyname (`hostname`);
> >
> > $serveraddr = pack ("Sna4x8", 2, $port, $server);
> >
> > socket (SSOCKET, 2, 1, $prototype) || die ("No socket");
> > bind (SSOCKET, $serveraddr) || die ("Can't bind");
> > listen (SSOCKET, 1) || die ("Can't listen");
> > ($clientaddr = accept (SOCKET, SSOCKET)) || die ("Can't accept");
> > select (SOCKET);
> > $|=1;
> > print SOCKET ("$line\n");
> > close (SOCKET);
> > close (SSOCKET);
> >
> > ------------------------------------------------
> >
> > ---------- Client ----------
> >
> > $port = 5000;
> >
> > ($d1, $d2, $prototype) = getprotobyname("tcp");
> > ($d1, $d2, $d3, $d4, $client) = gethostbyname (`hostname`);
> > ($d1, $d2, $d3, $d4, $server) = gethostbyname ("your hostname defined in the
> > server code");
> >
> > $clientaddr = pack ("Sna4x8", 2, 0, $client);
> > $serveraddr = pack ("Sna4x8", 2, $port, $server);
> >
> > socket (SOCKET, 2, 1, $prototype) || die ("No socket");
> > bind (SOCKET, $clientaddr) || die ("Can't bind");
> > connect (SOCKET, $serveraddr);
> >
> > $line = <SOCKET>;
> > print ("$line\n");
> > close (SOCKET);
> >
> > -------------------------------------------------------
> >
> > Hope this helps some as basic as it is.
> >
> > --
> >
> > Shay
> >
> > -----------== Posted via Deja News, The Discussion Network ==----------
> > http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
> 
> 
> 
> 
> 



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

Date: Mon, 23 Nov 1998 03:45:00 -0600
From: Joe  Shaw <jshaw@vellocet.insync.net>
Subject: Re: Raw Sockets
Message-Id: <Pine.SOL.4.05.9811230343120.28481-100000@vellocet.insync.net>


On Fri, 13 Nov 1998 lordvorp@my-dejanews.com wrote:

> I suggest looking at &Net::Ping::ping_icmp for the right direction.
> 
> Basically, you will have to manually construct, using pack(), a TCP packet.
> This will presumably require you learn the TCP guts enough to do this, but
> the function I've mentioned will be a great start (I'm planning to do this
> myself).
> 
> L8r,
> L V

I'll have to look into this as well.  I was not aware of the Net::Ping
module, but now that I am I'll have to give it a look.  I've been
wondering if you could do raw sockets in perl as well, but everything I've
heard says it would be better to done in C if it was even possible in
Perl.  

Thanks,
Joseph Shaw        - jshaw@insync.net
NetAdmin/Security  - Insync Internet Services
Free UNIX advocate - "I hack, therefore I am."



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

Date: 23 Nov 1998 03:18:01 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regular expression problem...
Message-Id: <73ak59$qoo$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x7g1bb1a3s.fsf@sysarch.com>:
> >>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
> 
>   IZ> I recall that one of my `use pedantic' or `use strict code' proposals
>   IZ> is to make such ambiguities a fatal error.
> 
> are they going in to any soon to be released versions? 

Well, somebody should actually do the spadework.  *I* cannot fix *all*
the broken software in the world (though I try ;-).

> if only scalars
> are allowed in regexes (a reasonable restriction IMO) then you would not
> have many ambiguities. all you have to do is assign the complex value
> (HOH, LOL etc.) to a scalar before using it in the regex. the fact that
> those expressions are valid in double quotish strings doesn't mean they
> should be allowed in regexes where they can be parsed ambiguiosly.

There is no need to restrict things to scalars.  Witness

 perl -le "sub foo {\'bar'} $foo[13]='baz'; print qq{' ${ foo [ 13 ] } '}"
 ' baz '

(though this changes one ambiguity to another one - is it foo([13]) or
not?).

> this is one of those newbie traps. i would never use such complex values
> in regexes directly. it is against my style.

This is the opinion I try to fight as hard as possible.  It is NOT a
newbie trap.  Do-what-I-mean works beautifully with newbies.

It is those who try to write an advances code who discover that DWIM
gets in the way - essentially it means that you need to know *all* the
fine details of parsing/other-quirks to predict how your work will work.

And a safe bet would be that *nobody* knows *all* these details
(especially now, when tens of people patched the core of the parser).
I did not check Larry, but a lot of other prominent contributors to
the Perl-lexer were caught by quite simple constructs - special-cased
by Perl.

Ilya


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

Date: Mon, 23 Nov 1998 02:35:58 -0500
From: Andrew Lee <xyz-andrew_lee@earthlink.net>
Subject: Seeking Win32::DES.pm
Message-Id: <3659105E.8A25620D@earthlink.net>

I know someone has written a perl module that implements DES in Win32,
but I can not, for the life of me, find it!

Any help is greatly appreciated!

--

Andrew F. Lee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 When I say, "Ignore the man behind the curtain."
 That is because there is no man behind the curtain.





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

Date: Mon, 23 Nov 1998 02:12:09 -0600
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Self Replicating Sites?
Message-Id: <365918D2.411EEF10@ecpi.com>

Has anyone seen decent code for self-replicating sites? Not a huge
<gulp> mlm thing...just for a couple dozen dealers.

thanks,
John



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

Date: 23 Nov 1998 09:26:28 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: shopping cart
Message-Id: <73b9o4$50r$1@shadow.skypoint.net>

Peter <peter@helpnet.com.au> wrote:
: Hello Mike and others,
: I am looking at the shopping cards offered free from the sites you
: mentioned.

: I did not set out to write a shopping cart.  I tried to get 3
: different ISPs to quote for a shopping cart.  All 3 said I wanted
: something new, difficult to do and vvvvvery expensive.

: All 3 quoted a rate per hour for programming that is far higher than
: anything that is being paid to programmers.

: All 3 refused to give even an indication of price.

: All 3 lost the business.

: All 3 lost the ongoing business from several other companies following
: my recommendations.

: Given that every major book store has several C and Perl programming
: books that show how to write a shopping cart and that most have the
: code on CD, how can ISPs pretend a shopping cart has to be invented
: from scratch at great expense?


I think this belongs in a *.cgi group.

It really depends on what you want.

Do you:

1.) Have a huge database? (maybe it needs SQL, maybe not, maybe thats not
    possible)

2.) Require other special features?

There are a lot of carts out there. http://www.cgi-resources.com is a good
starting place, but each cart is kind of "canned" some have features
you'll never use, others won't have features you need. 

Generally, an ISP is NOT the one you should talk to about getting a cart,
instead look for one you want and install it yourself, or have a web
designer handle it.

I'm kind of "in-lapse" for what I do, (someone else is taking it over
while I work on it) but when I was installing carts for people it seemed
everyone had a requirement that I hadn't thought of when writing the base,
the only defense seemed to be adding features 90% of the people would
never use.

Jamie
-- 
 -------------------------------------------------------------------------
 jamie@lecart.com
 http://www.lecart.com 


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

Date: Sun, 22 Nov 1998 20:48:47 -0800
From: Katia Hayati <hayati@ocf.Berkeley.EDU>
Subject: Socket Programming in Perl
Message-Id: <Pine.SOL.3.96.981122204739.19582A-100000@conquest.OCF.Berkeley.EDU>

Hello --

I am trying to figure out how to program sockets in Perl 4 or 5. Can
someone direct me to a site where they would explain their code (not just
list it), or explain to me how it is done?

Thanks

Katia Hayati



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

Date: 23 Nov 1998 05:14:34 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Socket Programming in Perl
Message-Id: <slrn75hrpq.16i.sholden@pgrad.cs.usyd.edu.au>

On Sun, 22 Nov 1998 20:48:47 -0800, Katia Hayati <hayati@ocf.Berkeley.EDU>
	wrote:
>Hello --
>
>I am trying to figure out how to program sockets in Perl 4 or 5. Can
>someone direct me to a site where they would explain their code (not just
>list it), or explain to me how it is done?

Reading the documentation that comes with perl would probably be useful :
perldoc perlipc.

There's a large section on using sockets (I suggest looking at the later
examples which use the far easier to use (in my opinion) IO::Socket
module).

If your copy of perlipc doesn't mention IO::Socket then it is time to
upgrade your version of perl.

-- 
Sam

You are bordering on ridiculous if you think you need to support your
premises.  Such an argument is an infinite regression.
 	--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>


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

Date: Mon, 23 Nov 1998 02:29:34 -0500
From: Andrew Lee <xyz-andrew_lee@earthlink.net>
Subject: Re: Socket Programming in Perl
Message-Id: <36590EDE.D757CA80@earthlink.net>

FWIW:
Stevens' books (3 volumes) on TCP/IP are invaluable for understanding sockets
in general.  As for sockets in Perl, have a look at 'Anvanced Perl
Programming' from O'Rielly.

Katia Hayati wrote:

> Hello --
>
> I am trying to figure out how to program sockets in Perl 4 or 5. Can
> someone direct me to a site where they would explain their code (not just
> list it), or explain to me how it is done?
>
> Thanks
>
> Katia Hayati



--

Andrew F. Lee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 When I say, "Ignore the man behind the curtain."
 That is because there is no man behind the curtain.





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

Date: Mon, 23 Nov 1998 09:32:31 GMT
From: mark-lists@webstylists.com (Mark Thompson)
Subject: Sorting DB but starting in middle
Message-Id: <365926e8.470298@news.supernews.com>

Hi,

I have a database program that sorts by record number (the database is in
alphabetical order already) and I would like it to start in a random part of
the database, continue to the end, and then finish up from the beginning. 

It currently prints the list with this command:

	print @hit_list[ sort bydborder $[..$#hit_list ];

using for bydborder:

	sub bydborder { $recnum[$a] <=> $recnum[$b]; } 

Record number is an integer from 1 through about 2000 but is not continuous.
It can be something like 2, 3, 5, 10, 12, 19, 20, 21, 22, 23.   Basically, in
this case, each number needs to have a 1 in 10 chance in being the first
number picked and then go to the end before finishing up at the beginning.
For example, let's say that 10 was picked first, it would be 10, 12, 19, 20,
21, 22, 23, 2, 3, 5 in that order.  

Would anyone have any thoughts on how best I can go about doing this?

Thanks,

Mark Thompson




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

Date: Sun, 22 Nov 1998 20:51:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: supressing output from external program in perl
Message-Id: <MPG.10c289bac073a79298991e@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <%x362.95$wg2.221@nsw.nnrp.telstra.net> on Mon, 23 Nov 1998 
02:14:19 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
> In article <3658C48D.A4270D8@music.unt.edu>,
> 	Kelly Wood <kwood@music.unt.edu> writes:
> > exec("csound -d -m 0 -A devaudio -b256 -B4096 $choice.orc $choice.sco");
> > 
> > Perl executes csound which plays the audio, but my perl program waits
> > until csound has finished before going on.  Is there a way to tell perl
> > not to wait for csound's completion?
 ...
> Anyway, look into fork:
> 
> # perldoc -f fork
> # perldoc perlipc

I am confused both by the question and by your response.

Doesn't 'exec' immediately terminate execution of the Perl program and 
replace it by execution of the exec'ed program?  Yet he says 'my perl 
program waits until csound has finished before going on' and you aim him 
at 'fork'.  What is going on???

I habitually put 'die' after 'exec' just in case...

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


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

Date: 23 Nov 1998 07:49:27 GMT
From: ralph@contact-paging.com (Ralph Forsythe)
Subject: sysread / need help w/ single byte I/O, urgent!  please!
Message-Id: <73b427$gov$1@news-2.csn.net>

Ok, here's the dilemma:  I am trying to read data from an analog to digital 
converter, and am missing something.  The way it works is I send a command 
(which is working fine) to it telling it how many channels I want returned 
(1-11), and it sends back 2 bytes for each channel, MSB and LSB.  I need to 
read the bytes one-at-a-time and do ord() conversions on them - but when I try 
this it just hangs the program.  The only way I can do it so far is to read it 
all at once into a string, which doesn't work very well.

Here is the Basic code sample they sent with it:

Step 1:  Constructing the command string

   channel = 1   (chan #'s start at 0, 0-10 for ch. 1-11 repectively)
   Command$ = "!0RA"+CHR$(channel)

Step 2:  Transmit the command string (which tells it to read the ports)

   Print #1, Command$;

Step 3:  Receive the data

   MSB$ = INPUT$ (1, #1)
   LSB$ = INPUT$ (1, #1)
   reading1 = (ASC(MSB$)*256) + ASC(LSB$)

   MSB$ ...
   LSB$ ...
   reading0 = ...


The idea is to get a value fro 0 to 4095, which will tell me the voltage.  Can 
someone *please* tell me the Perl equivalent to this code fragment?  
Unfortunately I'm a but rusty in this area, but I need to know how to do this 
ASAP.

Thanks a bunch!!
- Ralph Forsythe



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

Date: Mon, 23 Nov 1998 16:18:07 +1100
From: Grant Ozolins <grant.ozolins@anu.edu.au>
Subject: Trouble installing Date::Manip module
Message-Id: <3658F00F.460CAE99@anu.edu.au>

Hi Perl People,

I've been trying to install the Date::Manip module, but have had trouble
in the make install.  

I ran:

Makefile.PL PREFIX=/authors/home/username/bin/perlmod 

but when I went to make install, I got:

> make install
Skipping
/authors/home/username/bin/perlmod/lib/site_perl/./Date/Manip.pm
(unchanged)
Skipping
/authors/home/username/bin/perlmod/lib/site_perl/./Date/Manip.pod
(unchanged)
Skipping /authors/home/username/bin/perlmod/man/man3/./Date::Manip.3
(unchanged)
Writing
/authors/home/username/bin/perlmod/lib/site_perl/sun4-solaris/auto/Date/Manip/.packlist
/bin/sh:
/authors/home/username/bin/perlmod/lib/sun4-solaris/5.00404/perllocal.pod:
cannot create
make: *** [doc_site_install] Error 1
> 

Could any kind soul suggest why this is happening?

Cheers,
Grant Ozolins
grant.ozolins@anu.edu.au


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

Date: Mon, 23 Nov 1998 01:02:19 -0500
From: "Johnathan Posey" <jposey@mindspring.com>
Subject: Using multiple dbm files
Message-Id: <73atj0$v3j$1@camel25.mindspring.com>

Does anyone have some example code of someone using
multiple dbm files?

I am writing a sub that will allow the user to do a keyword search
and want to include my inventory database and my customer database and so
on.

I have already written the hash and I am opening the db using the tie method
with the
flag.

Anyone with any advise I would really appreciate it.

Johanthan




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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