[6858] in Perl-Users-Digest
Perl-Users Digest, Issue: 483 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 15 16:07:16 1997
Date: Thu, 15 May 97 13:00:22 -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, 15 May 1997 Volume: 8 Number: 483
Today's topics:
+++ Perl programmer / Refferal CGI Script NEEDED <izzy@ehawes.com>
Baffled (RMO)
Re: Bug report: Perl dumps core on funny split (Dominic Dunlop)
Re: Cant get Perl up and running <burleigh@hackberry.chem.niu.edu>
gzip/zmore in perl? <quemast@bvsd.k12.co.us>
Re: gzip/zmore in perl? (Mike Stok)
Re: Handy with perl? Here's a one-liner challenge. (Metameme 7)
Re: How to stop FOMAT putting space between fields? (Lack Mr G M)
Re: Ingres data on the Intranet (Andy Law)
Re: ls vs. readdir (Frank Miles)
Re: ls vs. readdir <cdh@CompleteIS.com>
Re: ls vs. readdir (Mike Stok)
More trouble with Syslog (Bernard Cosell)
Re: Private area using Perl/CGI <stevek@unidial.com>
Re: REQ: Perl obfuscator <sjn@pvv.ntnu.no>
Re: setuid & setgid scripts executed via cgi/internet (Bob)
setuid, trying to rm a file (Unix) (Rick Greene)
swallowing whitespace <venkat@bbb.caltech.edu>
What's the quickest way in perl to determine if a scala (Mark Daku)
Re: What's the quickest way in perl to determine if a s (Mike Stok)
Year 2000 Issues with Perl5 (Tony Zaki)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 15 May 1997 14:27:59 -0400
From: IZZY <izzy@ehawes.com>
Subject: +++ Perl programmer / Refferal CGI Script NEEDED
Message-Id: <337B55AF.32E6@ehawes.com>
+++ Perl programmer / Refferal CGI Script NEEDED
================================================
Hi, we are looking for a perl programmer to do some work
in the area of banner ad promotions, specifically to set-up
a system where adult webmasters can sign-up with us to display
our banners on their sites for pay reflecting click throughs.
If any of you know where we might be able to purchase software
that can do this, it would also be helpful.
Thanx (-:
IZZY
------------------------------
Date: Thu, 15 May 1997 19:37:43 GMT
From: isainfoserv@mindspring.com (RMO)
Subject: Baffled
Message-Id: <5lfoqt$jl0@camel3.mindspring.com>
I'm stuck. Below is the core of a script that accepts info ($keys)
typed into a html form. The below sub routine searches a quote, tab
delimted text database (pilotrmo.tab) for the persons/items in the
database that matches all items (items defined as separated by spaces)
in $keys. I.E. I type 'John Doe' in my form and the script returns
all listings that contain 'John' and 'Doe'. My quandry is that if
you enter 'Doe John' (out of order as compared to the database), it
doesn't find the listing. What am I doing wrong?
Thanks in advance,
Please send any responses to roverton@isa.org
Robert Overton
sub SEARCH_FOR_MATCH {
@search_key = split(/\x20/,$keys);
$k =0;
open(MYFILE,"pilotrmo.tab");
while(<MYFILE>) {
$l=0;
$_ =~ s/\"//g;
$wholeline=$_;
($last, $first, $work, $home, $fax, $email) = split(/\t/,$_);
$found = "yes";
foreach (@search_key) {
if ($wholeline =~ m/$search_key[$l]/gi) {
} else {
$found = "no";
}
$l++;
}
if ( $found eq "yes") {
if ($k > 999) {
next;
}
$k = $k + 1;
print "<TR>";
print "<TD ALIGN=\x22center\x22>", $first, "</TD>\n";
print "<TD ALIGN=\x22center\x22>", $last, "</TD>\n";
print "<TD ALIGN=\x22center\x22>", $home, "</TD>\n";
print "<TD ALIGN=\x22center\x22>", $work, "</TD>\n";
print "<TD ALIGN=\x22center\x22>", $fax, "</TD>\n";
print "<TD ALIGN=\x22center\x22>", "<A HREF=\x22MAILTO:",$email,
"\x22>", $email, "</A></TD>\n";
print "<TR>\n";
}
}
}
------------------------------
Date: Thu, 15 May 1997 11:03:23 +0200
From: domo@slipper.ip.lu (Dominic Dunlop)
Subject: Re: Bug report: Perl dumps core on funny split
Message-Id: <v03102803afa081093470@[194.51.248.65]>
At 10:36 +0200 1997-05-15, era eriksson wrote:
>For the record, some machines I tested this on only display the
>"Segmentation fault" when tried interactively (i.e. if you start up
>only the Perl part of the pipeline and type in some input manually)
I still can't reproduce it by tying at perl5.003 or 5.004 gamma. Maybe I'm
just lucky -- my 'platform' is somewhat off-the-wall. (4.4BSD UBIX atop
Mach, hosted by MacOS.) I look forward to seeing your report on the
perlbug list: the people who read it are generally very hot about making
perl not dump core.
---
Dominic Dunlop
------------------------------
Date: Thu, 15 May 1997 13:47:51 -0500
From: Darin Burleigh <burleigh@hackberry.chem.niu.edu>
Subject: Re: Cant get Perl up and running
Message-Id: <337B5A57.2DF2@hackberry.chem.niu.edu>
ddean@aracnet.net wrote:
>
> HI
>
> I've just installed perl on a Unix box. For some reason it installed it
> in /opt/perl5 instead of /usr/local/bin/perl5. Anyway, the installation
> went fine but when I try to run a script is tells me that it cannot
> execute the file.
>
> Can anyone tell me what is the matter with this tiny script
>
> #!/opt/perl5
>
> print"hello";
> exit(0);
>
> I'm new to this stuff so be gentle
how do you know its wrong?
did you get an error message?
if so, WHAT IS THE ERROR MESSAGE?!
(excuse me for shouting)
why didn't you use the -w flag?
you should really use the -w flag.
guess 1: the script is not executable
guess 2: perl is installed wrong.
other stuff:
is is 'perl' or 'perl5'?
shouldn't there be a space after 'print'?
not that its any of my business, but wouldn't you be
happier with with \n after hello?
you don't need the exit in this example.
--
==========================================================
- darin
burleigh@hackberry.chem.niu.edu
\\//\\//.\\//\\//.\\//\\//. http://hackberry.chem.niu.edu/HOME/dcb/
'2 kinds of green, look out!' - dieter rot
------------------------------
Date: Thu, 15 May 1997 13:04:07 -0600
From: GuideQueue Master <quemast@bvsd.k12.co.us>
Subject: gzip/zmore in perl?
Message-Id: <Pine.GSO.3.95.970515130138.22315A-100000@bvsd.k12.co.us>
I have a few logs that are in gzip format to keep the size down. In korn
scripts, I've always used "zgrep" to find what I need, and "echo "stuff" |
gzip >> file.log" to add stuff.
Is there any way to read and write to a gzip file in PERL w/o
using an external command? (I'd really hate to fork a shell for this, I
just re-wrote my log manager in PERL to avoid the extra processes).
````'
O O
. . . . . . . . oOOo . . U . . oOOo . . . . . . . . . . . . . . . . .
. .
. Dean J. Brissinger .
. - BVSD GuideQueue/GuideWeb Master (volunteer) .
. .
. "Here's five bucks. Go see the movie, and if you don't like it, .
. I'll take the money back." -- Taxi .
. .
. . . . . . . . . ooo . . . . ooo . . . . . . . . . . . . . . . . . .
------------------------------
Date: 15 May 1997 19:38:42 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: gzip/zmore in perl?
Message-Id: <5lfoo2$rcg@news-central.tiac.net>
In article <Pine.GSO.3.95.970515130138.22315A-100000@bvsd.k12.co.us>,
GuideQueue Master <quemast@bvsd.k12.co.us> wrote:
>I have a few logs that are in gzip format to keep the size down. In korn
>scripts, I've always used "zgrep" to find what I need, and "echo "stuff" |
>gzip >> file.log" to add stuff.
>
> Is there any way to read and write to a gzip file in PERL w/o
>using an external command? (I'd really hate to fork a shell for this, I
>just re-wrote my log manager in PERL to avoid the extra processes).
If you're using perl 5.xxx and have access to the net then there's
Compress-Zlib-0.50.tar.gz on the comprehensive perl archive network (CPAN)
under
.../CPAN/modules/by-category/17_Archiving_and_Compression/Compress/
you can get to CPAN by ftp to the master site at ftp.funet.fi in
/pub/languages/perl/CPAN or through Tom Christiansen's multiplexor at
http://www.perl.com/CPAN/
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 May 1997 15:47:01 GMT
From: vaccime@ripco.com (Metameme 7)
Subject: Re: Handy with perl? Here's a one-liner challenge.
Message-Id: <5lfb5l$cm1$1@gail.ripco.com>
In article <3378EF24.7B75@graphics.cornell.edu>,
Gordon Kindlmann <gordon@graphics.cornell.edu> wrote:
>hi,
Hi!
>As part of using gnu make, we're generating small dependency files
>that need to be post-processed. We chose perl to do this
>post-processing. We have (below) a four line perl program that does
>the job. Knowing that such programs are often writable as a single
>line of code, we tried our hand at compactifying it further but got
>nowhere. We would appreciate any help in this matter. Our faith
>in the perl community hangs in the balance ;-)
>
[...]
>What it does: given a dependency rule written over a number of lines,
>removes all the filenames after the colon except those which either
>don't start with a slash, or those which do start with the command
>line argument to the program.
>
>For instance, given some file called test.d:
>------------
>CHist.o: CHist.c pcgvCHist.h \
> /usr/local/gnu/lib/gcc-lib/hppa1.1-hp-hpux9.05/2.7.2.1/include/stdio.h
> /usr/include/time.h /usr/include/sys/time.h \
> /afs/bingo/projects/viz/proj/pcgv/include/pcgvCCom.h \
[snipped]
> /usr/include/sys/ipc.h /afs/bingo/projects/viz/cvi/include/pcgvCVio.h \
> /afs/bingo/projects/viz/proj/pcgv/include/pcgvCImage.h \
> /usr/include/ctype.h
>------------
>the program invoked as
>
> mfilt.pl /afs/bingo/projects/ < test.d
>
>produces:
>------------
>CHist.o: \
>CHist.c \
>pcgvCHist.h \
>/afs/bingo/projects/viz/proj/pcgv/include/pcgvCCom.h \
>/afs/bingo/projects/viz/cvi/include/pcgvCVio.h \
>/afs/bingo/projects/viz/proj/pcgv/include/pcgvCImage.h \
>
>------------
This seems to do the trick (though the "one line" is a bit long :);
It's broken here for readability:
perl -0777 -e '($_ = <STDIN>) =~
( s/\s+(\\\n\s+)?/ \\\n /sg && s/^ (?=\/)(?!$ARGV[0]).*?\\\n//msg
&& s/[\s\\]+$/\n/ && print );' /afs/bingo/projects/ < test.d
[...]
>And, if I may be so picky, it sure would be neat if that last line
>didn't not have a backslash, thereby eliminating the need for the
>final blank line.
You got it.
>Thanks for any assistance,
>Gordon
--
vaccime@ripco.com
------------------------------
Date: Thu, 15 May 1997 19:39:25 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: How to stop FOMAT putting space between fields?
Message-Id: <1997May15.193925@ukwit01>
In article <ACC03D8D940E1376.7C48780809EC7642.76598DBAE941E3BE@library-proxy.airnews.net>, Harold Todd Chapman <chapman@techctr.buddcompany.com> writes:
|> I have the following format:
|>
|>
|> format =
|> GRID@>>>>>>>>>>> @<<<<<<<@<<<<<<<@<<<<<<<
|> $node, $x, $y, $z
|> .
|>
|>
|> The x/y/z vars are floating point numbers. I want them right next to
|> each other but FORMAT seems to insist that there be a space. How can
|> I prevent this.
format =
GRID@>>>>>>>>>>> @<<<<<<<<<<<<<<<<<<<<<<<
$node, "$x$y$z"
.
Would do it (as I recently discovered as a result of perusing
perlform for a similar desire), but whether it is the "approved" way.....
--
----------- Gordon Lack ----------------- gml4410@ggr.co.uk ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
------------------------------
Date: Thu, 15 May 1997 09:34:58 +0100
From: Andy.Law@bbsrc.ac.uk (Andy Law)
Subject: Re: Ingres data on the Intranet
Message-Id: <Andy.Law-ya023480001505970934580001@is.bbsrc.ac.uk>
In article <5lcbkg$6l0$1@bilbo.reference.com>, deepa@ril.com wrote:
> We have huge databases on Ingres. We wish to put some
>
> web applications which will be able to query the Ingres
>
> database.
>
>
>
> Can anyone make any suggestions.
>
> We are using the Apache Web Server. Using perl extensively
>
> for CGI development.
>
>
>
> Thanks in advance.
>
>
>
OK, non commercial posting here.
A colleague at the Roslin Institute has developed a tool called WebInTool
that acts as the bridge between an INGRES database and the web server. You
can find it at <http://www.ri.bbsrc.ac.uk/webintool>. Its available free of
charge under the GNU licence. Jian just asks for an acknowledgement to be
made somewhere on your web pages that you have used his software.
It doesn't shut down after 2 hours, nor does it require you to spend any
money (although if you want to send us some, then feel free to do so - the
science budget is pretty tight these days)
Later,
Andy Law
------------------
( Andy.Law@bbsrc.ac.uk )
( Big Nose in Edinburgh )
------------------------------
Date: 15 May 1997 18:35:33 GMT
From: fpm@u.washington.edu (Frank Miles)
Subject: Re: ls vs. readdir
Message-Id: <5lfl1l$fk0@nntp6.u.washington.edu>
In article <adelton.863708483@aisa.fi.muni.cz>,
Honza Pazdziora <adelton@fi.muni.cz> wrote:
>"David Jennings [MSAI]" <djenning@aisun6.ai.uga.edu> writes:
>
>> I recently wrote a small script for cleaning up some directories, and I
>> used the backticked UNIX command ls to get filenames. I am curious: is
>> using the backticked command more or less computationally expensive than
>> using the built-in Perl commands opendir and readdir?
>
>When you use opendir and readdir, you do not fork another process and
>also do not use external programs that somebody might have erased or
>so.
>
>> It seems like you can make Perl as much like or unlike conventional shell
>> programming as you please. Neat, I guess.
>
>I think opendir is better when you seek efficient and reliable
>solution, `ls` when you need easy solution. You can use Perl as
>a powerfull shell but it usually deserves more than that.
Sounds about right. May I intrude with a simple question?
-- When I do a opendir(); readdir(), the returned list does not include
the names of subdirectories (this is with Perl 5.003 under Linux[Debian]).
Is there any way of getting these from these functions? Must one use
ls or some other o.s. function?
This is probably covered somewhere, but after some (possibly non-exhaustive)
search of P.P.(2nd ed) and the very nice on-line help system in the OS/2
version, I have seen no other alternative.
Thanks for your help!
-frank
------------------------------
Date: 15 May 1997 14:19:39 -0500
From: Chris Halverson <cdh@CompleteIS.com>
Subject: Re: ls vs. readdir
Message-Id: <wpu3k4a6gk.fsf@CompleteIS.com>
fpm@u.washington.edu (Frank Miles) writes:
> -- When I do a opendir(); readdir(), the returned list does not include
> the names of subdirectories (this is with Perl 5.003 under Linux[Debian]).
> Is there any way of getting these from these functions? Must one use
> ls or some other o.s. function?
You should get directories (including "." and ".."). readdir gets
_everything_ in the directory:
{cdh@worf} 2:17pm (~/misc/tmp) > ls
total 4273
1 foobar/ 1888 hand_lgc.tif 960 hand_smc.tif 1424 next.tif
{cdh@worf} 2:17pm (~/misc/tmp) > perl -de 1
Stack dump during die enabled outside of evals.
Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.
Enter h or `h h' for help.
main::(-e:1): 1
DB<1> opendir(DIR,".")
DB<2> @yo = readdir(DIR)
DB<3> p join "\n", @yo
.
..
hand_lgc.tif
hand_smc.tif
next.tif
foobar
DB<4> {cdh@worf} 2:17pm (~/misc/tmp) >
If you want only dirs, do:
opendir(DIR, ".");
@dirs = grep(-d, readdir(DIR));
closedir(DIR);
Hope that helps some (and see perlfunc(1)).
Chris
--
Chris D. Halverson Complete Internet Solutions
PGP mail accepted, finger for public key http://www.CompleteIS.com/~cdh/
------------------------------
Date: 15 May 1997 19:33:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: ls vs. readdir
Message-Id: <5lfodj$r0q@news-central.tiac.net>
In article <5lfl1l$fk0@nntp6.u.washington.edu>,
Frank Miles <fpm@u.washington.edu> wrote:
>-- When I do a opendir(); readdir(), the returned list does not include
>the names of subdirectories (this is with Perl 5.003 under Linux[Debian]).
>Is there any way of getting these from these functions? Must one use
>ls or some other o.s. function?
>
>This is probably covered somewhere, but after some (possibly non-exhaustive)
>search of P.P.(2nd ed) and the very nice on-line help system in the OS/2
>version, I have seen no other alternative.
readdir reads directory entries, and unless you happen to have opened .
then they will nor be directly useful. I usually end up doing
$dir = '/foo';
opendir D, $dir or die "opendir $dir failed ($!)\n";
while (defined ($entry = readdir D)) {
$file = "$dir/$entry";
}
closedir D; # don't care!
which will leave you with something useful in $file (as long as you don't
use a relative path and chdir while you're running :-)
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: Thu, 15 May 1997 19:38:52 GMT
From: bernie@rev.net (Bernard Cosell)
Subject: More trouble with Syslog
Message-Id: <337b62a7.253331957@news.rev.net>
I commented out that call to hostname at line 92, but now I'm still
getting funniness. When I run the program it gets:
Identifier "Sys::Syslog::args" used only once: possible typo at (eval
22) line 2
.
Identifier "Sys::Syslog::y" used only once: possible typo at (eval 27)
line 2.
I'm not sure that is causing any problem, but it is a bit annoying
[and I certainly can't put the program into production with it
printing that out every time it is started]. Anyone know what is
happening and how to work around it. There are no 'evals' anywhere
that I could see in either my program or in Syslog.
Thanks!!
/Bernie\
--
Bernie Cosell mailto:bernie@rev.net
Roanoke Electronic Village
------------------------------
Date: Thu, 15 May 1997 17:39:52 GMT
From: Steve Karr <stevek@unidial.com>
Subject: Re: Private area using Perl/CGI
Message-Id: <337B4A68.23F2@unidial.com>
Ketil Froyn wrote:
>
> Abigail wrote:
> > ++ password to access? If so, would you like to share your knowledge with
> > ++ me? :)
> > No. Why on earth are you asking this in comp.lang.perl.misc?
> > Don't you know that soc.culture.china is the obvious place to ask?
>
> I'm sorry. Punish me. I thought the way to do this was cgi/perl. I have
> now seen the error of my ways, and I thank you for your guidance.
>
> Ketil
Ketil:
Abigail was being sarcastic. Most everyone here is more than happy
to help out and to share our knowledge! That's what this newsgroup
is for, exactly. Get it? Cool! Ask and thou shall receive help!
Steve
--
-{ Steve Karr Internet Services Coordinator }-
-{ UniDial Communications, Inc. http://www.unidial.com }-
-{ Voice +1.502.244.6666 ext. 1147 Fax +1.502.244.4810 }-
------------------------------
Date: 15 May 1997 18:00:56 GMT
From: Salve J Nilsen <sjn@pvv.ntnu.no>
Subject: Re: REQ: Perl obfuscator
Message-Id: <5lfj0o$stq@due.unit.no>
And then, Chipmunk suddenly uttered...
> In article <5l8epe$hll@due.unit.no>
> Salve J Nilsen <sjn@pvv.ntnu.no> writes:
> > # single out the first line - if it begins with #!
> > s/^(\#\!.*?[\n\r])/\n/s;
> > $head = $1 || "";
> Why the [\n\r]? At the very least, you might want to match \n without
> a \r.
[\n\r] is a character class, so when I write [\n\r] it'll match either
\n or \r, but not both (unless I write [\n\r]+ or equivalent)
> > my $msv = "a";
> > # (note that the variables will look like "_$msv" in the end :)
Oops, old comments! :P Originally i had a specialized procedure thar
added a _ in front of the new metasyntactical variable, wut whe I
generalized the routine (and made swap()) it had to go. Sadly,
$foo="_foo"; print ++$foo;
prints a "0". Strangely (perhaps even useful when obfuscating code),
print --$foo;
prints out "-1"! :)
> The way swap is written right now, I think they'll look like "$msv"
> > # ##############################
> > sub swap {
> > my($name, $hashref, $safe) = @_;
> > $$hashref{$name} = $msv++ unless ($safe || $$hashref{$name});
> > warn "SWAP($hashref) -> $name:$$hashref{$name}\n"
> > if ($DEBUG && !$safe);
> > return $$hashref{$name}?$$hashref{$name}:$name;
> > }
> swap always uses $msv, even though you've defined $mss and $msf in the
> code. You should probably pass in the metasyntactic variable as
> another parameter.
Oops again. You're right! Fixed!
> I notice that some of your calls to swap have $safe=0, and others
> $safe=1 - subroutine declarations vs. subroutine calls, for example.
> $safe should be the same for identifiers of a given kind - you don't
> want to rename subroutines where they're defined and not where they're
> called. :-)
What happens with $safe is supposed to be the following: if $safe is
set, then we may create new metasyntactical variables in the hash. If
$safe is unset, we only change the occurences of msv's that we already
have found (and placed in the hash).
Example:
s/^sub\s+(\w+)\s*\{/"sub ".&swap($1,\%some_hash,\$some_msv,0)." {"/em;
assigns a new MSV to each new occurence of $1, and places that into
the hash.
-----DATA
$foo = "bart&lisa";
$bar = "homer";
sub baz { return $foo.$bar; }
sub quux { return "quux" }
print $foo.$bar.&baz;
print $foo.&baz.$bar;
-----EODATA
after running the substitution on this (with $msv="a"), the hash
should look like this:
%some_hash = { 'baz' => 'a',
'quux' => 'b', }
and the data would look like..:
-----DATA
$foo = "bart&lisa";
$bar = "homer";
sub a { return $foo.$bar; }
sub b { return "quux" }
print $foo.$bar.&baz;
print $foo.&baz.$bar.&quux;
-----EODATA
(this is what I'm doing in arghify.pl)
Then we'd run the following substitution on the new data:
s/\&(\w+)\b/"&".&swap($1,\%some_hash,\$some_msv,1)/e
(Note that the $safe variable is set) The data should now look like
this:
-----DATA
$foo = "bart&lisa";
$bar = "homer";
sub a { return $foo.$bar; }
sub b { return "quux" }
print $foo.$bar.&a;
print $foo.&a.$bar.&b;
-----EODATA
Note that &lisa wasn't touched! That's the whole point of $safe. If
$safe is set, only names existing in the hash will be changed.
(Was this explanation understandable? :)
> > # ##############################
> > warn "Pass 4... Whitespace and comments\n" unless $QUIET;
> > s/(
> > (?:\\\\)*(?!\\)?([\"\'])[^\1]*(?:\\\\)*[^\\]\1|
> > ([\"\'])\2|
> > (?:\\\\)*\\\#.*?$|
> > \$\#.*?$)|
> > \#.*?$|
> > \s{2,}|
> > [\r\n]|
> > \#.*?$/$1/gmx;
> Why do you want to remove the newlines?
To make the code unreadable! Everything on one line, get it? 8)
> Why do you match [\r\n] here, when you matched [\n\r] earlier? (see
> above)
Yep, see above for my answer. (I think there could be a problem if
someone used the $^M variable... hmmm.)
> You match to the end of the line after any of the non-comment instances
> of #. This means that, for example, '$#foo=1; # set size of foo to 1'
> will not be touched, even though it does contain a comment. I'm not
> sure of the best way to solve this problem... Looping over each
> occurence of # might work, though...
what about changing "\$\#.*?$)|" to "\$\#[\w][\w\d]*)|"?
> # remove comments
> $pos = 0;
> while ( ($pos = index($_, \#, $pos) ) >= 0 ) { # find next
> occurence of '#'
> if (&is_comment_start($_, $pos)) { # if this '#' marks the start
> of a comment
> substr($_, $pos, index($_, "\n", $pos)) = "";
> # remove everything from here
> to end of line
> }
> }
> # is_comment_start
> # returns true if # at $pos is the start of a comment
> sub is_comment_start {
> my($string, $pos) = @_;
> return if (substr($string, $pos, 1) ne "#");
> $string = substr($string, 0, $pos); # remove '#' and everything
> after
> # so match can occur at
> end of string
> return (! ($string =~ /(\\|\$)$/) );
> # if it's not escaped or part of a length-of-array index, it's a
> comment
> }
> This code I've given does not check whether the # is in a quoted
> string, however. :-(
> Also, it hasn't been tested. :-)
Hmm... I think this needs more work (you're welcome to do it!:)... I'm
doing this to learn regular experessions and perhaps some Perl syntax,
but you're of course welcome to try other methods :)
> I do think that there will always be some cases that arghify.pl won't
> be able to handle properly. For example:
> $foo = "bar";
> $$foo = "baz";
> if ($bar eq "baz") {
> print "Hello world\n";
> }
> would be changed to something like:
> $a = "bar";
> $$a = "baz";
> if ($b eq "baz") {
> print "Hello world\n";
> }
Not to mention,
print << EOT;
sub foo {
print "bar";
}
Is a very basic program.
END
and similar things...
> Nevertheless, it's still a cool program and I'm glad to help with its
> development!
Thanks, and who knows, perhaps this program even could become useful
some day! :)
The newest version can be found at URL:http://www.pvv.org/~sjn/arghify.pl
--
#!/store/bin/perl
#@(#)RELEASE VERSION .sig V1.02 by Salve J. Nilsen - Hacker, Student, Magician
($_='$ZNVYGB+$FWA?$CII:$BET;')?y:;ZA-Y\:?+${':\nm-za-l.@\:\0:?print:'}.':'.$';
------------------------------
Date: Thu, 15 May 1997 18:01:18 GMT
From: xxbbell@voicenet.com (Bob)
Subject: Re: setuid & setgid scripts executed via cgi/internet
Message-Id: <5lfjbc$spo$1@news2.voicenet.com>
Have you tried just putting a line in the script that does a
"whoami" or something similar to find out who the script runs at? My
recommendation.
"Christopher S. Reickenbacker" <chrisre@medianet.com> wrote:
>I am working on a web browser based cgi program to allow Computer
>Operators the option of executing commands as root(cancel print jobs,
>kill processes, rm files, etc...) Thus far I have had no luck. Right now
>I am trying this:
>
> 1) the cgi program is owned by root.
> 2) the setuid and setgid bits are set on the cgi program.
> 3) a system call is made to remove a test file in my home dir.
>
>Result: Nada. The file remains.
>
>I think that the http daemon user who actually runs the program is
>being blocked. I am not sure. If anyone has any idea how to do this, I
>would be very thankfull. I know perl is the language for this, as
>opposed to c, but I am getting nowhere doing it over the internet(behind
>firewall.)
>
>Thanks a million.
--
- Bob
http://www.voicenet.com/~bbell
xxbbell@voicenet.com
remove x's to reply
------------------------------
Date: 14 May 1997 18:14:54 GMT
From: rickg@hyperion.dynanet.com (Rick Greene)
Subject: setuid, trying to rm a file (Unix)
Message-Id: <5lcveu$enb$1@thea.dynanet.com>
Greetings all.
I've fixed most of my Insecure-ities in a setuid script I'm working on, only
one I can't figure out is trying to remove a file that was created by the
script.
During the script's run, it create a lock directory, "/etc/ptmp". At certain
points, temporary work files will be created within that directory. When
the script completes (successfully or not), I call a routine that is supposed
to do a "rm -fr /etc/ptmp". What I get back from the system is:
rm: /etc/ptmp: Permission denied.
If it gets created as owned by root from the setuid, why won't the remove
work the same way?
Any/all help would be greatly appreciated.
Rick Greene
Mid-Range Systems Support
Wyeth-Ayerst Laboratories
------------------------------
Date: Thu, 15 May 1997 12:08:38 -0700
From: Venkat Jagadish <venkat@bbb.caltech.edu>
Subject: swallowing whitespace
Message-Id: <337B5F36.41C67EA6@bbb.caltech.edu>
Hello Perl Wizards,
I am trying to eat up any whitespaces (ws) from every line (excluding
line-breaks) of a file that contains a list of mistyped
e-mail addresses.
I tried the following :
s/(\s+)(^[\n])(.*)/$2$3/g ;
but when the default pattern space ($_) encounters a line
such as
"login name@host. network.domain"
^ ^
| |
(single ws) (3 successive ws)
the above substitution yields
"loginname@host. network.domain"
Apparently, it matches a single whitespace followed by a
non-whitespace character but not successive whitespace (excluding
line-break) characters.
The surprising thing is that it works when I rerun the script
on this modified file once more.
I thought the /g modifier should take care of matching all
the occurrences in one shot.
What am I odoing wrong? Also is there a way
to do modifications in place in PERL ?
Thanks.
PS> e-mails will be greatly appreciated.
--
-------------------------------------------------------------------------------
e-mail: venkat@bbb.caltech.edu Ph: (213) 227-6007 [H]
(818) 395-6818 [W]
-------------------------------------------------------------------------------
------------------------------
Date: 15 May 1997 13:33:04 -0400
From: daku@nortel.ca (Mark Daku)
Subject: What's the quickest way in perl to determine if a scalar is a list?
Message-Id: <esqu3k4prn3.fsf@nortel.ca>
I'm looking for the FASTEST way to locate a string in an array. By
fastest I mean in cpu not in code style. I have a lot of arrays
in my code I just want to speed up the validation.
EG:
----------
@array = ("a","b","c","d","e","f");
$string = "a";
# were "isin" is my really fast look up code, I've used it like an operator.
# but it doesn't have to be a code block will do.
if ( $string isin @array ) {
print "found it\n";
} else {
print "Ah sucks it's not there!\n";
}
-----------
I would really like to have the exists function work on arrays as well.
Mark Daku
daku@nortel.ca
------------------------------
Date: 15 May 1997 18:13:28 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: What's the quickest way in perl to determine if a scalar is a list?
Message-Id: <5lfjo8$m0o@news-central.tiac.net>
In article <esqu3k4prn3.fsf@nortel.ca>, Mark Daku <daku@nortel.ca> wrote:
>
>I'm looking for the FASTEST way to locate a string in an array. By
>fastest I mean in cpu not in code style. I have a lot of arrays
>in my code I just want to speed up the validation.
>
>EG:
>----------
>@array = ("a","b","c","d","e","f");
>
>$string = "a";
>
># were "isin" is my really fast look up code, I've used it like an operator.
># but it doesn't have to be a code block will do.
>if ( $string isin @array ) {
> print "found it\n";
>} else {
> print "Ah sucks it's not there!\n";
>}
@array = ("a","b","c","d","e","f");
%isInArray = map {$_ => 1} @array;
...
if ($isInArray{$a}) {
...
}
is one way to do it, others are mentioned in the FAQ under
http://www.perl.com/FAQ/
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 May 1997 18:14:57 GMT
From: sukhr@bu.edu (Tony Zaki)
Subject: Year 2000 Issues with Perl5
Message-Id: <5lfjr1$t45@news.bu.edu>
Hi all..
Could someone please direct me to any site that has more information regarding
Perl5 and problems with the year 2000 ???
We are investigating the consequences of that year on our Software, and
specially our website which is totally based on Perl..
I hope Perl5 doesn't have problems.. But still, if someone knows,
please email me directly, so I don't miss the information.
Thank you in advance..
Tony Zaki
tz@usa.net
------------------------------
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 483
*************************************