[7403] in Perl-Users-Digest
Perl-Users Digest, Issue: 1028 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 15 16:35:57 1997
Date: Mon, 15 Sep 97 13:00:34 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 15 Sep 1997 Volume: 8 Number: 1028
Today's topics:
&&/|| vs. and/or <rjo100@york.ac.uk>
Re: &&/|| vs. and/or (Mike Stok)
Re: &&/|| vs. and/or (Jeremy D. Zawodny)
Re: A simple regular epression question. (Terry Michael Fletcher - PCD ~)
Bad start on Win95 <1dja@worldnet.att.net>
Re: Comparing dates?? (Faust Gertz)
Re: Dynmical pattern problem <mthurn@irnet.rest.tasc.com>
How to include my personal Perl libraries <dear_andrew@jpmorgan.com>
Re: How to include my personal Perl libraries (Jeremy D. Zawodny)
Re: How to include my personal Perl libraries (brian d foy)
Re: How to make 'beep' sound in perl? (Faust Gertz)
Re: Is it a module, or what? (Steven W McDougall)
Re: is there a better way to do this subroutine? <rootbeer@teleport.com>
Re: is there a better way to do this subroutine? <rbush@up.net>
Re: Is there a simpler syntax for: defined $a && $a ne <rjo100@york.ac.uk>
Need Pgp signature/checksum for Perl distribution <chris.pineda@predictive.com>
Re: perl and Apache and Header controls (brian d foy)
Perl and WINNT4.0 <chaos@futurenet.co.za>
Re: Permission mode <rootbeer@teleport.com>
Re: Regexp a Yes or No question? (Terry Michael Fletcher - PCD ~)
Sorting a Multi-dimentional Array dg50@chrysler.com
Re: Sorting a Multi-dimentional Array (Mike Stok)
Re: Sorting a Multi-dimentional Array (Mike Stok)
Username/Password script churley@gte.net
Re: what's the case (Tad McClellan)
Re: Why don't my <<HERE documents work? Attempt #2! <rootbeer@teleport.com>
Re: Why don't my <<HERE documents work? -- The Answer! (Faust Gertz)
Re: Why don't my <<HERE documents work? (Terry Michael Fletcher - PCD ~)
Re: why exec finger doesnt work!!!?? <dkp@lippy.ns.cs.boeing.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 15 Sep 1997 15:25:45 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: &&/|| vs. and/or
Message-Id: <341D4569.9834A315@york.ac.uk>
Is there any difference between using the '&&' and '||' operators as
opposed to 'and' & 'or'?
Is it just a matter of style (I think 'and'/'or' are nicer to read), or do
they behave differently under certain circumstances?
I realise you can't do something like '$a or= 1;' rather than
'$a ||= 1;' (I do think that's cool, Randal!), are there other
differences?
TIA,
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ mailto:rjo100@york.ac.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: 15 Sep 1997 18:13:31 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: &&/|| vs. and/or
Message-Id: <5vjtsb$f1u@news-central.tiac.net>
In article <341D4569.9834A315@york.ac.uk>,
Russell Odom <rjo100@york.ac.uk> wrote:
>Is there any difference between using the '&&' and '||' operators as
>opposed to 'and' & 'or'?
>
>Is it just a matter of style (I think 'and'/'or' are nicer to read), or do
>they behave differently under certain circumstances?
>
>I realise you can't do something like '$a or= 1;' rather than
>'$a ||= 1;' (I do think that's cool, Randal!), are there other
>differences?
print "0" or warn "print failed\n";
print "0" || warn "print failed\n";
behave differently due to the precedence of or being a lot lower than that
of ||. The first will only call warn if print fails, the seconf will see
|| as something to be evaluated before calling pront, so the warn is
evaluated, generates its message and returns 1, which is then printed by
the print.
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 15 Sep 1997 18:19:38 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: &&/|| vs. and/or
Message-Id: <341d7c21.367815600@igate.hst.moc.com>
[cc'd automagically to original author]
On Mon, 15 Sep 1997 15:25:45 +0100, Russell Odom <rjo100@york.ac.uk>
wrote:
>Is there any difference between using the '&&' and '||' operators as
>opposed to 'and' & 'or'?
>
>Is it just a matter of style (I think 'and'/'or' are nicer to read), or do
>they behave differently under certain circumstances?
>
>I realise you can't do something like '$a or= 1;' rather than
>'$a ||= 1;' (I do think that's cool, Randal!), are there other
>differences?
They have different precedence.
See the perlop manpage.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: 15 Sep 1997 17:49:39 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: A simple regular epression question.
Message-Id: <5vjsfj$8ce$1@news.fm.intel.com>
Mike Giroux (mgiroux@icon.com) so eloquently and verbosely pontificated:
>
> Zohar Tsaba wrote:
> >
> > When I tried to use:
> >
> > $x = "01010100001100" ;
> > $x =~ s/[^00]/X/g ; # I want to replace 'not 00' with X
> > #
> >
> > printf "$x\n" ; # $x is '0X0X0X0000XX00'
> > # which means, I replaced 'not 0 or not 0'
cool! simulating a state machines response to input using Perl. too bad
i didnt know Perl back in digital design :(
> $x~=s/[^0][^0]/X/g;
> or
> $x~=s/[^0]{2}/X/g;
>
> I hope this helps, and that it wasn't too verbose...
i think that did help, but not your above syntax :) you switched the ~
and the = in your operator :)
zohar, to get the exact output that you stated above for your state
machine you want to replace with a "0X" (i assume to preserve the bit
field's width). the X represents that the next bit starts the observation
for the "00" pattern again, i assume.
$x =~ s/[^0]|(0)[^0]/$1X/g;
on a side note, did you notice that to get your particular output, all you
had to do was translate the 1's into X's? i just thought i would point
that out (tr/1/X/;). my solution properly simulates a state machine,
however.
--
#!/usr/local/bin/perl -- tfletche@pcocd2.intel.com
map{$;.=chr$_}(112,114,105,110,116,32,117,110,112,97,99,107,32,34,117,
34);$_=$;.=q>,':2G5S="!A;F]T:&5R(%!E<FP@:&%C:V5R+`H`'>;y[\034]{}d;eval
------------------------------
Date: Mon, 15 Sep 1997 14:53:13 -0400
From: DJA <1dja@worldnet.att.net>
Subject: Bad start on Win95
Message-Id: <5vk0bj$qsp@bgtnsc03.worldnet.att.net>
I am trying to teach myself Perl using Win95 and I am off to a slow
start. I've loaded the latest self-extracting version from ActiveWare
and when I try to call a program from a "DOS" window I get a error
stating "This program cannot be run in DOS mode." When I try to run
the program from a "PERL" window the program seems to run and the
window instantly closes. Where am I going wrong? The FAQ's don't answer
this one. (Or I can't see the answer)
Any help will be appreciated.
David
------------------------------
Date: Mon, 15 Sep 1997 18:58:37 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Comparing dates??
Message-Id: <341e820a.296979@news.wwa.com>
Ray Bush wrote:
>asked for that 'cause i'm probly more in the gradeschool
>perl anyway. Does the Date module come stock with perl ...
>hmm ... not mine.
On Sun, 14 Sep 1997 23:14:40 -0500, Andrew Johnson
<ajohnson@gpu.srv.ualberta.ca> responded:
>negligent on my part, I apologize. ...the Date::Manip module
>is available on CPAN under:
>/CPAN/modules/by-category/06_Data_Type_Utilities/Date/
>as with most (maybe even all?) modules on CPAN, it is relatively
>painless to retrieve and install and it comes with very
>complete built in documentation in POD format.
No need for you to apologize. This information is available in both
the FAQ and in my message earlier in the thread.
On Fri, 12 Sep 1997 19:29:06 GMT, faust@wwa.com (Faust Gertz) wrote:
>The collective wisdom which authored the FAQ suggests that you use
>either the Date::Manip or the Date::DateCalc module. These modules
>can be found at
>ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-category/06_Data_Type_Utilities/Date/
>or go to http://perl.com/CPAN to choose the CPAN nearest you.
You went far beyound the call of duty by providing an example of the
code to do the job.
>#!/usr/bin/perl -w
>use Date::Manip;
>$bday="12311979"; # birthday in mmddyyyy format
>$bday=~s/^(\d\d)(\d\d)(\d\d\d\d)$/$1-$2-$3/;
>$bdate=&ParseDate($bday);
>$today=&ParseDate("today");
>&DateCalc($bdate,$today,undef,1)=~/([+-]\d+)/;
>print "$1:over 18\n" if $1>=18;
>print "$1:under 18\n" if $1<18;
>__END__
You did more than your fair share. You can't be expected to require
all the background information to get this to work, or else you would
have to write about how to set up the computer you need to run this
program and then how to get the money to buy the computer that you
will need to run this program. :-)
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
"I can well understand why children love sand."
-- Ludwig Wittgenstein
------------------------------
Date: 15 Sep 1997 12:49:02 -0400
From: Kingpin <mthurn@irnet.rest.tasc.com>
Subject: Re: Dynmical pattern problem
Message-Id: <eu202q7cap.fsf@irnet.rest.tasc.com>
"Andreas SLATEFF" <slateff@netway.at.Please.remove.this.I.really.hate.spam> writes:
> > Here what I tried (I think, you can imagine my intention):
Actually, it's pretty hard to imagine...
> > $e=$2;
> > s/ ..any pattern.. /$e/;
How about using the /e modifier? Then you can call a function which
returns a value to be used as the replacement:
s/pattern/&dynamic($e)/e;
sub dynamic
{
my ($e) = @_;
return $2 ? $2 : $e; # or whatever you want!
}
--
- - Martin "Kingpin" Thurn mthurn@tasc.com
Research Software Engineer (703) 834-5000 x2926
The Information Refinery http://tir.tasc.com
TASC, Inc. http://www.tasc.com
Try not! Do... or do not. There is no try. -- Yoda, The Empire Strikes Back
------------------------------
Date: Mon, 15 Sep 1997 17:42:35 -0700
From: Andrew Dear <dear_andrew@jpmorgan.com>
Subject: How to include my personal Perl libraries
Message-Id: <341DD5FB.5BCF@jpmorgan.com>
I would like to have my perl libraries in a sub directory sitting under
the perl script that will be run from the command line.
eg. /something/bin/my_perl_script
which uses the library
/something/bin/my_perl_libraries/my_lib_1.pl
my_perl_script then contains the generic line:
use lib './my_perl_libraries';
require 'my_lib_1.pl';
This works if I run the command 'my_perl_script' and my current
directory is /something/bin. However it doesn't otherwise.
Is there any way of finding the location of the file I am executing from
within perl. Ideally I want the output from the UNIX command 'which'
where I would be able to get /something/bin and then 'use' a full
pathname instead of a relative pathname.
This would allow my code to be portable across different environments
without having to change any hard coded library directories within the
code itself.
Any ideas? Any better ways to avoid hard coding a library directory
path?
I have avoided using environment variables because you can't see them in
CGI scripts.
Thanks for any help.
Andrew
------------------------------
Date: Mon, 15 Sep 1997 18:24:17 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: How to include my personal Perl libraries
Message-Id: <341e7cb9.367966798@igate.hst.moc.com>
[cc'd automagically to original author]
On Mon, 15 Sep 1997 17:42:35 -0700, Andrew Dear
<dear_andrew@jpmorgan.com> wrote:
>I would like to have my perl libraries in a sub directory sitting under
>the perl script that will be run from the command line.
>
>eg. /something/bin/my_perl_script
>
> which uses the library
>
> /something/bin/my_perl_libraries/my_lib_1.pl
>
>
>my_perl_script then contains the generic line:
>
>use lib './my_perl_libraries';
>require 'my_lib_1.pl';
Since you're using require, why not just:
require "my_perl_libraries/my_lib_1.pl"
? Or does that have implication which don't work in your environment?
Or maybe you can push an additional directory onto @INC in your main
script, and just let it find all the libraries...
>This works if I run the command 'my_perl_script' and my current
>directory is /something/bin. However it doesn't otherwise.
>
>Is there any way of finding the location of the file I am executing from
>within perl. Ideally I want the output from the UNIX command 'which'
>where I would be able to get /something/bin and then 'use' a full
>pathname instead of a relative pathname.
'which' is shell-specific.
>This would allow my code to be portable across different environments
>without having to change any hard coded library directories within the
>code itself.
Is it that you don't want absolute paths hard-coded? What about
relative paths? (They *seem* to be okay, based on your example.)
>Any ideas? Any better ways to avoid hard coding a library directory
>path?
>I have avoided using environment variables because you can't see them in
>CGI scripts.
Smart move.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Mon, 15 Sep 1997 14:37:10 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: How to include my personal Perl libraries
Message-Id: <comdog-ya02408000R1509971437100001@news.panix.com>
In article <341DD5FB.5BCF@jpmorgan.com>, dear_andrew@jpmorgan.com wrote:
>my_perl_script then contains the generic line:
>use lib './my_perl_libraries';
>require 'my_lib_1.pl';
>This works if I run the command 'my_perl_script' and my current
>directory is /something/bin. However it doesn't otherwise.
just hard code the path. it's in one place and not going anywhere.
the script may not know where it is in the filesystem during compile
time, so other heuristics to figure out the path might fail as well.
is there a reason you are trying to avoid hard coding the path?
good luck :)
--
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: Mon, 15 Sep 1997 19:36:07 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: How to make 'beep' sound in perl?
Message-Id: <34248bde.2810567@news.wwa.com>
On 13 Sep 1997 00:12:52 GMT, A. Reichert <alan@mattress.atww.org>
wrote:
>On Fri, 12 Sep 1997 22:33:48 GMT, Faust Gertz <faust@wwa.com> wrote:
>: could you do something like:
>
>: for ($i = 0; $i < 3; $i++) {
>: sleep $i;
>: print "\a";
>: }
>:
>: Which I guess would give you three beeps like this.
>
>: Beep, sleep one second, Beep, Sleep two seconds, Beep
>
>: But on second thought, I bet it won't. It will sleep for three
>: seconds and then
>
>: print "\a\a\a";
>
>: because the three "\a"s will be in the print buffer. Try just
>: printing 'a ' instead of "\a" to see what I mean. So you will
>: probably have to empty the print buffer after each time you print "\a"
>: and then sleep to get the sound of three distinct bells.
>I think your first one is correct, one second delay, then two seconds...
>Just replace your "sleep $i:" with "sleep 1;" for a constant delay.
Nope. I was right, we need to clear the print buffer or as Mark
DSouza <dsouza@mcs.anl.gov> pointed out, just set
$| = 1;
before the "for" loop to force the output buffer to be flushed after
every print, so the beeps do not "stack up" into one beep.
So, some theme or variation of
$| = 1;
for (0 .. 2) {
sleep $_;
print "\a";
}
will yield the requested results.
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
------------------------------
Date: Mon, 15 Sep 1997 17:47:19 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: Is it a module, or what?
Message-Id: <EGK9Ew.s@world.std.com>
ken@forum.swarthmore.edu (Ken Williams) writes:
>In article <Pine.GSO.3.96.970905163639.24123X-100000@julie.teleport.com>,
>Tom Phoenix <rootbeer@teleport.com> wrote:
>>
>>I don't know; are you doing what it says in the perlmod(1) manpage? (Be
>>sure that you start with h2xs, since that's really the only way to make
>>modules.)
>What? Is this true? Haven't I made modules before that don't use C code
>and don't use h2xs? In fact, the Camel book says how to make modules but
>doesn't seem to mention h2xs.
You don't need h2xs to create a module,
but you definitely want it.
See
http://world.std.com/~swmcd/steven/perl
for details.
- SWM
------------------------------
Date: Mon, 15 Sep 1997 10:35:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ray Bush <rbush@up.net>
Subject: Re: is there a better way to do this subroutine?
Message-Id: <Pine.GSO.3.96.970915103321.21989I-100000@julie.teleport.com>
On Sun, 14 Sep 1997, Ray Bush wrote:
> Matthew Cravit wrote:
> > >> > local(*p,*plog)=@_;
> > >> ^^^^^^^^
> > >
> > >oh really cant recognize two arrays being passed in ... this is right
> > >out of the perl5 book example
>
> My apologies, but, where does it say this is bad?
I'll say it right here. :-) Don't use a typeglob if you can use a
reference instead. References are better in every way: faster, more
reliable, more efficient, easier to understand, tastes great, less
filling. The main reason you'll see lines like that one in old code is
because, back in the bad old days of Perl 4, we didn't have references (or
my(), for that matter).
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: Mon, 15 Sep 1997 15:45:39 -0400
From: "Raymond K. Bush" <rbush@up.net>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: is there a better way to do this subroutine?
Message-Id: <341D9063.3876@up.net>
Tom Phoenix wrote:
>
> On Sun, 14 Sep 1997, Ray Bush wrote:
>
> > Matthew Cravit wrote:
>
> > > >> > local(*p,*plog)=@_;
> > > >> ^^^^^^^^
> > > >
> > > >oh really cant recognize two arrays being passed in ... this is right
> > > >out of the perl5 book example
> >
> > My apologies, but, where does it say this is bad?
>
> I'll say it right here. :-) Don't use a typeglob if you can use a
> reference instead. References are better in every way: faster, more
> reliable, more efficient, easier to understand, tastes great, less
I dont think references are easier to understand ... I think that's a
subjective thing.
Now as for speed yes its faster. I put a call in a loop and waited.
Then did the same for
a reference version. I did see ssome obscure mention in the FAQ about
speed but nothing else ...
if it's such an issue why isnt it there?
How do you mean unreliable (more reliable?) as you imply this. Is my
type glob going to fail on the 10000th itteration or something? Are you
talking about the memory leak thing?
The changing to a ref hardly made a change in the runtime of my program,
but hey 3 sec is three seconds.
A difference of 3 seconds on a job that runs in 1.5 hours is
negligeable. (well it used to run that long)
Rewriting the entire subroutine so that the job finishes in 2 passes
instead
of 2^2 passes. Now that was the kind of thing i needed. I do feel
better having figured it out myself though
To the person who commented about my ugly code ... no kidding. my
rewrite runs in less than 2 minutes.
This was in the FAQ.
> filling. The main reason you'll see lines like that one in old code is
> because, back in the bad old days of Perl 4, we didn't have references (or
> my(), for that matter).
>
I just stepped outta them old days a few months ago ... I know the old
(probly why i think its easier);
> Hope this helps!
Actually yes it did ...
>
> --
> 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!
Thank you,
--Ray
.70~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~07.
--- reply to rbush - at - up - dot - net ---
--- please include indication of past correspondence ---
--- in order to receive a faster response ---
------------------------------
Date: Mon, 15 Sep 1997 15:45:26 +0100
From: Russell Odom <rjo100@york.ac.uk>
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Is there a simpler syntax for: defined $a && $a ne ''
Message-Id: <341D4A06.D18647E9@york.ac.uk>
Randal Schwartz wrote:
>
> >>>>> "Russell" == Russell Odom <rjo100@york.ac.uk> writes:
>
> Russell> The Llama book, 1st Ed, p12 (footnote), says undef 'looks
> Russell> like an empty string to the eq operator'. Therefore you could
> Russell> use...
>
> Russell> $a = 1 if $a eq '';
>
> Or, to be Way Cooler (as we say on the left coast):
>
> $a ||= 1;
Ah, but it doesn't work if $a='0'; Part of the question was:
>> Also, I can't just
>> test for true or false, because '0' is false, but would be acceptable
>> under my criterion..
Yes, it is Very Cool, though, I didn't realise you could do that :-)
Later,
Russ
---------------------------------------------------------------------
--[ R u s s e l l O d o m ]---[ mailto:rjo100@york.ac.uk ]--
--[ University of York, UK ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[ FAQ maintainer, news:comp.os.ms-windows.win95.moderated ]--
---------------------------------------------------------------------
------------------------------
Date: Mon, 15 Sep 1997 11:58:15 -0700
From: "Chris M. Pineda" <chris.pineda@predictive.com>
Subject: Need Pgp signature/checksum for Perl distribution
Message-Id: <341D8547.B7ED4B6E@predictive.com>
Is there a PGP signature/file checksum available for the current
releases of Perl? I've looked on the www.perl.com site, but can only
find checksums for individual modules. I need to use Perl but I also
want to make sure that I am downloading and using something that is
"safe". I've seen some threads on this news group dated from 1995 that
talk about this issue, but have yet to find something publicly
available.
Any help much appreciated,
Chris
--
-----------------------------------------------------
Chris M. Pineda -chris.pineda@predictive.com
Security Associate
Predictive Systems, Inc
p. 408-460-3100
f. 408-460-3199
------------------------------
Date: Mon, 15 Sep 1997 13:03:50 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl and Apache and Header controls
Message-Id: <comdog-ya02408000R1509971303500001@news.panix.com>
[follow ups set]
In article <341D63FA.C1564@apple.com>, lev@apple.com wrote:
>Anyone out there know what has to be done to an Apache server (1.2.4) to
>allow one perl script of Many to transmit the headers?
>
>I want to do an auto redirect without using the meta tag.
depending on what you want to do (which isn't clear), Apache may
have built in functionality. check the Apache docs for redirection
(Redirect, Rewrite, etc) or ask in comp.infosystems.www.servers.unix.
good luck :)
--
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: Mon, 15 Sep 1997 21:24:40 +0200
From: Scott Balneaves <chaos@futurenet.co.za>
Subject: Perl and WINNT4.0
Message-Id: <341D8B77.2A0E5071@futurenet.co.za>
I have been told that Perl programming can cause problems on NT 4.0, any
truth behind this and second of all where is the best place to start
programming.
Basically I need to learn how to put a database online using a perl
script to access it.
thanks
cheers
Scott
chaos@futurenet.co.za
------------------------------
Date: Mon, 15 Sep 1997 10:52:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: Permission mode
Message-Id: <Pine.GSO.3.96.970915104325.21989L-100000@julie.teleport.com>
On 15 Sep 1997, Morten Simonsen wrote:
> status() is returning a value for the file mode (type and permissions).
I think you mean stat().
> I want to map that mode to the numbers used in chmod to set permission
> and to the letters used in ls-command to indicate directories and soft
> links.
It's a bit-vector, so you can do things like this. (But don't try using
$octal_mode as a number without wrapping it in the oct() function.)
$octal_mode = sprintf('%04o', $mode & 0777);
print "That object has mode $octal_mode\n";
You may also want to search your system's docs to see what bits are set
for which attributes (such as links and directories) and then use code
something like this.
print "Symlink" if ($mode & 0170000) == 0120000;
Or, you might get away with Perl's builtin tests, such as -l . 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: 15 Sep 1997 17:21:27 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: Regexp a Yes or No question?
Message-Id: <5vjqqn$7t3$1@news.fm.intel.com>
Gabor Egressy (gabor@vinyl.quickweb.com) so eloquently and verbosely pontificated:
> Matthew Cravit (mcravit@best.com) wrote:
>
> what if the user types 'yellow'
> should that be accepted?
well, only if the question was a phone call, since 'yellow' is a standard
way of answering :)
but seriously, my two scents:
if /^(y(a|e(s|ah))?|o(k(ay)?)?|t(rue)?|s(ure)?|a(bsolutely|ffirmative)?)$/i
that should cover enough cases. :)
--
#!/usr/local/bin/perl -- tfletche@pcocd2.intel.com
map{$;.=chr$_}(112,114,105,110,116,32,117,110,112,97,99,107,32,34,117,
34);$_=$;.=q>,':2G5S="!A;F]T:&5R(%!E<FP@:&%C:V5R+`H`'>;y[\034]{}d;eval
------------------------------
Date: Mon, 15 Sep 1997 13:01:40 -0600
From: dg50@chrysler.com
Subject: Sorting a Multi-dimentional Array
Message-Id: <874345957.19620@dejanews.com>
This is probably a dumb-ass simple question, but then "given enough eyes,
all problems are simple"
I have a multi-dimentional array @foo (well, 2 dimentional - and yes, I
know that in perl that's really an array of references to arrays) of
length k and width i.
I need a function &foo_sort that returns a sorted @foo, sorted on column
n, such that
$col = n;
@sorted_foo = &foo_sort(@foo,$col);
or something similar
would take
"1", "duck", "quack"
"7", "pig", "blue"
"2", "red", "house"
and return
"7", "pig", "blue"
"2", "red", "house"
"1", "duck", "quack"
if $col = 2.
I have a way to brute-force this, but I'm sure that there's an elegant
solution to this problem, and my brain is too fried at this point in the
day to tackle it.
Any takers?
DG
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 15 Sep 1997 18:24:33 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Sorting a Multi-dimentional Array
Message-Id: <5vjuh1$fkp@news-central.tiac.net>
In article <874345957.19620@dejanews.com>, <dg50@chrysler.com> wrote:
>This is probably a dumb-ass simple question, but then "given enough eyes,
>all problems are simple"
>I need a function &foo_sort that returns a sorted @foo, sorted on column
>n, such that
>$col = n;
>@sorted_foo = &foo_sort(@foo,$col);
>
>or something similar
>
>would take
>
>"1", "duck", "quack"
>"7", "pig", "blue"
>"2", "red", "house"
>
>and return
>
>"7", "pig", "blue"
>"2", "red", "house"
>"1", "duck", "quack"
>
>if $col = 2.
You might say
@sortedFoo = sort {$b->[$col] cmp $a->[$col]} @foo;
e.g.
DB<1> push @foo, ["1", "duck", "quack"], ["7", "pig", "blue"]
DB<2> push @foo, ["2", "red", "house"]
DB<3> @sortedFoo = sort {$b->[$col] cmp $a->[$col]} @foo
DB<4> X sortedFoo
@sortedFoo = (
0 ARRAY(0x810f098)
0 7
1 'pig'
2 'blue'
1 ARRAY(0x810e86c)
0 2
1 'red'
2 'house'
2 ARRAY(0x8050878)
0 1
1 'duck'
2 'quack'
)
Alternatively you can have a look at
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4/How_do_I_sort_an_aray_by_anyth.html
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 15 Sep 1997 18:33:19 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Sorting a Multi-dimentional Array
Message-Id: <5vjv1f$fue@news-central.tiac.net>
In article <5vjuh1$fkp@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:
> DB<1> push @foo, ["1", "duck", "quack"], ["7", "pig", "blue"]
>
> DB<2> push @foo, ["2", "red", "house"]
>
> DB<3> @sortedFoo = sort {$b->[$col] cmp $a->[$col]} @foo
>
> DB<4> X sortedFoo
>@sortedFoo = (
> 0 ARRAY(0x810f098)
> 0 7
> 1 'pig'
> 2 'blue'
> 1 ARRAY(0x810e86c)
> 0 2
> 1 'red'
> 2 'house'
> 2 ARRAY(0x8050878)
> 0 1
> 1 'duck'
> 2 'quack'
>)
This worked 'cos I was sorting on colum 0 as strings in descenfing order,
as an undefined $col is worth 0 as an index, and produced right looking
results ... of course setting $col to something (like 2) and sorting the
right way round might help e.g.
DB<5> $col = 2
DB<6> @sortedFoo = sort {$a->[$col] cmp $b->[$col]} @foo
DB<7> X sortedFoo
@sortedFoo = (
0 ARRAY(0x810f098)
0 7
1 'pig'
2 'blue'
1 ARRAY(0x810e86c)
0 2
1 'red'
2 'house'
2 ARRAY(0x8050878)
0 1
1 'duck'
2 'quack'
)
Sorry.
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@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 15 Sep 1997 19:21:37 GMT
From: churley@gte.net
Subject: Username/Password script
Message-Id: <5vk1s1$rg9$1@gte1.gte.net>
I am trying to create a Perl script, that used on with an HTML form,
will allow users to enter a username and password to enter the site.
This info will then be saved to a second file and the user will
proceed to the entry page where this info can be entered so that entry
to the site is allowed. I want the user to create his own username
and password and to be stored and security is not an issue as this is
not a secure site and no credit card or personal info will be entered
other than e-mail address. Also, my server is an NT 4.0 server. This
is the first real script that I have tried to create and was curious
as to where I should start. I appreciate any help and please respond
to me via e-mail at:
churley@gte.net
Thank you,
Chris Hurely
churley@gte.net
------------------------------
Date: Mon, 15 Sep 1997 12:26:47 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: what's the case
Message-Id: <n4rjv5.a82.ln@localhost>
Tom Oelke (toelke@mipos2.sc.intel.com) wrote:
: Edwin Bishop wrote:
: >
: > I have the following line which matches
: > User id input against a text file.
: >
: > It is working fine, except, I want it
: > to ignore case (upper/lower)....
: >
: As others said, you probably want
: if ($database_row =~ /$username/i)
: You might want to add some sort of delimiter into that pattern match
: however,
: so that when you are looking for "john", you don't get everything for
: "john"
: plus everything for "johnson"
: If all that is on $database_row is the username, you'd want
: if ($database_row =~ /^$username$/i)
: If it were ':' delimited fields you'd want
: if ($database_row =~ /\:$username\:/i)
^ ^
^ ^ Don't need the backwacks
: Since this is dependent upon the data / context of your code, you'll
: have to determine whats most appropriate
That won't work if it is the first or last field ;-)
e.g.
john:wayne:duke
I might go with a zero-width match though:
if ($database_row =~ /\b$username\b/i)
or, if you assume colon separated:
if ($database_row =~ /(^|:)$username($|:)/i)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 15 Sep 1997 10:31:40 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Anagrams of the Word 'A' <jefpin@bergen.org>
Subject: Re: Why don't my <<HERE documents work? Attempt #2!
Message-Id: <Pine.GSO.3.96.970915103108.21989H-100000@julie.teleport.com>
On Sun, 14 Sep 1997, Anagrams of the Word 'A' wrote:
> correct syntax i:
>
> #!/user/local/bin/perl -w
> use strict; # 'cause it's in the FAQ :-)
> print <<EOF
> This is a test!
> EOF
> exit;
>
> notice there is NO semicolon after the <<EOF
Please stop giving out such bad advice. Thanks.
--
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: Mon, 15 Sep 1997 19:19:59 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Why don't my <<HERE documents work? -- The Answer!
Message-Id: <341f85b0.1229441@news.wwa.com>
On Sat, 13 Sep 1997 10:38:58 GMT, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:
Faust> If I resolve this problem, I will post the solution in case
Faust> others are having these kinds of problems.
>Please do: AFAICS you've had all the suggestions that could be based
>on what's in your source code, so if you've eliminated those then it
>seems to point to a bug in the version you're using.
Ok, I will. :-)
In the target post, I asked:
> Why don't my <<HERE documents work? Here is a sample of my code.
>
> #!/user/local/bin/perl -w
> use strict; # 'cause it's in the FAQ :-)
> print <<EOF;
> This is a test!
> EOF
> exit;
>
> The result is:
>
> >Can't find string terminator "EOF" anywhere before EOF at da.pl line 3.
>
> Please note that:
>
> 1. There is no space after the << part.
> 2. There is a semicolon at the end.
> 3. There is no space in front of the tag.
Well, Mike Heins <mheins@prairienet.org> was right. It was not my
syntax. The problem had to do with uploading the script from a DOS
machine.
On 12 Sep 1997 08:34:09 GMT, mheins@prairienet.org (Mike Heins) wrote:
>My guess is that you uploaded the script from a DOS machine in
>binary mode, and that there is a ^M after the EOF. If this works
>you can verify it:
>
>print <<"EOF\r";
>testing
>EOF
I uploaded the script from a DOS machine with WS-FTP, but in ASCII
mode. I did try
print <<"EOF\r";
and even
print <<"EOF\cM";
with no luck.
Then I tried uploading the script with Cute-FTP in ASCII mode and it
seems to have fixed the problem. Apparently there must be something
different about the ASCII upload modes of the versions of WS-FTP and
Cute-FTP I used. This also fixed the problems I was having with:
#!/user/local/bin/perl -w
and
#!/user/local/bin/perl -T
sometimes returning
>.nrecognized switch: -
Thanks for everyone's help and I am sorry it turned out to be a FTP
problem and not a perl problem.
Faust Gertz
Philosopher at Large
When Russell was still doubtful as to Wittgenstein's ability, he
asked G.E. Moore for his opinion. Moore replied, "I think very well
of him indeed." When Russell enquired the reason for his opinion,
Moore said that it was because Wittgenstein was the only man who
looked puzzled during his lectures.
------------------------------
Date: 15 Sep 1997 18:52:49 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: Why don't my <<HERE documents work?
Message-Id: <5vk061$913$1@news.fm.intel.com>
Faust Gertz (faust@wwa.com) so eloquently and verbosely pontificated:
> Faust Gertz (faust@wwa.com) wrote:
>
> > Why don't my <<HERE documents work? Here is a sample of my code.
>
> >is there anything after the (supposedly) terminating EOF? it must be
> >on a line by itself.
>
> #!/user/local/bin/perl -w
>
> and
>
> #!/user/local/bin/perl -T
>
> sometimes returns
>
> >.nrecognized switch: -
AHAA! the culprit is in the editor you are using. i have seen this error
message before, and it is when you have a space following the "-" in the
option list, i.e.
'#!/user/local/bin/perl -w '
^
your editor (or something else) is placing a space here!!!
your "HERE documents" are not working for the same reason:
'EOF ' is not being seen as 'EOF'.
try a different editor, or whatever may solve that problem!
--
#!/usr/local/bin/perl -- tfletche@pcocd2.intel.com
map{$;.=chr$_}(112,114,105,110,116,32,117,110,112,97,99,107,32,34,117,
34);$_=$;.=q>,':2G5S="!A;F]T:&5R(%!E<FP@:&%C:V5R+`H`'>;y[\034]{}d;eval
------------------------------
Date: Mon, 15 Sep 1997 15:39:03 GMT
From: Dennis Peterson <dkp@lippy.ns.cs.boeing.com>
Subject: Re: why exec finger doesnt work!!!??
Message-Id: <341D5697.770F@lippy.ns.cs.boeing.com>
Nadeem Rana wrote:
>
> I have some user Ids in a file temp. I am writing a simple perl script but
> it doesnt work.
> Heres the script
>
> #!/usr/bin/perl
> while($_ = <ARGV>){
> chop($_);
> exec 'finger', $_;
> }
> but it runs finger ONLY on the first user id in temp. Could you please
> help me why is it doing so?
> My temp sile is something like this...
>
> userid1
> userid2
> ..
> .
>
> Thanks
> Nadim
The exec function executes the called external and then terminates the
current process. Try using system() instead of exec().
dp
------------------------------
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 1028
**************************************