[7644] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1270 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 4 15:17:42 1997

Date: Tue, 4 Nov 97 12:00:50 -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           Tue, 4 Nov 1997     Volume: 8 Number: 1270

Today's topics:
     **why?** perl syscall(&SYS_sbrk,0) != C sbrk(0) <hollosi@sbcm.com>
     Re: AUTOLOAD and sort <rootbeer@teleport.com>
     Re: Best way to comma seperate a number? <barnett@houston.Geco-Prakla.slb.com>
     Re: Best way to comma seperate a number? <rootbeer@teleport.com>
     Re: CGI / Reflection Web Server <rootbeer@teleport.com>
     crontab -l reformating (Reinvent the wheel?) (bodhi1@nonamesleft.com)
     dates and times <rsmith@nac.net>
     Re: dates and times (brian d foy)
     Dbase and Fox Pro <Martin.Bolduc@riq.qc.ca>
     Re: HTTP Bug?  404 Not Found (Mike Stok)
     Re: more gethostbyaddr <seay@hol.fr>
     ODBC and Apostrophe (Licensed User)
     Re: ODBC and Apostrophe (Mike Heins)
     Re: Perl Assignment!! <usenet-tag@qz.little-neck.ny.us>
     Perl->Java? Java->Perl? Gaaaaa! dg50@chrysler.com
     Re: Perl->Java? Java->Perl? Gaaaaa! <nospam_scottv@dnai.com>
     Re: Personal Web Server - Perl ? (Pete Barker)
     print aound matched line <mhammer@execpc.com>
     Re: print aound matched line (Tad McClellan)
     problem programming daemon with perl <rmcgahey@lakers.lssu.edu>
     Re: problem programming daemon with perl (brian d foy)
     Re: problem programming daemon with perl <rootbeer@teleport.com>
     Re: PROBLEM WRITING FILES - HELP! (Tad McClellan)
     Re: Real Newbie Question (Ronald L. Parker)
     Re: realtime output - HELP ME PLEASE!!! <alex@telekom.ru>
     searching a fileNAME for a string <bobm@tiac.net>
     Re: searching a fileNAME for a string (brian d foy)
     Re: searching a fileNAME for a string <rootbeer@teleport.com>
     Re: Seeking Year 2000 checker OR comment stripper for C (John Moreno)
     Re: Seeking Year 2000 checker OR comment stripper for C <Eric.NoSpam.Buckley@edwardjones.com>
     signal handling <benneman@nortel.SPAM.BUSTER.ca>
     Re: slow server <rootbeer@teleport.com>
     Re: Type="file" and CGI <rootbeer@teleport.com>
     UKs Top Perl, Java, CGI Opportunities, ECM <vanessa@ecmcel.demon.co.uk>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 4 Nov 1997 16:17:22 GMT
From: Jozsef Hollosi <hollosi@sbcm.com>
Subject: **why?** perl syscall(&SYS_sbrk,0) != C sbrk(0)
Message-Id: <EJ4qL1.5C@nonexistent.com>

Hi, I am trying to get an estimate of the running process size as
it grows in time due to memory leaks.

In C, I can get the current break value with an sbrk(0) call, but the
perl equivalent syscall(&SYS_sbrk, 0) returns zero.

Is there any remedy to this situation?

Thanks a lot,
Jozsef
hollosi@sbcm.com


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

Date: Tue, 4 Nov 1997 10:12:53 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Andrew M. Langmead" <aml@world.std.com>
Subject: Re: AUTOLOAD and sort
Message-Id: <Pine.GSO.3.96.971104101119.17982R-100000@usertest.teleport.com>

On Mon, 3 Nov 1997, Andrew M. Langmead wrote:

> I doubt that a sort subroutine would have side effects,

It had better not have side effects! :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 04 Nov 1997 12:32:56 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Best way to comma seperate a number?
Message-Id: <345F6A58.32E7@houston.Geco-Prakla.slb.com>

I have a module that I've created to comma seperate numbers.

It doesn't work well with numbers that are non-integer (simply because I
never wrote it intending to pass it decimal numbers  :-)  ).  It could
be easily modified to handle non-integer numbers.

If you would like a copy of it, let me know, and I will e-mail what I
have to you.  (No guarantees....no extreme amount of testing has been
done, but it passes my simple tests just fine.  ;-)  )

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Tue, 4 Nov 1997 11:29:56 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Best way to comma seperate a number?
Message-Id: <Pine.GSO.3.96.971104112922.17982U-100000@usertest.teleport.com>

On Tue, 4 Nov 1997, Dave Barnett wrote:

> I have a module that I've created to comma seperate numbers.

You should upload it to CPAN. If, of course, it's finished. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 4 Nov 1997 09:18:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: John Desper <John.M.Desper@vanderbilt.edu>
Subject: Re: CGI / Reflection Web Server
Message-Id: <Pine.GSO.3.96.971104091733.17982N-100000@usertest.teleport.com>

On 1 Nov 1997, John Desper wrote:

> Has anyone out there been able to run CGI scripts on a WRQ Reflection
> Web Server?

If anyone has, they may hang out in a newsgroup about servers in the hopes
of answering your questions. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 04 Nov 1997 14:26:58 GMT
From: bodhi1@nonamesleft.com (bodhi1@nonamesleft.com)
Subject: crontab -l reformating (Reinvent the wheel?)
Message-Id: <63nbgu$jdv@suriname.earthlink.net>

I am looking for any Perl scripts that will allow me to take the output of 
crontab -l and format it into something that is readable by normal human 
beings. It would be ideal if it would put it into a .html format.

Thanks,

Bodhi1


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

Date: Tue, 04 Nov 1997 11:50:36 -0500
From: Rick Smith <rsmith@nac.net>
Subject: dates and times
Message-Id: <345F525C.D5B998A5@nac.net>

I have a file, a RADIUS file to be exact, that dumps the date and
time of a user's connection to this format:

Nov  4 1997 11:51AM

How do I convert this to unix time, subtract an amount of seconds
from it, and then convert it back to the above format ?

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Don't go with a spineless ISP;                   Rick Smith
        we have more backbone."                   rsmith@nac.net

(201) 983-0725     net @ccess corporation     (201) 983-0453 Fax
                     http://www.nac.net

Quake!                  games@nac.net                      MUDs!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




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

Date: Tue, 04 Nov 1997 13:16:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: dates and times
Message-Id: <comdog-ya02408000R0411971316020001@news.panix.com>

In article <345F525C.D5B998A5@nac.net>, Rick Smith <rsmith@nac.net> wrote:

>Nov  4 1997 11:51AM
>
>How do I convert this to unix time, subtract an amount of seconds
>from it, and then convert it back to the above format ?

you use a nifty Date module from CPAN.

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 4 Nov 1997 19:39:40 GMT
From: "Martin Bolduc" <Martin.Bolduc@riq.qc.ca>
Subject: Dbase and Fox Pro
Message-Id: <01bce958$c09ade20$078054c7@lorenz>

Help,

I want help for using Dbase III and Fox Pro database's on a Unix system
with Perl 5.

Martin
martinbolduc@littera.com


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

Date: 4 Nov 1997 19:53:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: HTTP Bug?  404 Not Found
Message-Id: <63nufi$s40@news-central.tiac.net>

In article <63700k$hg@rac5.wam.umd.edu>, Joe Benik <jobe@wam.umd.edu> wrote:
>Hello,
>
>I am having problems downloading an HTML file from a web server.  I
>telnet to www.pornsugar.com 80, and execute "GET /jabars.html HTTP/1.0" 
>(I am not endorsing the site or its content, it just shows the error I am
>running into.  I am in no way affiliated with the site.)
>
>This returns: HTTP/1.1 404 Not Found
>
>But, if you bring up a web browser and browse
>http://www.pornsugar.com/jabars.html   I have absolutely no trouble
>getting to the page.

GET is one of the scripts distributed with the libwww-perl distribution
which makes use of several of the modules in the distribution.  Using it
seems to retrieve the content:

bash$ GET http://www.pornsugar.com/jabars.html | head


<HTML>
<HEAD>
        <TITLE>Jabar's Hot Pix</TITLE>
</HEAD>

<BODY BGCOLOR="Black" TEXT="Orange" LINK="Red" VLINK="Purple"
ALINK="Lime">


bash$ 

so you can use the modules in a perl script to crawl the web.  In general
it's much better to use someone else's code as they will already have made
most of the mistakes you are likely to encounter, and a popular module
incorporates feedback from many users.  You can find perl modules at any
CPAN (Comprehensive Perl Archive Network) site, perhaps the quickest way
there is via the link on http://www.perl.com

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Tue, 04 Nov 1997 19:12:46 +0100
From: Douglas SEAY <seay@hol.fr>
To: "U-Topia S.r.l." <root@u-topia.com>
Subject: Re: more gethostbyaddr
Message-Id: <345F659E.267DA697@hol.fr>

[posted and mailed]

U-Topia S.r.l. wrote:
> 
> That's the sub..i took it from a book...but there's something obscure for
> me (i don't know why or how...but it works!)
> 
> sub get_request {
> local ($server,$request) = @_ ;

Ouch, this is old.  "local" isn't really up-to-date.  With Perl5 "my" is
the way to do most things.

> chop ($hostname='hostname');
> ($name,$aliases,$proto) = getprotobyname ('tcp');
> ($name,$aliases,$type,$len,$thisaddr) = gethostbyname ($hostname);
> ($name,$aliases,$type,$len,$thataddr) = gethostbyname ($server);
> $sockaddr = 'S n a4 x8';
> $this = pack ($sockaddr,2,0,$thisaddr);
> $that = pack ($sockaddr,2,80,$thataddr);
> socket (S,2,1,$proto);
> bind (S,$this);
> connect (S,$that);
> select((select(S),$|=1)[0]);
> print S ("$request");
> @page = <S> ;
> close (S);
> }
> 
> Can someone help me to understand ???
> 
> Line 3 - why chop ??? and why 'hostname' as address ???

So you get the host info (address included) for the local host.  Chop()
deletes the end of line character.  Trash whatever book you used because
it was writen for Perl4.  Nowdays that should be "chomp" (see perlfunc
for the differences).

> Line 5 - what's that format ? and why if i put anything on $hostname it
> work ?
> Line 6 - again the format ... and expecially...how can i handle numeric
> address ?

For the format, just look it up in perlfunc.  Don't expect us to read
the docs for you.  As for the numeric bit, most system's libraries
support gethostbyname() with dotted quad strings.  I don't think Windows
does, but maybe the Perl gethostname() fudges it.

> Line 7/8/9 - it's that a particular format to use bind & connect ??

Go get a book on TCP/IP programming.  Sorry if this sounds snooty, but
with Berkeley sockets it is normal to create a socket, bind it to a
local port and then connect to a distant machine.

> Line 13 - really obscure

Is that the select() line?  That is just setting the socket to not
buffer (aka autoflush).  This is real close to the example in perlfunc
("perldoc -f select").  RTFM.

> I'd like to handle also numerical address.
> But first of all i'd like to know what this piece of source does...it's
> hard for me to understand why it works.

Forget all this crap.  IO::Socket does this for you and is much easier
to read.  This becomes

	my $sock = IO::Socket::INET->new(
		PeerAddr=> $server,
		PeerPort=> 80,
		Proto	=> 'tcp' );
	$sock->autoflush(1);

Even better might be one of the WWW modules (LWP.pm, CGI.pm, or
something else from CPAN module catagory 15).  Since I've never used any
of 'em, I can't be more specific than this.

- doug


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

Date: Tue, 4 Nov 1997 11:45:17 -0500
From: hobo@alumni.stanford.org (Licensed User)
Subject: ODBC and Apostrophe
Message-Id: <MPG.ec91b233fe40eae989687@news.ricochet.net>

Can anyone help me?

I'm trying to update a database using perl and have got most of it 
working successfully except for this one annoying bug.  When I try and 
send a insert a field value that contains an apostrophe... The sql call 
breaks.  
for example

$joe="Joe's";
$bob="Bob";
$sql_stmt="Insert into friends values('$joe','$bob)";
$db->Sql($sql_stmt);

I know the conflict comes from the fact that the field delimeters are 
apostrophes and that conflicts with field value... What I don't know of 
is any solution around it? I've tried the ascii representation 
$joe="Joe\047s" but that updates the database with literally "Joe\047s" 

Can anyone help or direct me to a page that addresses this?

thank you,
Stan


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

Date: 4 Nov 1997 19:45:54 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: ODBC and Apostrophe
Message-Id: <63nu1i$3o7$1@vixen.cso.uiuc.edu>

Licensed User (hobo@alumni.stanford.org) wrote:
: Can anyone help me?
: 
: I'm trying to update a database using perl and have got most of it 
: working successfully except for this one annoying bug.  When I try and 
: send a insert a field value that contains an apostrophe... The sql call 
: breaks.  
: for example
: 
: $joe="Joe's";
: $bob="Bob";
: $sql_stmt="Insert into friends values('$joe','$bob)";
: $db->Sql($sql_stmt);
: 
: I know the conflict comes from the fact that the field delimeters are 
: apostrophes and that conflicts with field value... What I don't know of 
: is any solution around it? I've tried the ascii representation 
: $joe="Joe\047s" but that updates the database with literally "Joe\047s" 
: 
: Can anyone help or direct me to a page that addresses this?
: 

'perldoc DBI' will tell you.

Basically, you should do:

	$joe = $db->quote($joe);
	$bob = $db->quote($bob);
	$sql_stmt="Insert into friends values($joe,$bob)";
	
Then run your command.  The quoting will be done as required
for that DBD driver. This is important, because some escape
the quote with '' and others use \'. Using the quote
method makes your code portable.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: 4 Nov 1997 19:31:51 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Perl Assignment!!
Message-Id: <eli$9711041339@qz.little-neck.ny.us>

brian d foy <comdog@computerdog.com> wrote:
> In article <345EC07F.708@hcpd.com>, andee@hcpd.com wrote:
> >some difficulties with the assignment.  For the assignment we have to
> >write a perl language beautifying application that will take a text file
> >and do the following:
> perhaps you could be more specific about which parts are giving you
> trouble.  for instance, what have you already tried and how does it
> not do what you expect?

Sure, that's one way to do it. But we can only expect that from people
who do not expect Usenet to do their homework for them.

> normally i would just give some examples, but that might defeat the
> purpose of this assignment :)

Well, how about buggy examples just to give them a feel for how to
do it?

I fer instence, came up with this crystal clear method but it has
some problems with too many embedded newlines:

#!/usr/bin/env perl5.00401
$^W=1; $/=$.; $_=<>;
@split=split m i\bb\Bruce\bii;
@map=map {s , \.  $ , $& . q "
" x($^=~y.T.t.),xem,qq "$_"}@split;
$done= join q*myname* , @map;
$done=~ s/(^myname|myname1?(?=myname))|(?:(?i)perl)|NY \B.\b PM/q
?PERL? if!defined $1/ge;
print $done;
__END__

It may have some other bugs I've not noticed, too. And it only
does most of the problem, I left out the five blank lines bit,
but it should be obvious how to add that in. Suffice to say it
works for a few examples I plugged into it. You should probably
clean it up a bit and add comments before using it. For added
fun, convert it to work as one statement.

> >      If the word Bruce appears anyplace and even in multiple places on
> >a line, your first name will be substituted.
> sounds like you want the substitution operator, since you want to
> substitute.

TIMTOWTDI. But I confess, my way is not soley independent on substitutions.

> >        On the next line after a line with a period, insert 5 blank lines
> >before you write out the line (like starting a new paragraph)
> does this make sense based on the previous substitution?

Maybe. That one only applied to \Q.\E$ while this does not.

> >        Change the words Perl (any case) to all Upper Case (PERL) anyplace they
> >occur in the text file.
> what kind of school is this!  i think you want to do that the other
> way around!

What's the line? "Must appear in single case, lower case prefered"?

> DOS has poisoned society

Either that or it is a throwback to the TRS 80s that lack lower case.

Elijah
------
the trash-80s were B1FF"S F4V0R1TE <0MPUTER!!!!!!


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

Date: Tue, 04 Nov 1997 12:22:48 -0600
From: dg50@chrysler.com
Subject: Perl->Java? Java->Perl? Gaaaaa!
Message-Id: <878667641.15181@dejanews.com>

I've got a nasty little problem I'd like some advice on.

I need to create a program that adds/edits/deletes from a little flat-file
database, and executes a subroutine that then does something with the data
in the flat file.

This by itself is a no-brainer. I've done similar programs (using a web
interface as the API) so many times that I've lost count.

This time, however, it a little bit different. In this case, I don't have
the luxury of a web server with Perl running behind it to act as my API
manager. Instead, the application has to run offline - quite possibly on a
*gasp* Wintel box. :(

I also can't count on having perlwin32 on this PC, nor can I count on
this application staying on any particular machine. Next week, it may
need to run on a Mac, or on Linux, or whatever.

So, Java, right? "Write once, run anywhere" right? (I can count on having
access to a Java-enabled web browser, at least)

So I sketch out a nifty user interface (based loosly on the Win95 Network
Control Panel) and call up the AWT specs, and... gaaaa, who designed this
language? It's like trying to read a cookbook written by George Orwell in
a 1984-ish mood, shortly after ingesting some alien hallucinagen! People
actually *use* this and accomplish stuff? Inconceivable!

I want my nice, comprehensible perl code back!

So I guess what I want to do is write this app in perl, with some sort of
ties to a windowing package of some sort, that I can then compile to Java
bytecode (with all the windowing calls mapped to AWT, of course) that can
then be wrapped up in a web page that resides on the user's local machine
to be invoked by a browser bookmark.

Or do I?

I don't care if the compilation process results in my java program
containing the perl interpreter, I don't care if native Java would result
in a file size 100 times smaller, I just want to get this done without
having to teach myself Java from scratch to accomplish what would be an
hour long job in perl.

(and there's this issue of reading/writing local files too - this may not
be runnable from a browser window, the machine this runs on may require
the Java RTE no matter what - in which case I have to install some sort
of RT package on the machine no matter what, throwing the "univeriallity"
of Java right out the window...)

Anyone care to offer any advice?

DG



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


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

Date: Tue, 4 Nov 1997 11:16:12 -0800
From: "Scott Vachalek" <nospam_scottv@dnai.com>
Subject: Re: Perl->Java? Java->Perl? Gaaaaa!
Message-Id: <63nsk3$iqt$1@castor.dnai.com>

I hate to tell you this but I think Java and Perl are only dating and
marriage is quite a ways in the future.  But you may feel better if you take
another look at Java and approach it a little more slowly.  Java is actually
a much simpler language than Perl, in that there's not a lot of keywords and
syntax and what little there is, is very consistent.  One difference,
however, is that it forces you to use an object-oriented model, which is
something that just takes a little adjusting to if you haven't tried it in
Perl.  And another is that you have to identify your data types a little
more specifically than $, @, %.  But the big difference, as you discovered
when looking at that AWT book, is that the Java library is quite a bit
larger and more complex than the built-in Perl functions.

My recommendation: find some source for a sample java applet with some text
fields in it.  That should get you started without needing to learn much
about AWT.  GUI libraries can be the hardest to learn.  Then dig up what you
can on java.lang.String, java.io.PrintWriter (or PrintStream if you're using
old Java 1.0), and java.io.BufferedReader (or InputStream in 1.0).  That
should get you your basic file I/O.  There's also a java.text package that
may help out in some of your string manipulations.

One final thing: applets are by default not allowed to access the file
system.  In order to do that you'll have to look into "signed" applets.

Good luck!




dg50@chrysler.com wrote in message <878667641.15181@dejanews.com>...
>Anyone care to offer any advice?
>
>DG





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

Date: 4 Nov 1997 16:08:26 GMT
From: on.maps.barker@cix.co.uk (Pete Barker)
Subject: Re: Personal Web Server - Perl ?
Message-Id: <memo.19971104160713.66B@mt.cix.co.uk>

In article <63gds4$1b4$1@news.vanderbilt.edu>,
John.M.Desper@vanderbilt.edu (John Desper) wrote:

> In article <3458ba3f.0@news.bru.tfi.be>, yooo@geocities.com
says...
> >
> >Is it possible to configure Personal Web Server (Microsoft), so
I can r
> un
> >Perl CGI-scripts on it ?
> >
> >Thx in advance
> >
> >

I did this yesterday, with the ActiveState Win32 port. The
installation for ActiveState perl automatically does the
association of .pl with perl.exe.

To make perl scripts work with the Peer Web Services (which I
assume is what you mean), add this registry entry...

HKEY_LOCAL_SYSTEM
  System
    CurrentControlSet
      Services
        W3Svc
          Parameters
            Script Map
              .pl: REG_SZ: C:\<PERLDIR>\BIN\PERL.EXE %s %s

This runs perl.exe as a seperate process. There is a was to get
perl to run as a DLL, in which case the entry would be

              .pl (REG_SZ) <path>\PerlIS.dll
 
However, I don't know where that DLL is obtained from.

Pete Barker
P.S. Please remove on.maps. to mail me.



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

Date: Tue, 04 Nov 1997 12:23:44 -0500
From: Michael Hammernik <mhammer@execpc.com>
Subject: print aound matched line
Message-Id: <345F5A20.3DE9@execpc.com>

I'm having trouble finding a way to match a line and then print the line
above, the matched line and the line below. I've been browsing through
the llama, the camel and the panther without finding what I need. 
Thanks in advance for any assistance given.

Hammer


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

Date: Tue, 4 Nov 1997 11:42:17 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: print aound matched line
Message-Id: <ppmn36.2t8.ln@localhost>

Michael Hammernik (mhammer@execpc.com) wrote:
: I'm having trouble finding a way to match a line and then print the line
: above, the matched line and the line below. I've been browsing through
: the llama, the camel and the panther without finding what I need. 
: Thanks in advance for any assistance given.


while (<>) {
   if ( /match me/ ) {
       print $prev;       # print the line before
       print;             # print the line
       print scalar(<>);  # read and print the line after
                          # line after better BE there (ie. problem if
                          # 'match me' is on the last line...

   }
   $prev = $_;  # remember the previous line
}


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Tue, 04 Nov 1997 11:21:04 -0500
From: Richard McGahey <rmcgahey@lakers.lssu.edu>
Subject: problem programming daemon with perl
Message-Id: <345F4B70.E824C697@news.lssu.edu>

Hi there,
	I hope someone could help me out about this. I tried to program a
simple server program that will run in background as a daemon process,
but now my problem is after it runs - it only response back to client
only once then it dies. It didn't stay. Here is my simple program ->

#!/usr/bin/perl

require 'sys/socket.ph';

$sockaddr = 'S n a4 x8';

$port = 5000;

$hostname = `hostname`;
chop($hostname);

($name, $aliases, $protocol) = getprotobyname('tcp');
($name, $aliases, $type, $len, $rawaddr) = gethostbyname($hostname);
$serveraddr = pack($sockaddr, &AF_INET, $port, $rawaddr);
socket(MASTER, &PF_INET, &SOCK_STREAM, $protocol) || die("\nNo
socket!\n");
bind(MASTER, $serveraddr) || die("\nCan't bind\n");
listen(MASTER, 1) || die("\nCan't listen\n");
($clientaddr = accept(SLAVE, MASTER)) || die("\ncan't listen\n");

select(SLAVE);
$| = 1;

$line = "Test Socket, it's working!";
print SLAVE ("$line\n");
close(SLAVE);
close(MASTER);

please help!..
thanks
pe'


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

Date: Tue, 04 Nov 1997 12:26:58 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: problem programming daemon with perl
Message-Id: <comdog-ya02408000R0411971226580001@news.panix.com>

In article <345F4B70.E824C697@news.lssu.edu>, Richard McGahey <rmcgahey@lakers.lssu.edu> wrote:

>        I hope someone could help me out about this. I tried to program a
>simple server program that will run in background as a daemon process,
>but now my problem is after it runs - it only response back to client
>only once then it dies. It didn't stay. Here is my simple program ->

your daemon has no looping mechanism.  it accepts a connection, does
its thing, then reaches the end of the program.  with nothing left
to do, it exits.

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 4 Nov 1997 09:25:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Richard McGahey <rmcgahey@lakers.lssu.edu>
Subject: Re: problem programming daemon with perl
Message-Id: <Pine.GSO.3.96.971104092015.17982O-100000@usertest.teleport.com>

On Tue, 4 Nov 1997, Richard McGahey wrote:

> I tried to program a simple server program that will run in background
> as a daemon process, but now my problem is after it runs - it only
> response back to client only once then it dies. It didn't stay.

Maybe that's because you let it quit after its one connection is done. :-) 
But there are some example server scripts running around. One should be
here:

    http://www.perl.org/CPAN/scripts/nutshell/ch6/server

Good luck with it!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 4 Nov 1997 10:21:08 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: PROBLEM WRITING FILES - HELP!
Message-Id: <k1in36.jg8.ln@localhost>

Jim Michael (genepool@netcom.com) wrote:
: Gil Vidals (vidals@etica-entertainment.com) wrote:
: : "/tmp2". The directory
: : look like this:
: :    drwxrwxrwx  2 root root 1024 Nov 3 23:05 tmp2

: : The problem is that it ***ONLY*** writes to the file when I'm logged in
: : as the root.

: :     -rw-r--r-- 1 pwrusr wheel 0 Nov 3 23:27 test20
                     ^^^^^^

: Oops, only root has write permission. You need the chmod command. See the 
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Eh?

Looks to me like only 'pwrusr' has write permission...


: chmod man page: man chmod.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Tue, 04 Nov 1997 15:04:16 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: Real Newbie Question
Message-Id: <345f206c.316596581@news.supernews.com>

On Mon, 3 Nov 1997 14:29:10 -0600, tadmc@flash.net (Tad McClellan)
wrote:

>Although it's rumored that the (imminent) 5.004 release may build
>on Windows NT, this is yet to be proven.  Binary distributions
>for 32-bit Microsoft systems and for Apple systems can be found
>http://www.perl.com/CPAN/ports/ directory.  Because these are not part of
>the standard distribution, they may and in fact do differ from the base
>Perl port in a variety of ways.  You'll have to check their respective
>release notes to see just what the differences are.  These differences
>can be either positive (e.g. extensions for the features of the particular
>platform that are not supported in the source release of perl) or negative
>(e.g. might be based upon a less current source release of perl).

If that's what the FAQ says, it seems as though it should be changed.
Not only is 5.004 no longer "imminent," but it does build on NT out of
the box, and Gurusamy Sarathy works hard over on p5p to keep it that
way.



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

Date: Tue, 04 Nov 1997 19:55:16 +0300
From: Cheglyakov Alexey <alex@telekom.ru>
Subject: Re: realtime output - HELP ME PLEASE!!!
Message-Id: <345F5374.79D0@telekom.ru>

Matthias Hellmund wrote:

> Why does the line-by-line output of this perl-script only work with
> Netscape Navigator? Netscape's browser prints one line, pauses, prints one
> more line, pauses again and so on.
> Why does this not work with Microsoft Internet Explorer (I tried version
> 3.02 for Win95)? MS IE waits until the script has finished sending the
> lines and THEN prints all lines in one flush. Pretty bad for a chat-system
> for example where the message-output must be realtime, isn't it?
> 
> #### perl-script ######
> #!/usr/bin/perl
> print "HTTP/1.0 200 OK\n"; # NPH-file with Linux-Apachee-Server
> print "Content-Type: text/html\n\n";
> $|=1; # unbuffered Output
print "<!DOCTYPE HTML PUBLIC \"//IETF//DTD HTML//EN\">\n";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Try insert it here.
> print "<HTML><HEAD><TITLE>line by line output test</TITLE></HEAD><BODY>\n";

 ....<skip>....

best regards,  Alex.


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

Date: Tue, 04 Nov 1997 11:58:20 -0500
From: Bob Maillet <bobm@tiac.net>
Subject: searching a fileNAME for a string
Message-Id: <345F542C.C31997B0@tiac.net>

I have a directory of files which are created daily..part of each
filename is equal to a string which is queried from a database.  If I do
a foreach loop and use $fname=~(/$thisval/) the value does not seem to
be compared. What am I doing wrong?

Bob



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

Date: Tue, 04 Nov 1997 13:17:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: searching a fileNAME for a string
Message-Id: <comdog-ya02408000R0411971317000001@news.panix.com>

In article <345F542C.C31997B0@tiac.net>, bob@cafemedia.com wrote:

>I have a directory of files which are created daily..part of each
>filename is equal to a string which is queried from a database.  If I do
>a foreach loop and use $fname=~(/$thisval/) the value does not seem to
>be compared. What am I doing wrong?


those parenthesis do not belong there. try:

   $fname =~ /$thisval/;

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 4 Nov 1997 10:10:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: bob@cafemedia.com
Subject: Re: searching a fileNAME for a string
Message-Id: <Pine.GSO.3.96.971104100641.17982Q-100000@usertest.teleport.com>

On Tue, 4 Nov 1997, Bob Maillet wrote:

> I have a directory of files which are created daily..part of each
> filename is equal to a string which is queried from a database.  If I do
> a foreach loop and use $fname=~(/$thisval/) the value does not seem to
> be compared. What am I doing wrong?

If your code looks like this, you're doing two pattern matches instead of
one! 

    $fname =~ (/$thisval/)	# Bad

That checks the pattern /$thisval/ against $_ . Then, the return value
from that match is used as a pattern matching against $fname! You probably
wanted something like one of these expressions instead.

    $fname =~ /$thisval/o

    $fname =~ /$thisval/

    $fname eq $thisval

    index($fname, $thisval) != -1

    $fname eq "something.$thisval"

Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 4 Nov 1997 12:09:07 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <19971104111111204405980N@roxboro-162.interpath.net>

In comp.lang.perl.misc Bob Weissman <weissman@netcom.com> wrote:

] I'm looking for a perl script to inspect C and C++ code for suspicious
] constructs with respect to the Year 2000 Problem.  Such a script
] should strip comments and then look for suspicious strings such as
] "19", "365", "getdate", "strptime", etc.
] 
] If such a beast does not exist, I'd be happy with a script which
] simply removes all comments from C and C++ source, including
] multi-line comments.  Then I could code the rest myself, but I'm not
] enough of a perl wiz to know how to strip multi-line comments.  (Yes,
] I know the C preprocessor will strip comments, but it also does other
] nasty things like expand #include directives, which I don't want to
] do.)
] 
] I've looked on CPAN and searched the web, but haven't seen anything
] like this.  Any help will be greatly appreciated.

Stripping comments is easy.  Here's some test code to show how to do it,
of course you'll probably want to slurp in the whole file and print it
out after the regex's but that's left as a exercise for the reader.
You'll need Perl5, this uses a nongreedy regex.


$test= "x=1; /* test */\nz=2; /*comment\nacross \nlines */\ni=3; // yet
another comment\ng=4;\n";

print "Before regex:\n";
print $test;

$test =~ s#(/\*.*?\*/)##sg;
$test =~ s#(//.*)##g;

print "\n\nAfter regex:\n";
print $test;

-- 
John Moreno


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

Date: Tue, 04 Nov 1997 13:45:27 -0600
From: Eric Buckley <Eric.NoSpam.Buckley@edwardjones.com>
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <345F7B57.41C8@edwardjones.com>

Bob Weissman wrote:

<snip>

> If such a beast does not exist, I'd be happy with a script which simply
> removes all comments from C and C++ source, including multi-line
> comments.  Then I could code the rest myself, but I'm not enough of a
> perl wiz to know how to strip multi-line comments.

Why not just write it in C? A simple finite state machine does quite
nicely.

WARNING: the following program was composed at the keyboard and not even
compiled much less tested. It probably contains constructs from several
different languages. But you get the idea.

#include <stdio.h>
#define CODE 1
#define FOUND_SLASH 2
#define BLOCK_COMMENT 3
#define FOUND STAR 4
#define LINE_COMMENT 5

main()
{
int state, c;

state = CODE;
c = getchar();

while (not eof())
{
   c = getch();
   switch (state)
   {
   case CODE:
      if ( '/' == c ) then
         state = FOUND_SLASH;
      else
         putchar(c);
      break;
   case FOUND_SLASH:
      if ( '*' == c ) then
         state = BLOCK_COMMENT;
      else if ( '/' == c ) then
         state = LINE_COMMENT;
      else
      {
         putchar('/');
         putchar(c);
         state = CODE;
      }
      break;
   case BLOCK_COMMENT:
      if ( '*' == c ) then
         state = FOUND_STAR;
      break;
   case FOUND_STAR:
      if ( '/' == c ) then
      {
         state = CODE;
         putchar(' '); /* insert space as separator */
      else if ( '*' != c ) then
         state = BLOCK_COMMENT;
      break;
   case LINE_COMMENT:
      if ( '\n' = c ) then
      {
         state = CODE;
         putchar('\n');
      }
      break;
   }
}

-- 
Eric Buckley
Comsys Millennium Services
eMail: remove NoSpam from above
Standard disclaimer - I speak for myself and nobody else.


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

Date: Tue, 04 Nov 1997 14:11:42 -0500
From: Ben Newman <benneman@nortel.SPAM.BUSTER.ca>
Subject: signal handling
Message-Id: <345F736D.1DA13D32@nortel.SPAM.THIS.ca>


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

I have an application which relies on signals from a child process for
asynchronous event notification.
The parent process is only ever interrupted while in a loop. I can
successfully catch the signals (verified
by putting die/print statements in the signal handling routines) but I
can't get the code in reset to execute.

Anyone know what's going on?

sub catchSigUsr1 {

    reset();

}

sub catchSigUsr2 {

    reset();

}

sub reset {

    print "Resetting...\n";
    sleep(2);                          # give everything a chance to
settle down
    print ($cmd = "stat off\n");
    print CSMWTR $cmd;
    print ($cmd = "stat calib\n");
    print CSMWTR $cmd;
    $rate = $rate * 0.95;        # slow things down by 5%
    print "Restarting at new rate $rate\n";
    $adjRate = 3600/$rate;
    return;
}

$SIG{USR1} = \&catchSigUsr1;
$SIG{USR2} = \&catchSigUsr2;

--
_______________________________________________
Ben Newman                   benneman@nortel.ca
Nortel Technologies

35 Davis Drive                    (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613      ESN 294-2622
_______________________________________________

Note: In an effort to reduce spamming, the reply
to address in this message's header may be
incorrect. Please use benneman@nortel.ca.



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

<HTML>
I have an application which relies on signals from a child process for
asynchronous event notification.
<BR>The parent process is only ever interrupted while in a loop. I can
successfully catch the signals (verified
<BR>by putting die/print statements in the signal handling routines) but
I can't get the code in reset to execute.

<P>Anyone know what's going on?

<P>sub catchSigUsr1 {<BR>
<BR>
&nbsp;&nbsp;&nbsp; reset();<BR>
<BR>
}<BR>
<BR>
sub catchSigUsr2 {<BR>
<BR>
&nbsp;&nbsp;&nbsp; reset();<BR>
&nbsp;<BR>
}<BR>
<BR>
sub reset {<BR>
&nbsp;<BR>
&nbsp;&nbsp;&nbsp; print "Resetting...\n";<BR>
&nbsp;&nbsp;&nbsp; sleep(2);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# give everything a chance to settle down<BR>
&nbsp;&nbsp;&nbsp; print ($cmd = "stat off\n");<BR>
&nbsp;&nbsp;&nbsp; print CSMWTR $cmd;<BR>
&nbsp;&nbsp;&nbsp; print ($cmd = "stat calib\n");<BR>
&nbsp;&nbsp;&nbsp; print CSMWTR $cmd;<BR>
&nbsp;&nbsp;&nbsp; $rate = $rate * 0.95;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
# slow things down by 5%<BR>
&nbsp;&nbsp;&nbsp; print "Restarting at new rate $rate\n";<BR>
&nbsp;&nbsp;&nbsp; $adjRate = 3600/$rate;<BR>
&nbsp;&nbsp;&nbsp; return;<BR>
}

<P>$SIG{USR1} = \&amp;catchSigUsr1;
<BR>$SIG{USR2} = \&amp;catchSigUsr2;
<PRE>--&nbsp;
_______________________________________________
Ben Newman&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; benneman@nortel.ca
Nortel Technologies

35 Davis Drive&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (919)991-2622
Research Triangle Park
Raleigh, North Carolina 27613&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ESN 294-2622
_______________________________________________

Note: In an effort to reduce spamming, the reply
to address in this message's header may be&nbsp;
incorrect. Please use benneman@nortel.ca.</PRE>
&nbsp;</HTML>

--------------A40DF0DB81FAF6317E29CC5F--



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

Date: Tue, 4 Nov 1997 09:16:27 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: tfaith@leo.aye.net
Subject: Re: slow server
Message-Id: <Pine.GSO.3.96.971104091418.17982M-100000@usertest.teleport.com>

On Mon, 3 Nov 1997, TFaith wrote:

> I have a very slow server. I have a cgi that sends e-mail to everyone in
> an array and it takes a few minutes. Is it possible to print out to the
> user a "Thanks, everything worked fine" message while the program is
> still busy e-mailing?

Yes, and the folks in a newsgroup about CGI programming should be able to
tell you about how to do that, if it's not already in their FAQ. Good
luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 4 Nov 1997 09:14:04 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Francois <leurmy@akula.com>
Subject: Re: Type="file" and CGI
Message-Id: <Pine.GSO.3.96.971104091212.17982L-100000@usertest.teleport.com>

On Tue, 4 Nov 1997, Francois wrote:

> I'm trying to process a file sent by a form using the <input
> type="file"> tag.
> 
> If I use the enctype="multipart/form-data" attribute in my <form> tag, I
> transfer nothing.
> On the other hand, if I remove the enctype="multipart/form-data"
> attribute, then I only transfer the path as a value.

Your Perl code seems fine, especially since you didn't post any of it. :-)

It sounds as if you're not getting what you expect from a browser, server,
or through the Common Gateway Interface. So you should re-check the
appropriate docs and FAQs. If you've still got questions after that, try
asking in a newsgroup about those topics. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 4 Nov 1997 11:58:40 +0000
From: ECM Selection Ltd <vanessa@ecmcel.demon.co.uk>
Subject: UKs Top Perl, Java, CGI Opportunities, ECM
Message-Id: <K42ak$Aw3wX0Ewza@ecmcel.demon.co.uk>

                The UKs Top Perl, Java, CGI Opportunities

                     PhD, MSc, 1st Class, 2.1 Hons?



        For the pick of the UKs most challenging opportunities in:

                        Network Security
                        Messaging
                        Search Agents / Robots
                        User Interfacing

visit:          http://www.ecmsel.co.uk





 
For further information on ECM and to search our ONLINE VACANCY DATABASE visit
http://www.ecmsel.co.uk.

Please contact us by Email (CVs in plain ASCII text - not coded!) 
topjob@ecmsel.co.uk.

Alternatively Snail, Fax or Phone:
ECM Selection Ltd, The Maltings, Burwell, Cambridge, CB5 0HB
Phone: 01638 742244                             Fax: 01638 743066


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

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

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