[7137] in Perl-Users-Digest
Perl-Users Digest, Issue: 762 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 24 03:38:51 1997
Date: Thu, 24 Jul 97 00:02:12 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 24 Jul 1997 Volume: 8 Number: 762
Today's topics:
Re: Idea for a New Perl Book <friedman@uci.edu>
Re: if ($var =~ '\\' ) { ... } (Christopher Ryan Sidi)
Re: Integer arrays in an XS extension.. (Ken Fox)
Loading hash crashes computer <mdudley@execonn.com>
Re: Looking for a routine to trim white space (like VB (Craig Berry)
LWP::Simple proxy <kenlo@hk.super.net>
Re: MD5 in PERL? <rootbeer@teleport.com>
Re: Merging large complex data structures--answers... (Chris Sherman)
Re: Mysterious new error? <g-fast@ux4.cso.uiuc.edu>
Re: newbie problem with $1 (M.J.T. Guy)
Re: newsgroup archives? <murray@cdrom.com>
Re: NNTP Access <rootbeer@teleport.com>
perl alert? <cascioli@geocities.com>
Perl for win 95 ? <kj.jl@klaipeda.omnitel.net>
Re: Perl for win 95 ? (etta )
Perl Interface to /etc/passwd (Harichandran Sukerathavan)
Re: Perl print buffer. <rootbeer@teleport.com>
Re: Perl Scripts and Windows NT (etta )
Re: perl vs python vs icon shamim@nospam.com
Please comment: perl (NNTP) gateway <M.Turcotte@icrf.icnet.uk>
Please Help: Pattern Matching (daniel abrams)
Re: Please Help: Pattern Matching <dev@sgi.net>
Re: Please Help: Pattern Matching (daniel abrams)
Re: process handling <rootbeer@teleport.com>
Question: About strings, replacements and collapsing wh dcd@k12-dev.arc.nasa.gov
Re: Quick Substitute Tip Req'd <pdenman@ims.ltd.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jul 1997 21:10:52 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Idea for a New Perl Book
Message-Id: <5r37ks$ien@news.service.uci.edu>
[mailed, posted]
In article <33cbace6.8787691@news>, Marjorie Roswell <roswell@umbc.edu> wrote:
<address simpler tasks that most people on this newsgroup would smirk
<at if someone posted asking help with.
People ask simple questions here all the time, and the responses to
those questions vary widely. To my mind, whether a response is
negative or positive depends more on how the question is asked than on
its relative simplicity. Think about it: for Randall, Tom (x 2), Tad,
etc, >most< Perl questions will appear simple. And yet, they respond to
a large number of such queries, often in great deal. So if simplicity
of a question isn't the determining factor, what is? Here's an
approximate list of successful strategies:
1) A subject line that shows the person has some respect for her target
audience and doesn't resort to cute games like 'Do you know how to...'
2) Some evidence that the person has studied the available resources on
the web before posting. Few communities have resources as extensive as
the Perl language community's, and it behooves us to make use of them!
3) A >brief< description of the problem, together with some legible
(but not overly terse) code snippets, commented as necessary. In other
words, don't dump a 5,000 line script into a post and expect people to
debug it for you; conversely, don't send a message saying only "it
doesn't work!"
4) An indication that the person doesn't expect free private consulting
time: "Mail me because I don't have time to read this group!"
There are probably other factors I haven't listed, but this should give
you the idea.
<Most folks who send those annoyed RTFM posts (or usually RTFF, that
<last F standing for "FAQ") probably don't realize that you can often
<have studied all the building blocks of a task, without being actually
<able to complete the task or complete it in reasonable time. This book
<would fill that "in between" phase of someone who has become familiar
<with regexps, loops, special variables, file handles, etc, but needs
<some hand-holding to get real things done.
Well, they probably do realize that you can study all of the tools
needed for a task and still not know what to do, but this isn't the
place to learn that. You could stare at a new socket wrench for days
on end, read the manual over and over, and talk for hours to people who
use socket wrenches regularly, but you still won't learn how to replace
the alternator in your car. Don't get me wrong: I believe in
autodidacticism as much as the next person, but there are some cases
where mastering 'concepts' (as opposed to 'skills') requires some
specialized training. A software engineering course is one way to go;
reading one of the many books on the subject is another. In my view,
at least a few of Tom C.'s more vitriolic rants seemed motivated by his
frustration with people who insisted on trivializing the learned mental
discipline that good software design requires. He had spent time
learning that discipline - in addition to mastering the tools of Perl -
and believed enough in his training to think that others would benefit
from it too.
That said, I do wish the new camel had retained/expanded the pages
in the old camel which gave code snippets for common programming tasks
in Perl. These included 'computing the difference between two arrays'
and other helpful tidbits. Maybe you can find a copy somewhere? Or maybe
you can persuade ORA to release them into the public domain (web)?
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: 21 Jul 1997 00:30:47 GMT
From: gt6161c@acmex.gatech.edu (Christopher Ryan Sidi)
Subject: Re: if ($var =~ '\\' ) { ... }
Message-Id: <5quajn$if6@catapult.gatech.edu>
No Spam! (hate@spam.com) wrote:
: I'm trying to examine a $variable and see if it contains the \ character.
Sounds like you need the llama, but the soln is below:
#!/usr/bin/perl -w
$foo = 'boo\ger'; #single quotes are used
#so that we get a literal "\"
if ($foo =~ /\\/) { #look for a single backslash anywhere in the
#string
print "Yup, there is a backslash somewhere in:\n$foo\n";
}
------------------------------
Date: 24 Jul 1997 03:17:23 GMT
From: fox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Integer arrays in an XS extension..
Message-Id: <5r6hg3$9gv1@eccws1.dearborn.ford.com>
In article <52afjfnnia.fsf@ace.funcom.com>,
Marius Kjeldahl <marius@funcom.com> writes:
[Author wants to interface this function to perl:]
> void func2(int ar1[12], int i1, int i2, int i3, int i4, int i5,
> int ar2[4], int ar3[4])
Here's a typemap that handles 'int *'. It is unsafe in the sense
that the C code getting the 'int *' doesn't know how big it is. It
also depends upon a working alloca() to handle deallocating the
temporary array.
------------------------------
int * T_int_array
INPUT
T_int_array
if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
AV *av = (AV *)SvRV($arg);
int i = 0, len = AvFILL(av) + 1;
SV **sv;
$var = alloca(len * sizeof(int));
while (i < len) {
sv = av_fetch(av, i, 0);
if (sv && SvIOK(*sv)) {
${var}[i] = SvIV(*sv);
}
else {
${var}[i] = 0;
}
++i;
}
}
else {
croak(\"$var is not an array reference\");
}
------------------------------
You can use this typemap like so:
void
func2(ar1, i1, i2)
int * ar1
int i1
int i2
CODE:
printf("ar1[0] = %d, ar1[1] = %d, ar1[2] = %d\n", ar1[0], ar1[1], ar1[2]);
If I were writing this extension, I'd probably use a custom typemap
or just prototype the XS functions as taking an 'SV *' and do the
conversion myself in the CODE: section.
Does anybody have a good way for generating secondary variables
in a typemap? It would be nice to generate a variable ${var}_len to
stash the length of the array. Unfortunately, the variable declaration
has to go at the top of the block (for C anyways) so the INPUT clause
in the typemap can't do it. A PREINIT typemap clause would be really
nice. So would a way to pass additional information to the typemap --
like the dimension of an array.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: Wed, 23 Jul 1997 18:05:25 -0400
From: Marshall Dudley <mdudley@execonn.com>
Subject: Loading hash crashes computer
Message-Id: <33D68024.3ACA@execonn.com>
I am trying to load up a hash with values, but when I do, the comptuer
will lock up, or get an invalid
instruction fatal interrupt and close the window I am compiling in.
Basically filehandle TABLE contains a table of x y entries, the number
of impressions and click-thrus from system x to system y. The same keys
systems are located on the rows and columns.
Anyway, the following is the section of code which pulls the values out
of the matrix, and puts then into a two dimensional hash. @names is an
array of the site names in the same order as the both the rows and
columns are in. As you may guess this is for a banner exchange
application.
ie. for an array with 3 entries (we actually have about 80):
If we have ExecutiveConnection Links2Go Seacom in @name array and then
the <TABLE> file will look like this:
0=0 327=12 4736=213
873=43 0=0 9872=75
9872=432 8726=387 0=0
@lines = <TABLE>; #lines has the data for the sites
$n = 0;
foreach $line (@lines) {
$maxctr = 0;
$o = 0;
@pairs = split(' ',$line);
foreach $pair (@pairs) {
($impressions, $clicks) = split('=',$pair);
$impression{@name[$n],@name[$o]} = $impressions; #will
crash system
$click{@name[$n],@name[$o]} = $clicks; #will carsha
system
++$o;
}
++$n;
}
Everything works as would be expected if I comment out the lines which
build the hash for %impression and %click. But if either of those two
lines are left to compile, the system will crash, lock-up, or the
process will abort with an invalid instruction error, and the window
will close.
Anyone know why these instructions are causing these problems, and how
to get around it?
Thanks,
Marshall
------------------------------
Date: 22 Jul 1997 00:58:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Looking for a routine to trim white space (like VB trim$)
Message-Id: <5r10iq$sa5$1@marina.cinenet.net>
Steve O'Hara Smith (sohara@mardil.elsevier.nl) wrote:
: pk (pk@flexsol.co.nz) wrote:
: : I am looking for a routine like the Visual Basic trim$() to trim leading and
: : trailing spaces from a string.
:
: Try
:
: ($stripped) = $unstripped =~ /^\s*(\S.*\S)\s*$/;
...and fail miserably on ' x '. That parenthesized part requires two
non-whitespace characters to be in the string for anything to happen.
Why not just use
($stripped) = $unstripped =~ /^\s*(.*?)\s*$/;
Though even this is woefully inefficient, involving lots of backtracking
internally on many strings. Better still might be doing it in two
passes, one for each end of the string:
$stripped = $unstripped;
$stripped =~ s/^\s+//;
$stripped =~ s/\s+$//;
Hope this helps!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Mon, 21 Jul 1997 16:29:57 +0800
From: Kenneth LO <kenlo@hk.super.net>
Subject: LWP::Simple proxy
Message-Id: <33D31E05.4F2BD0F1@hk.super.net>
Is there any way to set proxy while using LWP::Simple ? I suppose I can
set $ENV{http_proxy}at the very beginning so that when LWP::Simple call
$ua->env_proxy the correct proxy value can be set. It does not however
work.
------------------------------
Date: Tue, 22 Jul 1997 16:44:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: lmm <lmm@vasco.com>
Subject: Re: MD5 in PERL?
Message-Id: <Pine.GSO.3.96.970722164111.28607H-100000@kelly.teleport.com>
On 22 Jul 1997, lmm wrote:
> Has anyone come across MD5 implementes in PERL?
>
> I know that there are modules you can compile for PERL written in C,
> but, from my understanding, it is not transportable to different
> platforms except by compiling.
That's right. And you can't transport Perl itself to different platforms
except by compiling, so that's not usually too onerous. :-)
> With a PERL version of MD5, one could then use it on any platform that
> has PERL.
Yes, and terribly slowly. :-) That's why linkable modules were developed,
so that you could Perl for its strengths and not use it for its
weaknesses.
If you can't compile the existing module, it would be better to use one of
the standalone MD5 applications, and run that from Perl. Of course, you
may need to compile one of those...
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/
------------------------------
Date: Mon, 21 Jul 1997 22:18:29 GMT
From: sherman@unx.sas.com (Chris Sherman)
Subject: Re: Merging large complex data structures--answers...
Message-Id: <EDowMt.K5A@unx.sas.com>
In <EDoDHJ.2uD@unx.sas.com> sherman@unx.sas.com (Chris Sherman) writes:
>I want to merge two complex data structures into a new variable.
>So, in effect, I want to do:
> %TV = %TV1 + %TV2; # thinking of '+' as a union operator
I've received a couple of answers that seem to work.
I would like to thank Tom Phoenix <rootbeer@teleport.com>
and Ben Gertzfield <che@imsa.edu> for their responses.
One method is to:
%TV = (%TV1, %TV2);
The second method is to:
@TV1{ keys %TV2 } = values %TV2;
which merges %TV2 into %TV1. I was warned that the second
method copies only references, but not the data itself.
I've tested both, and they both work. The second one
is neat because I never knew you could put the keys
statement on the LHS of an expression--pretty cool.
--
____/ / / __ / _ _/ ____/
/ / / / / / / Chris Sherman
/ ___ / _/ / /
_____/ __/ __/ __/ _\ _____/ _____/ sherman@unx.sas.com
------------------------------
Date: 22 Jul 1997 16:09:07 -0500
From: gregory douglas fast <g-fast@ux4.cso.uiuc.edu>
Subject: Re: Mysterious new error?
Message-Id: <m7goh7urdzg.fsf@ux4.cso.uiuc.edu>
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> In article <m7gg1tct6hh.fsf@ux4.cso.uiuc.edu>,
> gregory douglas fast <g-fast@ux4.cso.uiuc.edu> wrote:
> > Upon upgrading our site to 5.004, we started getting this error from a
> > script which has previously (under 5.003) run fine:
> >
> > DESTROY created new reference to dead object during global destruction.
> >
> > Since the error occurs in global destruction, the script completes its
> > work, but I can't find any reference to this kinda of error in
> > perldiag or anywhere else. I'd love to eliminate this message, since
> > the script isn't supposed to be tossing any output to stdout or
> > stderr, but I don't know enough about perl internals to be able to
> > figure out what might be going on.
> >
> > Any suggestions as to what I could check for?
>
> The message is absolutely clear: you should check for DESTROY creating
> new reference to dead objects. You can find out *which* DESTROY is
> faulty by using `f'rame `O'ption of debugger (see perldebug).
>
> An example of bad code is this one:
>
> DESTROY { $self = shift; }
>
> Note that `my' is missing before $self, so after a call to DESTROY an
> extra reference is created (in global $self), thus nullifying the
> target of DESTROY.
I'm much less confused now. I neglected to mention the helpful fact
that I don't have any DESTROYs in the code, hence my inability to
understand where the error was coming from (I was also unaware of that
capability of the debugger, that's realy neat :).
Now I've traced the problem to my AUTOLOAD routine, where I was doing
Bad Things with my $self, and made the error go away, but I'm now curious
as to the why of perl calling my AUTOLOAD routine for DESTROY. It
doesn't get called for BEGIN or END... am I just not understanding
something gutsy?
Thanks,
--
-- Greg Fast --- g-fast@uiuc.edu -------------------------------------------
"In the equally bad dreams of Jim, the "goffs," his particular name for them,
grew like monster meringue-paste mushrooms, which fed on rats which fed on
spiders which fed, in turn, because they were large enough, on cats."
-- Ray Bradbury, Something Wicked This Way Comes
------------------------------------------------------------------------------
------------------------------
Date: 21 Jul 1997 15:10:50 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: newbie problem with $1
Message-Id: <5qvu5q$9sb@lyra.csx.cam.ac.uk>
Mueller Beat <mueller@iwf.bepr.ethz.ch> wrote:
>consider the following short perl script :
>
>#!/appl/bin/perl -w
>
>$_ = "a sentence with __s__o__m__e highlithed __w__o__r__d__s is this.";
>
>if (/((__.)+)/)
>{
> s//<b>$1<\/b>/g;
> s/__//g;
>}
>
>print; print "\n";
>
>exit 0;
>
>the idea is a generate a string :
>
>" a sentence with <b>some</b> highlithed <b>words</b> is this."
which is exactly what your script does for me.
>why does it exit with a segmentation fault ? i think the problem is
>the $1 generated by the condition in if (). i could circumvent the
>problem by using a variable other than $_ but $_ is here to be used.
>i found nothing useful in the faq. (btw, i am using perl 5.0)
The above works for me for Perl versions 5.002 onwards. (I don't have
any earlier ones about.) Do you really mean you are using Perl 5.000?
If so, you certainly should upgrade - that was never a properly
released version.
Mike Guy
------------------------------
Date: Wed, 23 Jul 1997 13:39:08 -0700
From: Murray Stokely <murray@cdrom.com>
Subject: Re: newsgroup archives?
Message-Id: <33D66BEC.41C67EA6@cdrom.com>
That doesn't help anything. I need the actual message files of
course so I can make a searchable index of newsgroup messages (similar
to the functionality of dejanews, but not nearly as advanced, only one
group, and on cdrom). A few years ago usenet messages were archived on
all sorts of ftp sites, is this just being left up to companies like
dejanews now who flatout refuse access to their databases?
lvirden@cas.org wrote:
>
> Re: archives of comp.lang.perl.misc
>
> I don't know of ftp'able archives, but you should be able to go to
> <URL: http://www.dejanews.com/ > or <URL: http://www.reference.com/ > and
> search thru the archives.
> --
> Larry W. Virden INET: lvirden@cas.org
> <URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
> Unless explicitly stated to the contrary, nothing in this posting should
> be construed as representing my employer's opinions.
--
Murray Stokely
------------------------------
Date: Wed, 23 Jul 1997 10:07:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Sergio Stateri Jr <serginho@alpha.hydra.com.br>
Subject: Re: NNTP Access
Message-Id: <Pine.GSO.3.96.970723100253.23677B-100000@kelly.teleport.com>
On 23 Jul 1997, Sergio Stateri Jr wrote:
> Does anyone here know where I can find a Perl Script that access a
> NNTP server ?
There are some examples which come with the modules. Are those what you
need?
> I'd like a script that use only default perl modules, because I want to
> use this in a server that I can only to put my scripts, but I can't to
> install new modules.
Do you know that you don't have to be the root user to install modules?
But if your sysadmin has a rule against installing own modules, see
about installing a new sysadmin. :-)
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/
------------------------------
Date: Wed, 23 Jul 1997 23:52:02 +0200
From: ".70 Andreas 07." <cascioli@geocities.com>
Subject: perl alert?
Message-Id: <33D67D02.A6118B9E@geocities.com>
Does anyone know if there's a Perl command similiar to JavaScript Alert?
ie that makes a box pop up in windows.
Andreas
------------------------------
Date: Sun, 20 Jul 1997 17:35:37 +0300
From: Kazys Jocionis <kj.jl@klaipeda.omnitel.net>
Subject: Perl for win 95 ?
Message-Id: <33D22239.FBA@klaipeda.omnitel.net>
Hi all
I am new to Perl
I was just wondering is it is possible to run Perl on
my local PC with Windows 95/NT OS while testing Perl scripts?
It would be much faster than testing Perl scripts on server side every
time.
Today I have found Perl for win 32 on the Net.
Can I run it on my PC?
Any help will be appreciated.
Please answer by mail.
Best regards
--
-------------------------------------
Kazys Jocionis
email kj.jl@klaipeda.omnitel.net
home http://www.omnitel.net/kazyshome
-------------------------------------
------------------------------
Date: Sun, 20 Jul 1997 21:02:58 GMT
From: etta@fyi.com (etta )
Subject: Re: Perl for win 95 ?
Message-Id: <33d27bbe.151260383@netnews.worldnet.att.net>
Yes you can. I have perl5 for win95 and I test them all the time on
the command line and my server. I would suggest that you get PFE
because once a scripts is run the dos files closes. How ever if you
get PFE it will run the script from with in the program and echo back
the resutls. PFE will also let you open multipule files.
http://www.lancs.ac.uk/people/cpaap/pfe/
Hope this helps,
etta
On Sun, 20 Jul 1997 17:35:37 +0300, Kazys Jocionis
<kj.jl@klaipeda.omnitel.net> wrote:
>Hi all
>
>
>I am new to Perl
>
>I was just wondering is it is possible to run Perl on
>my local PC with Windows 95/NT OS while testing Perl scripts?
>It would be much faster than testing Perl scripts on server side every
>time.
>
>Today I have found Perl for win 32 on the Net.
>
>Can I run it on my PC?
>
>Any help will be appreciated.
>
>Please answer by mail.
>
>Best regards
>
>
>--
>-------------------------------------
>Kazys Jocionis
>email kj.jl@klaipeda.omnitel.net
>home http://www.omnitel.net/kazyshome
>-------------------------------------
------------------------------
Date: Wed, 23 Jul 1997 00:59:29 GMT
From: hcs@pc.jaring.my (Harichandran Sukerathavan)
Subject: Perl Interface to /etc/passwd
Message-Id: <33d4264d.7605224@news.jaring.my>
I'm planning to write an interface that allows people to change their
passwod in their /etc/passwd, where the new password is entered via an
WWW Form. The platform I'm using is FreeBSD 2.1.5.
I have tried looking for the User module, but no luck. Before I
reinvent the wheel, can somebody point me to resources or somewhere
where something similar has been implemented.
Thanks
Harichanadran Sukerathavan
Kuala Lumpur, Malaysia
hcs@pc.jaring.my
------------------------------
Date: Tue, 22 Jul 1997 12:28:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "David R. Adams" <dradams@psts.mbt.washington.edu>
Subject: Re: Perl print buffer.
Message-Id: <Pine.GSO.3.96.970722122123.6115J-100000@kelly.teleport.com>
On Tue, 22 Jul 1997, David Adams wrote:
> open(OUT,">out");
You really should check the result of that operation, even though it
doesn't seem to have a bearing on this situation.
> for($i=1;$i<$#records;$i++) {
That's unusual. You're letting $i count through all the indices of
@records except for the first and last ones. If that's really what you
want, you should note that in a comment, so that your maintenance
programmer will know it's not a bug.
> $ps = join(',',@array);
> print OUT $ps,"\n";
> This code (I know, it's not beautiful) prints out some thing like
>
> ,,edarge
> ,rangium
I suspect that there are carriage returns (or some other control
characters) lurking among the data in @array. Try this statement just
before or after your print statement above, and you can see a hex dump of
what's in @array. (You could direct this to STDERR or to OUT or wherever,
of course.)
print map { "$_: " . unpack("H*", $array[$_]) . "\n" } 0..$#array;
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/
------------------------------
Date: Sun, 20 Jul 1997 21:09:23 GMT
From: etta@fyi.com (etta )
Subject: Re: Perl Scripts and Windows NT
Message-Id: <33d27d8b.151721375@netnews.worldnet.att.net>
I don't know if this is what you mean but try this, add this line in
your code.
$fliename= "/cgi-bin/filename.ext";
Now when you use the $filename it will point to the cgi-bin dir
or what ever dir you specify
It would also help if you would post your code.
Hope this helps,
etta
On Sun, 20 Jul 1997 08:54:11 -0600, Bobbi Arlett
<bja109@mail.usask.ca> wrote:
>Hi, I have written a perl script for windows NT and I cannot specify the
>path for the resulting file to go to, it only works if the file is in
>the CGI-bin directory. Can anyone tell me how to specify the path in a
>perl script?
>
>Please respond via e-mail.
>
>Thanks,
>Bobbi Arlett
>bja109@mail.usask.ca
------------------------------
Date: 21 Jul 1997 22:56:15 GMT
From: shamim@nospam.com
Subject: Re: perl vs python vs icon
Message-Id: <5r0pef$l6c@hermes.synopsys.com>
In article <5qv1l9$eit$1@newshost.nmt.edu>, John Shipman <john@nmt.edu> wrote:
>See this URL for brief comparisons of Python vs. Perl and Icon:
>
> http://www.nmt.edu/tcc/help/lang/python/why.html
I'd like to point out that this point _con_ Icon is no longer valid:
> Python interfaces already exist to a wide variety of systems programming
> facilities (such as directories and TCP/IP sockets), databases, other
> languages, and much more.
I have added POSIX calls to Icon (reading directories, TCP/UDP/IP, signals,
dbm routines, etc.). For more details:
http://www.crl.com/~spm/unicon/
I've tested it on SunOS4.1.3, Solaris 2.4 and 2.5, HP-UX versions 9.05 and
10.20, and Linux 2.x. Source patches and binaries are available.
My opinion is that Icon with the POSIX features is (for the most part) a
better language for scripts, CGI programs etc. than Perl. Perl still handles
regular expressions more conveniently than Icon does; and Perl comes with a
debugger. Other than these two points, Icon is a better system than
Perl. IMHO, of course.
This point:
> Python has a lot more momentum and a much larger and more vigorous user
> community.
Alas, a self-perpetuating property... what we need is an O'Reilly book on
Icon, that seems to be what does the trick!
-s
Shamim Mohamed
shamim @ synopsys.com
Shamim Mohamed <shamim@synopsys.com>
A2-1 Synopsys Inc., 700 E Middlefield Rd., Mountain View, CA 94043-4033
--
Shamim Mohamed <shamim@synopsys.com>
A2-1 Synopsys Inc., 700 E Middlefield Rd., Mountain View, CA 94043-4033
------------------------------
Date: 23 Jul 1997 10:47:56 +0100
From: Marcel Turcotte <M.Turcotte@icrf.icnet.uk>
Subject: Please comment: perl (NNTP) gateway
Message-Id: <y7w4t9mumk3.fsf@fir.lif.icnet.uk>
Hello all,
I wrote the following piece of code, it acts as a software gateway,
providing access to a machine (A), by the mean of an intermediate
machine (B), to a third machine (C) that would not normally have
direct access to machine (A). For example, someone would use it to
read his/here news from a host not served by the NNTP host.
This is the first time I write something like this
(perl/socket/client/server) and I am seeking comments:
- Are there any pieces of code doing that job already?
- Would it be useful to make it clean and robust? Would you use it?
- It's creating zombies, what's wrong?
- It's not always writting to the log file, why?
To do list:
- IP filtering
- Better logs
- ?
Any comments/suggestions will be greatly appreciated.
Cheers!
Marcel
--
Marcel Turcotte Biomolecular Modelling Laboratory
[44|0]-171-269-3023/3479 Phone/Fax Imperial Cancer Research Fund
M.Turcotte@icrf.icnet.uk 44 Lincoln's Inn Fields (Room G17)
http://bonsai.lif.icnet.uk/people/turcotte London WC2A 3PX, England
#! /usr/local/bin/perl
# -*- Mode: Perl -*-
# gw.pl --- perl gateway server
# Author : Marcel Turcotte (M.Turcotte@icrf.icnet.uk)
# Created On : Mon Jul 21 17:38:47 1997
# Last Modified By: Marcel Turcotte
# Last Modified On: Mon Jul 21 18:08:21 1997
# (client) gw.pl (server)
# left <-- port/host <-- GateWay <-- port <-- right
# --> usenet/119 --> Server --> 32853 -->
#
$left_host = 'news';
$left_port = 119;
$right_port = 32853;
open(GWLOG, '>>./gw-log') || die "Can't open gwlog file $!";
select(GWLOG);
print "Gateway started\n";
require 'sys/socket.ph';
# Common
$sockaddr = 'Sna4x8';
($name, $aliases, $proto) = getprotobyname('tcp');
# Interface to the left (client)
$SIG{'INT'} = 'dokill';
sub dokill { kill 9,$child if $child; }
($name, $aliases, $type, $len, $left_addr) = gethostbyname($left_host);
$left = pack($sockaddr, &AF_INET, $left_port, $left_addr);
chop($hostname = `hostname`);
($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname);
$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
# Interface to the right (server)
($name, $aliases, $right_port) = getservbyname($right_port, 'tcp')
unless $right_port =~ /^\d+$/;
$rightaddr = pack($sockaddr, &AF_INET, $right_port, "\0\0\0\0");
select(NRIGHT); $| = 1; select(GWLOG);
socket(RIGHT, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(RIGHT, $rightaddr) || die "bind: $!";
listen(RIGHT, 5) || die "connect: $!";
select(RIGHT); $| = 1; select(GWLOG);
for (;;)
{
# waiting for a request
print "Listening again\n";
($addr = accept(NRIGHT,RIGHT)) || die $!;
print "accept ok\n";
($af,$right_port,$inetaddr) = unpack($sockaddr,$addr);
@inetaddr = unpack('C4',$inetaddr);
print "$af $right_port @inetaddr\n";
# got a request, connecting to left-hand side host
# include code that checks if IP is allowed to connect
socket(LEFT, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(LEFT, $this) || die "bind: $!";
connect(LEFT, $left) || die "connect: $!";
select(LEFT); $| = 1; select(RIGHT);
if ($child = fork) {
# parent
while (<NRIGHT>) {
print LEFT;
}
sleep 3;
do dokill();
}
else {
# child
while (<LEFT>) {
print NRIGHT;
}
}
}
print "Gateway shut down\n";
close(GWLOG);
------------------------------
Date: 22 Jul 1997 21:53:55 GMT
From: dabrams@mathcs.emory.edu (daniel abrams)
Subject: Please Help: Pattern Matching
Message-Id: <5r3a5j$feq$1@cssun.mathcs.emory.edu>
Hello,
I am getting funny results trying to substitue " for <xDQx>
For instance:
$holder =~ s/<xDQx>/BEGIN"END/g;
results in a string where some of the <xDQx> are replaced
with BEGIN"END as you would expect, and some appear
as BEGINEND missing the ".
$holder =~ s/<xDQx>/"/g;
also results in some <xDQx> being replaced with ", while some
are simply removed. The same <xDQx> are replaced as above.
i.e. in each case 1'st and 4th instance of <xDQx> are vanished,
while 2nd and 3d are replaced with ".
However the following:
$holder =~ s/<xDQx>/elephant/g;
works properly for all intances of <xDQx> in the string.
This is really frustrating. Does anyone have an explanation?
$holder is simply a string, I cannot find anything different
between when the " is placed properly and when its ommitted.
Daniel Abrams
------------------------------
Date: Tue, 22 Jul 1997 18:53:11 -0400
From: Devin Anderson <dev@sgi.net>
Subject: Re: Please Help: Pattern Matching
Message-Id: <33D539D7.5E82@sgi.net>
daniel abrams wrote:
>
> Hello,
>
> I am getting funny results trying to substitue " for <xDQx>
> For instance:
>
> $holder =~ s/<xDQx>/BEGIN"END/g;
>
> results in a string where some of the <xDQx> are replaced
> with BEGIN"END as you would expect, and some appear
> as BEGINEND missing the ".
>
> $holder =~ s/<xDQx>/"/g;
Try escaping the " like so:
s/<xDQx>/\"/g;
When in doubt try a \ !
I'm not sure if that will make a difference, but it is worth a try.
---
Devin P. Anderson
Webmaster, Systems Administrator
Stargate Industries, Inc.
http://www.sgi.net/
Phone: 412.930.STAR (7827) ext. 241
F a x: 412.930.7110
This should clear up any confusion:
anti-match - v. To reverse the match process. Show all patterns that
*DON'T* match.
-----PGP PUBLIC KEY AVAILABLE-----
------------------------------
Date: 22 Jul 1997 23:42:06 GMT
From: dabrams@mathcs.emory.edu (daniel abrams)
Subject: Re: Please Help: Pattern Matching
Message-Id: <5r3gge$kc7$1@cssun.mathcs.emory.edu>
Tried it, but no luck. Also tried assigning the "
to a variable and every other way I could think of to
trick the machine. I tried substituting five "
s/<xDQx>/" " " " "/g
Some instances were replaced with five spaces some with " " " " "
Arg.
Daniel
: Try escaping the " like so:
: s/<xDQx>/\"/g;
: When in doubt try a \ !
: I'm not sure if that will make a difference, but it is worth a try.
: ---
: Devin P. Anderson
: Webmaster, Systems Administrator
: Stargate Industries, Inc.
: http://www.sgi.net/
: Phone: 412.930.STAR (7827) ext. 241
: F a x: 412.930.7110
: This should clear up any confusion:
:
: anti-match - v. To reverse the match process. Show all patterns that
: *DON'T* match.
: -----PGP PUBLIC KEY AVAILABLE-----
------------------------------
Date: Mon, 21 Jul 1997 12:56:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Matti Kinnunen <matti@universe.pc.helsinki.fi>
Subject: Re: process handling
Message-Id: <Pine.GSO.3.96.970721124859.7819K-100000@kelly.teleport.com>
On 21 Jul 1997, Matti Kinnunen wrote:
> open(SYS, "ps -ax| grep prog_to_check| grep -v grep |");
You're sure starting a lot of processes there. Perl could do the work of
two of those processes without breaking a sweat, making life nicer for
everyone on your system and making it less likely that your code will fail
due to "can't fork" errors.
> my($tmp) = <SYS>;
> close <SYS>;
I don't think that's doing what you think it's doing.
If you need only to find out whether a process you've spawned is still
alive, you can usually tell by sending it signal 0. That has a big
advantage of not requiring any extra processes, although it does require
you to remember the pid of the process you've spawned, which is often a
trivial thing to do. 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/
------------------------------
Date: Tue, 22 Jul 1997 17:41:35 -0600
From: dcd@k12-dev.arc.nasa.gov
Subject: Question: About strings, replacements and collapsing white space
Message-Id: <869610598.4638@dejanews.com>
I'm relatively new to Perl and have a somewhat complicated question
(hopefully just complicated to explain and not to solve :) )....
I have a string ($data) that contains the contents of a text file, as
well as a search string ($searchString) that I want to replace with
$text in all instances (ie globally). The problem arises that, as my
search string could be rather lengthy, and not spaced the same as when
it appears in $data, a straight $data =~ s/$searchString/$text/g won't
work. For example....
if my search string is..
'this is a search string'
...and I want it to match...
'
this is
a search
string'
....it won't do it unless I collapse the white space. So that's what
I did, with ($copy = $data) =~ s/\s+/ /g; If I collapse both $data
and $searchString this way, they match up just fine and I can make a
straight replacement using a s///; But here's the real problem
(finally). Since I plan to write $data back to a file, I don't want
it's white space to be collapsed. I need some way to un-collapse the
white space after I've made the replacements, or find an entirely new
way to do it.
If you've been patient enough to read through all that I thank you,
and would greatly appreciate any help you could give me.
-Thanks a lot
David
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 21 Jul 1997 13:53:23 +0100
From: "Paul Denman" <pdenman@ims.ltd.uk>
Subject: Re: Quick Substitute Tip Req'd
Message-Id: <05mvq5.agq.ln@gate.imsport.co.uk>
Thankyou for the following 2 tips:
$a =~ tr/a-zA-Z 0-9//cd
(Marek Rouchal)
and
$value =~ s/[^a-zA-Z0-9 ]//g;
(Thomas Honigmann)
Your replies were greatly appreciated!
---
Paul
------------------------------
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 762
*************************************