[7645] in Perl-Users-Digest
Perl-Users Digest, Issue: 1271 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 4 19:17:13 1997
Date: Tue, 4 Nov 97 16:00:22 -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: 1271
Today's topics:
Re: Combining two files into a two-column file (Charles DeRykus)
Re: dates and times (Charles DeRykus)
Re: how to get a program name ($0 etc.) (Parillo)
Re: HTTP Bug? 404 Not Found (Toutatis)
Number::Format [was: Re: Best way to comma seperate a n (William R. Ward)
Re: ODBC and Apostrophe <rsmith@nac.net>
OPEN mechanism (Scott M. Wiebe)
Re: OPEN mechanism <rootbeer@teleport.com>
Re: open() redirection failing under NT/CGI. (Jason Gloudon)
Re: Perl Assignment!! (brian d foy)
Perl build 303 -> 311 <cboget@apdi.net>
Re: Perl debug <jay@rgrs.com>
Re: Perl debug (Ilya Zakharevich)
Perl W32, PerlIs and IIS <shire@bigwave.ca>
Re: Perl W32, PerlIs and IIS <shire@bigwave.ca>
q: Recursive Search & Replace every dir except...? (Drake Cleary)
Re: Seeking Year 2000 checker OR comment stripper for C (brian d foy)
Re: Seeking Year 2000 checker OR comment stripper for C (brian d foy)
Re: Seeking Year 2000 checker OR comment stripper for C (Ronald L. Parker)
Re: Seeking Year 2000 checker OR comment stripper for C <usenet-tag@qz.little-neck.ny.us>
Re: Seeking Year 2000 checker OR comment stripper for C (John Moreno)
Re: Seeking Year 2000 checker OR comment stripper for C (brian d foy)
send & recieve data through socket <pe@news.lssu.edu>
waiting for forks <mrinella@earthlink.net>
Web interface to /etc/mail/aliases ? <forrie@tiac.net>
why (and when) does undef == 0? <tkeitt@santafe.edu>
Re: why (and when) does undef == 0? (brian d foy)
Re: Your opinion on The Perl Journal (TPJ) ? (Jon Orwant)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 4 Nov 1997 20:44:18 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Combining two files into a two-column file
Message-Id: <EJ52xv.BFB@bcstec.ca.boeing.com>
In article <m3zpnl82vy.fsf@windlord.Stanford.EDU>,
Russ Allbery <rra@stanford.edu> wrote:
>Steffen Kluge <kluge@fujitsu.com.au> writes:
>
>> When combining two text files side-to-side in order to produce a
>> two-column file I'm usually using something along the lines of:
>
>> awk '{printf "%s", $0; getline < F2; printf " %s\n", $0}' F2=f2.txt f1.txt
>
>The equivalent in Perl would be something like:
>
>perl -pe 'BEGIN {open (F2, "f2.txt")} chomp; print "$_ " . <F2> . "\n"' f1.txt
>
Here's an obfuscated variant of the nice one above:)
perl -pe 'BEGIN {open (F2, "f2.txt")} s/\n/\t$l/s if $l=<F2>' f1.txt
Regards,
--
Charles DeRykus
------------------------------
Date: Tue, 4 Nov 1997 18:48:41 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: dates and times
Message-Id: <EJ4xL6.2x0@bcstec.ca.boeing.com>
In article <345F525C.D5B998A5@nac.net>, Rick Smith <rsmith@nac.net> wrote:
> 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 ?
>
Check CPAN for Date::Calc or Date::Manip.
Or, if you eschew timesaving devices which require a trip
to the corner CPAN, you could use a combination of localtime
and Time::Local and roll something on your own.
perldoc -f localtime perlfunc
perldoc Time::Local
HTH,
--
Charles DeRykus
------------------------------
Date: 4 Nov 1997 23:28:57 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: how to get a program name ($0 etc.)
Message-Id: <63ob3p$d89$1@news01.li.net>
Is use constant a new part of Perl?
Can you tell me which man page it is on?
I am already on Perl 5, and I do not see it.
lparillo at suffolk dot lib dot ny dot us
Tom Phoenix (rootbeer@teleport.com) wrote:
: # Update these as needed!
: use constant SCRIPT_NAME => 'nifty_program';
: use constant SCRIPT_PATH => '/home/foo/bar/' . SCRIPT_NAME ;
: use constant SCRIPT_VERSION => '1.03 beta';
------------------------------
Date: 4 Nov 1997 23:53:14 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: HTTP Bug? 404 Not Found
Message-Id: <toutatis-ya023180000511970053130001@news.euro.net>
jobe@wam.umd.edu (Joe Benik) 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.
>
> So, I setup a local server to capture what my web browser was sending as a
> request... It is sending:
> GET /jabars.html HTTP/1.0
> Connection: Keep-Alive
> User-Agent: Mozilla/3.04 (Win95; I)
> Host: localhost:2345
> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
>
> I telnet back to the www.pornsugar.com server, and sent that exact
> text string. I still get a 404 Not Found error. I tried modifying the
> text string so it pointed to my correct host, this did not work either.
>
> I have tried about 6 more strings, all of which lead me to nothing but
> 404 Not Found errors.
>
> So, my question is. How come Netscape can get the HTML but I can't?
Probably, pornsugar.com runs as a virtualhost with a shared IP-adress. The
HTTP-server determines which virtualhost by $ENV{'HTTP_HOST'}, and sets the
document root for this request to some subdirectory, say:
/..../htdocs/pornsugar. Your primitive client didn't set this variable, so
the server looks for the document in the main document root, /..../htdocs
where it does not find it.
--
Toutatis
------------------------------
Date: 04 Nov 1997 13:49:23 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Number::Format [was: Re: Best way to comma seperate a number?]
Message-Id: <waapvogz5wb.fsf_-_@am.UCSC.EDU>
There was some discusson on comp.lang.perl.misc about separating a
number by commas and I proposed a new module, tentatively to be called
Number::Format. I'd like to solicit suggestions and existing code
from people who have an interest in formatting numbers. I'm willing
to write it, but want it to meet the needs of its users, so please
suggest to me in private e-mail what you think it should contain. I
will summarize what I hear.
I have changed the followups for this thread to comp.lang.perl.modules
so please send any reply postings to that group.
--Bill.
tadmc@flash.net (Tad McClellan) writes:
> William R. Ward (hermit@cats.ucsc.edu) wrote:
> : This sounds like a perfect candidate for a standard Perl module. We
> : all have to format numbers sometimes... Number::Format perhaps?
>
> Thanks. That would be useful.
>
> Please post an announcement here when you get it finished.
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
------------------------------
Date: Tue, 04 Nov 1997 14:59:20 -0500
From: Rick Smith <rsmith@nac.net>
To: Mike Heins <mheins@prairienet.org>
Subject: Re: ODBC and Apostrophe
Message-Id: <345F7E98.7EBED2B3@nac.net>
Mike Heins wrote:
> 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)";
maybe cuz you're missing the second apostrophe on $bob ?
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"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: 4 Nov 1997 20:38:22 GMT
From: scott.wiebe@bpal.com (Scott M. Wiebe)
Subject: OPEN mechanism
Message-Id: <63o13u$3l8$1@newsbell.bellglobal.com>
This is a rather indepth question reguarding perl's file handling.
When files are opened in the various modes, how (exactly) does perl handle the
file. In particular; when opening for append (">>FILENAME"), is the file a)
read in it's entirety into memory, b) read line by line (one line in memory at
a time) until EOF is found or c) some other method which I can't think of at
this moment.
I'm wondering what type of load is placed on the machine when an append is
done. Memory usage, I/O load, steps required. Does it matter when a file gets
very large or does it make no difference at all?
s
------------------------------
Date: Tue, 4 Nov 1997 15:04:30 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Scott M. Wiebe" <scott.wiebe@bpal.com>
Subject: Re: OPEN mechanism
Message-Id: <Pine.GSO.3.96.971104150234.17982e-100000@usertest.teleport.com>
On 4 Nov 1997, Scott M. Wiebe wrote:
> When files are opened in the various modes, how (exactly) does perl
> handle the file. In particular; when opening for append (">>FILENAME"),
> is the file a) read in it's entirety into memory, b) read line by line
> (one line in memory at a time) until EOF is found or c) some other
> method which I can't think of at this moment.
Perl tells the OS that it wants to open the file for appending. Then it's
up to the OS to do the right thing. :-) But that usually means that the
system will simply position the file pointer at the end of the file.
> I'm wondering what type of load is placed on the machine when an append
> is done. Memory usage, I/O load, steps required. Does it matter when a
> file gets very large or does it make no difference at all?
It should make (nearly) no difference at all on a well-designed OS. Hope
this helps!
--
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: 4 Nov 1997 22:07:55 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: open() redirection failing under NT/CGI.
Message-Id: <63o6br$m7p$1@daily.bbnplanet.com>
Steve Kilbane (Steve_Kilbane@cegelecproj.co.uk) wrote:
: System: Windows NT 4.0, Perl 5.004_01, compiled with M$ VC++.
: I'm using the open(F,"cmd|") construct, and while it works fine
: from the command line, it's not working when invoked as a
: CGI script by M$ IIS. "Not working" in this case means that
: the open() seems to work (doesn't invoke the associated "or die"),
: but that the redirection doesn't happen - following loop doesn't
: read any data under the CGI environment.
Are you using the full path name to cmd ? Your script may inherit a different
environment when run from the Web Server.
Jason Gloudon
------------------------------
Date: Tue, 04 Nov 1997 15:23:10 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl Assignment!!
Message-Id: <comdog-ya02408000R0411971523100001@news.panix.com>
In article <eli$9711041339@qz.little-neck.ny.us>, Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>brian d foy <comdog@computerdog.com> wrote:
>> >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"?
that's for my name, not Perl (the language) or perl (the executable).
i really hate to see contrived acronyms become accepted as real ones.
although i noticed that the case of /perl/i changed between the
first edition of "Programming perl" and the second edition,
"Programming Perl".
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
style guide <URL:http://computerdog.com/brian/style.html>
doesn't like to yell
------------------------------
Date: 4 Nov 1997 22:36:56 GMT
From: "Chris" <cboget@apdi.net>
Subject: Perl build 303 -> 311
Message-Id: <01bce971$b1ba8ae0$075875cc@Chris>
This morning I had a perl (CGI) script that I had been
trying to modify running on build 303. I then upgraded
to build 311 and now whenever I try to run the .CGI, I
am constantly getting the error:
Cannot open internet site
Connection to server was reset
And the only thing that changed was the ver of perl.
I've checked the registry, the path, everything I can
think of but have come up empty. Any suggestions?
Also, the .CGI script is one that I got off of the net
that I'm trying to use to upload files through the web.
Thanx for your help.
Chris
------------------------------
Date: 04 Nov 1997 17:40:37 -0500
From: Jay Rogers <jay@rgrs.com>
To: Jack LaVigne <lavigne@houston.wireline.slb.com>, Kevin Lambright <kevinl@ascend.com>
Subject: Re: Perl debug
Message-Id: <82pvogs2oq.fsf@shell2.shore.net>
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> In article <yhfoh41dfe3.fsf@ascend.com>,
> Kevin Lambright <kevinl@ascend.com> wrote:
> > > Where can I get documentation that explains how to set up
> > > and run perl in debug controlled by emacs?
> >
> > Having perl-mode.el is good, but it won't get you the debugger. You
> > also need perldb.el (or perldb+.el, which has cleaned up a few things).
> >
> > Put this in your personal emacs lib path, or your site emacs lib path,
> > byte compile it, if you wish and add the following lines to your
> > .emacs file:
>
> One does not need any additional package to debug Perl under RMS
> Emacs. XEmacs may have broken this support (as most other things), so
> my comment may be irrelevant.
>
> So if you use RMS Emacs, please ignore the above advice. Just use M-x
> perldb, or upgrade to CPerl.
OK, let's try to clarify things...
First to answer Jack's original question. Not much documentation is
needed for using perl debugging support in Emacs or XEmacs. Start it
by doing M-x perldb and then do C-h m to get documentation about the
debugger mode.
Support for debugging perl programs comes standard with Emacs and
XEmacs. As Kevin pointed out there is an improved version called
perldb+.el and I'm maintaining it.
perldb+.el allows you to position to where errors or warnings occur in
the source. It also provides filename completion when entering the
source to debug. It's known to work with versions Emacs 19.XX, Emacs
20.XX, XEmacs 19.XX, and Emacs 19.34 for NT/95.
You can find perldb+.el at
ftp://cpan.perl.org/pub/CPAN/authors/id/JROGERS/
Beware of ftp://cpan.perl.org/pub/CPAN/misc/emacs/perldb.el - it is
only needed for and only works for emacs18. The CPAN gods should
rename this to perldb18.el
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: 4 Nov 1997 23:15:27 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl debug
Message-Id: <63oaaf$nf7$1@agate.berkeley.edu>
In article <82pvogs2oq.fsf@shell2.shore.net>, Jay Rogers <jay@rgrs.com> wrote:
> > So if you use RMS Emacs, please ignore the above advice. Just use M-x
> > perldb, or upgrade to CPerl.
>
> OK, let's try to clarify things...
>
> First to answer Jack's original question. Not much documentation is
> needed for using perl debugging support in Emacs or XEmacs. Start it
> by doing M-x perldb and then do C-h m to get documentation about the
> debugger mode.
>
> Support for debugging perl programs comes standard with Emacs and
> XEmacs. As Kevin pointed out there is an improved version called
> perldb+.el and I'm maintaining it.
>
> perldb+.el allows you to position to where errors or warnings occur in
> the source. It also provides filename completion when entering the
> source to debug. It's known to work with versions Emacs 19.XX, Emacs
> 20.XX, XEmacs 19.XX, and Emacs 19.34 for NT/95.
Thanks for clarification. I was attacked by a person who wanted to
support perldb.el, and I could not get an explanation from him who on
earth would do it, except some words about XEmacs. Now I see that my
opinion about a need for perldb.el is correct.
Now back to perldb+. Can you merge the filename continuation of
perldb+ into CPerl? The rest is already there.
Ilya
------------------------------
Date: 4 Nov 1997 21:17:19 GMT
From: "SH Ir Env." <shire@bigwave.ca>
Subject: Perl W32, PerlIs and IIS
Message-Id: <01bce967$95102da0$a82e658e@cgi-00266.tor.cgi.net>
Hi. I'm trying to set up perl for cgi use without having to make url's
like:
http://unsecure.com/scripts/perl.exe?myscript.pl+This_argument
Doing it this way works, but is unsecure. The script works perfectly on
the command line. The .exe and .dll are in FAT, so I don't have to set any
permissions on them.
In the registry under
CurrentControlSet\Services\W3SVC\Parameters\script_map, i've tried:
.pl : REG_SZ : D:\{path to perl}\perl.exe
and used the URL:
http://unsecure.com/scripts/myscript.pl?This_argument
NT then starts up perl, but never sends any output to the client browser.
It also keeps that copy of perl running until you restart the service.
then I tried:
.pl : REG_SZ : D:\{path to perl}\perlis.dll
and used the URL:
http://unsecure.com/scripts/myscript.pl?This_argument
The script does work, but it doesn't pick up the argument "This_argument"
I've also tried throwing %1's in the registry in every perceivable
configuration, but to no avail.
Any other guesses?
Mike
------------------------------
Date: 4 Nov 1997 21:28:15 GMT
From: "SH Ir Env." <shire@bigwave.ca>
Subject: Re: Perl W32, PerlIs and IIS
Message-Id: <01bce969$1c3f9c60$a82e658e@cgi-00266.tor.cgi.net>
Thanks. Found the answer in Microsoft's Web Site. (missing %s %s in
registry)
SH Ir Env. <shire@bigwave.ca> wrote in article
<01bce967$95102da0$a82e658e@cgi-00266.tor.cgi.net>...
> Hi. I'm trying to set up perl for cgi use without having to make url's
> In the registry under
>
------------------------------
Date: Tue, 04 Nov 1997 20:57:22 GMT
From: killbell@peterboro.net (Drake Cleary)
Subject: q: Recursive Search & Replace every dir except...?
Message-Id: <345f8ba2.3108205@news.peterboro.net>
Is there any way to make the following command
exclude one or more specific directories???
find . -name '*.html' | xargs perl -pi -e
's/searchtext/replacetext/gm;'
Thanks in advance.
------------------------------
Date: Tue, 04 Nov 1997 15:14:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <comdog-ya02408000R0411971514000001@news.panix.com>
In article <19971104111111204405980N@roxboro-162.interpath.net>, phenix@interpath.com (John Moreno) wrote:
>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;
how about this input data:
$test =<<"DATA";
#include <stdio.h>
int main(void)
{
printf("a C comment looks like /* comment */\n");
return 1;
}
DATA
not so easy is it? you can't blindly munge a source file and expect it
not to break.
that's why many good people have contributed much more sophisticated
answers to the Perl FAQ.
--
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, 04 Nov 1997 15:26:18 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <comdog-ya02408000R0411971526180001@news.panix.com>
In article <345F7B57.41C8@edwardjones.com>, Eric Buckley <Eric.NoSpam.Buckley@edwardjones.com> wrote:
>Bob Weissman wrote:
>> 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.
maybe you'd like to cancel your message after testing it against my
simple program:
#include <stdio.h>
int main(void)
{
printf("a C comment looks like /* comment */");
return 1;
}
--
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>
if you haven't done it before and haven't tested it, don't post it
------------------------------
Date: Tue, 04 Nov 1997 20:21:58 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <345f7bfa.14199738@news.supernews.com>
On Tue, 4 Nov 1997 12:09:07 -0500, phenix@interpath.com (John Moreno)
wrote:
>Stripping comments is easy.
Quoting from the Perl FAQ:
+------>8
|While this actually can be done, its much harder than youd think.
|For example, this one-liner
|perl -0777 -pe s{/\*.*?\*/}{}gs foo.c
|will work in many but not all cases. You see, its too simple-minded
|for certain kinds of C programs, in particular, those with what appear
|to be comments in quoted strings.
+-------
This gets really ugly in this case:
+------->8
|char *MyHeaderString = "/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/";
|if ( year < startyear ) {
| introduce_subtle_untraceable_bug_into_data( );
| }
|sprintf( DateString, "Period ends on %s %d, 19%2.2d", monthname[month], day, year );
|/* Print period ending date */
+---------
which gets changed to:
+------->8
|char *MyHeaderString = "*****
+---------
How to do it, then? Do what Tad already suggested: RTFFAQ.
Better yet, don't strip the comments - you won't gain that much by
doing so, anyway. The job is still monumentally difficult, since the
only way to do it right is to track any variables that come from a
date-ish function, and any variables that those variables taint, and
so on. Having the comments might help with that process.
Oh, and hope you don't read a 2-digit date from a database file from
outside your realm and "convert" it to 4 digits without using any
date-ish functions.
This late in the century, it's probably easier to convert your data to
work with your competitor's product that was written right the first
time.
------------------------------
Date: 4 Nov 1997 22:34:18 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <eli$9711041719@qz.little-neck.ny.us>
John Moreno <phenix@interpath.com> wrote:
> In comp.lang.perl.misc Bob Weissman <weissman@netcom.com> wrote:
> ] 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
> Stripping comments is easy. Here's some test code to show how to do it,
Yes. And covered in great detail in Friedl's _Mastering Regular
Expressions_ because of all the seemingly correct answers which
are not.
# New $test
$test = q!
/*char y = '\'' /* */
char x = '"';
/*
* Some fun source code
*/
char foo[] = "/*",
bar[] = "*/",
qux[] = "//";
!;
> $test =~ s#(/\*.*?\*/)##sg;
> $test =~ s#(//.*)##g;
>
> print "\n\nAfter regex:\n";
> print $test;
After regex:
char x = '"';
char foo[] = "",
qux[] = "
I'll let you figure out how to avoid quoting problems on your own,
either with the hip owls book or without it. :^)
Elijah
------
use cpp, that way you can find stuff in #define's, too
------------------------------
Date: Tue, 4 Nov 1997 17:38:46 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <19971104172848218004760N@roxboro-162.interpath.net>
brian d foy <comdog@computerdog.com> wrote:
] phenix@interpath.com (John Moreno) wrote:
]
]
] >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.
-snip code better forgotten-
] how about this input data:
]
] $test =<<"DATA";
] #include <stdio.h>
]
] int main(void)
] {
] printf("a C comment looks like /* comment */\n");
]
] return 1;
] }
] DATA
]
] not so easy is it? you can't blindly munge a source file and expect
] not it to break.
Well, *I've* never written code like that.
] that's why many good people have contributed much more sophisticated
] answers to the Perl FAQ.
So I found out soon after replying - sorry.
------------------------------
Date: Tue, 04 Nov 1997 18:37:21 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Seeking Year 2000 checker OR comment stripper for C/C++
Message-Id: <comdog-ya02408000R0411971837210001@news.panix.com>
In article <19971104172848218004760N@roxboro-162.interpath.net>, phenix@interpath.com (John Moreno) wrote:
>brian d foy <comdog@computerdog.com> wrote:
>] $test =<<"DATA";
>] #include <stdio.h>
>]
>] int main(void)
>] {
>] printf("a C comment looks like /* comment */\n");
>]
>] return 1;
>] }
>] DATA
>]
>] not so easy is it? you can't blindly munge a source file and expect
>] not it to break.
>
>Well, *I've* never written code like that.
it doesn't matter if you wrote it or not. the point is that you
can't take a source file and do global replaces on it without doing
a lot of work to ensure that you aren't munging something you shouldn't.
not everyone has the luxury (or punishment) of working solely with
his or her own code.
--
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, 04 Nov 1997 18:47:45 -0500
From: Pe' <pe@news.lssu.edu>
Subject: send & recieve data through socket
Message-Id: <345FB421.5FE5@news.lssu.edu>
Hi there,
I have problem write a client-server program using socket. What I want
to do is have srver running in background as daemon process and have
client program get the information then send the information to server
via socket. I get the socket part down pretty much but I don't know how
to send and recive data through socket between client and server. Here
is my simple program both server and client ->
client ->
#!/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);
$clientaddr = pack($sockaddr, &AF_INET, 0, $rawaddr);
$serveraddr = pack($sockaddr, &AF_INET, $port, $rawaddr);
socket(CLIENT, &PF_INET, &SOCK_STREAM, $protocol) || die("\nNo
socket\n");
bind(CLIENT, $clientaddr) || die("\ncan't bind\n");
connect(CLIENT, $serveraddr);
$line = <CLIENT>;
print("\n$line\n); <- get data from server daemon
open(STDOUT, ">&CLIENT");
print CLIENT ("Send information back to server"); <- I try to
send something back
to server daemon
close(CLIENT);
--------------------------------------
now the server daemon ->
#!/usr/bin/perl
require 'sys/socket.ph';
$service_nam = 'auto-acct';
$service_port = 5000;
$SIG{'PIPE'} = 'IGNORE';
$hostname = `hostname`;
chop($hostname);
($name, $aliases, $protocol) = getprotobyname('tcp');
($name, $aliases, $type, $len, $rawaddr) = gethostbyname($hostname);
if($service_nam)
{
($name, $aliases, $port) = getservbyname($service_nam, 'tcp');
$service_port = $port if $port;
}
$sockaddr = 'S n a4 x8';
$serveraddr = pack($sockaddr, &AF_INET, $service_port, $rawaddr);
select(SLAVE); $| = 1; select(stdout);
socket(MASTER, &PF_INET, &SOCK_STREAM, $protocol) || die("socket:
$!\n");
bind(MASTER, $serveraddr) || die("bind: $!\n");
listen(MASTER, 5) || die("listen: $!\n");
select(MASTER); $| = 1; select(stdout);
for(;;)
{
($clientaddr = accept(SLAVE, MASTER)) || die("accept: $!\n");
select SLAVE;
($af, $remote_port, $remote_ip) = unpack($sockaddr, $clientaddr);
##########################
#### THE ACTUAL CODE ####
##########################
$line = "Test socket Daemon server and it works!";
print SLAVE ("$line\n");
open(STDIN, "<&SLAVE") || die("stdin: $!\n"); <- right here that I
want to
open(FILE, "test.fl"); <- receive info. from
client
print FILE (SLAVE); <- then print out to
file.
close(FILE);
@inetaddr = unpack('C4', $remote_ip);
print "\nConnecting from ",@inetaddr," $remote_port\r\n";
close SLAVE;
}
How can I do it?.. Please help me out, I'm kind na stuck here. Really
appreciate any help
thanx
pe'
------------------------------
Date: Tue, 04 Nov 1997 14:28:26 -0800
From: matthew rinella <mrinella@earthlink.net>
Subject: waiting for forks
Message-Id: <345FA18A.FE5E852E@earthlink.net>
I want my perl script to run a large list of child processes, but
only have 2 running at any given time.
any advice?
thanks in advance
matt
------------------------------
Date: Tue, 04 Nov 1997 16:03:04 -0500
From: Forrest Aldrich <forrie@tiac.net>
Subject: Web interface to /etc/mail/aliases ?
Message-Id: <345F8D88.62ABCC40@tiac.net>
Has anyone a web interface that makes it easier for "novices" to manage
an aliases (and perhaps other tables) databases? We have a need to
create something, but I'd rather not re-invent the wheel.
TIA...
------------------------------
Date: Tue, 04 Nov 1997 13:19:09 -0700
From: "Timothy H. Keitt" <tkeitt@santafe.edu>
Subject: why (and when) does undef == 0?
Message-Id: <345F833D.60D6@santafe.edu>
Hi,
I'm curious why an undefined scalar value takes the value zero when used
in an arithmetic expression (but not always), e.g., 10 * undef returns
the value 0, but undef * 10 returns undef! Try for example:
perl -e '$a=10*undef;$b=undef*10;print defined$a?"a is defined\n":"a is
undefined\n";print defined$b?"b is defined\n":"b is undefined\n"'
It seems that any operation on undef should return undef, no? I'm using
perl5 (5.0 patchlevel 4 subversion 0).
Cheers,
Tim
------------------------------
Date: Tue, 04 Nov 1997 18:23:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: why (and when) does undef == 0?
Message-Id: <comdog-ya02408000R0411971823010001@news.panix.com>
In article <345F833D.60D6@santafe.edu>, "Timothy H. Keitt" <tkeitt@santafe.edu> wrote:
>I'm curious why an undefined scalar value takes the value zero when used
>in an arithmetic expression (but not always), e.g., 10 * undef returns
>the value 0, but undef * 10 returns undef! Try for example:
>
>perl -e '$a=10*undef;$b=undef*10;print defined$a?"a is defined\n":"a is
>undefined\n";print defined$b?"b is defined\n":"b is undefined\n"'
>
>It seems that any operation on undef should return undef, no? I'm using
>perl5 (5.0 patchlevel 4 subversion 0).
from an algebraic perspective, the order of operands is important. in
your first case you are operating on 10 (a number) and get a number
back. in the second case, you operate on undef and get undef. this
seems to be reasonable behaviour - in an algebraic sense.
from a perl perspective, let's remember that undef is an operator,
although perl let's us get away with a bit of syntatic sloppiness
with it sometimes.
let's compare the results of a more careful way of writing this:
#!/usr/bin/perl
$a = undef * 10;
$b = undef() * 10;
$c = undef() * undef();
$d = '' * 10;
$e = 'just another new york perl hacker' * 10;
print <<"HERE";
----
a = $a
b = $b
c = $c
d = $d
e = $e
----
HERE
__END__
i won't spoil this, but one of the results of this script is different
from the others (<music>one of these thigs just isn't the same). in
that difference is your answer :)
--
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: 04 Nov 1997 21:56:05 GMT
From: orwant@fahrenheit-451.media.mit.edu (Jon Orwant)
To: faust@wwa.com
Subject: Re: Your opinion on The Perl Journal (TPJ) ?
Message-Id: <ORWANT.97Nov4165605@fahrenheit-451.media.mit.edu>
In article <345758c4.6302369@news.wwa.com> faust@wwa.com (Faust Gertz) writes:
> >> What do you like best about the Perl Journal?
> >
> >The stories you wouldn't hear about otherwise, for instance the article
> >"Perl and the Human Genome Project".
>
> Actually, you can find some of the articles from the Perl Journal in
> other sources. Lincoln Stein's "How Perl Saved the Human Genome
> Project" appeared in the Spring 1997 issue of _Dr. Dobb's Journal_
> (http://www.ddj.com/ddj/1997/1997.careers/stei.htm) and was presented
> at the O'Reilly Perl Conference (http://conference.perl.com/) I also
> believe I saw Lincoln's articles entitled "The Mangler" an "Rating Web
> Page Tastefulness" in another periodical. Perhaps in _Web
> Techniques_? I could be wrong.
You're not -- but in every instance it's other magazines reprinting
articles that appeared earlier in TPJ. The sole exception is Lincoln,
who sometimes writes two articles on the same topic -- a general
interest piece for WebTechniques and a Perl-centric version for TPJ.
To the best of my recollection, TPJ articles have been reprinted in
the World Wide Web Journal, Linux Journal, Dr. Dobb's Journal, and the
O'Reilly Perl Resource Kit (both individual articles and an entire
miniaturized bite-size copy of TPJ #7). An upcoming book might
excerpt a few articles as well.
Article reprints have been used for a couple dozen classes, seminars,
and tutorials.
Copies of issue #7 were also given away on Hallowe'en as a nutritious
alternative to candy.
-Jon
------------------------------------
Jon Orwant http://tpj.com
Editor & Publisher, The Perl Journal
------------------------------
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 1271
**************************************