[10104] in Perl-Users-Digest
Perl-Users Digest, Issue: 3697 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 11 19:08:34 1998
Date: Fri, 11 Sep 98 16:01:28 -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 Fri, 11 Sep 1998 Volume: 8 Number: 3697
Today's topics:
Re: Perl gurus opinion needed. <dwheeler@isd.net>
Perl printing help jasonburks@my-dejanews.com
Re: Problems with UNC on Windows platforms <evhendrs@micron.net>
Re:[Re:Searching for a few CGI scripts] t-dog98@usa.net
Re: Regular expression question <dgris@rand.dimensional.com>
REMOTE_USER ENV variable trapping <rsmoore@banton.com>
Re: Search/Replace but Not under certain conditions. HO (Larry Rosler)
Re: Search/Replace but Not under certain conditions. HO (Larry Rosler)
Selecting menu items in Telnet (W95)? <dlyons_remove_to_reply@stats.tcd.ie>
Re: setuid CGI <prauz@sprynet.com>
Re: sorting strings (Tad McClellan)
system "convert -monochrome... <buck@writeme.com>
Re: Using perl to write a passwd program... <pinky@mail.usmo.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 Sep 1998 16:04:06 -0500
From: "Doug Wheeler" <dwheeler@isd.net>
Subject: Re: Perl gurus opinion needed.
Message-Id: <6tc35q$i7i$1@blackice.winternet.com>
Mark-Jason Dominus <mjd@op.net> wrote in message
6tbsld$5nf$1@monet.op.net...
>
>In article <6tbp40$eqo$1@blackice.winternet.com>,
>Doug Wheeler <dwheeler@isd.net> wrote:
>>It seems (from some quick research) that all the "hacks" relating to being
>>available for hire (cabs, horses, etc.) are derived from "hackney." All
the
>>forms relating to unskilled cutting (and other unskilled work) are from
the
>>word "hack." I would definitely put computer hacker (and hack writer) into
>>the second category.
>
>`Computer hacker' may be a matter for speculation, but `hack writer'
>is not. `Hack writer' is derived from `hackney' (== cab) and not from
>`hack' (== hoe, cut up) regarless of whether you would categorize it
>that way or not.
Hmmm... I think there are two common uses of "hack writer." The first being
a writer who works on order, the second being a writer who throws together
poor-quality books based on tire cliches and overused plotlines. I have
definitely heard the second usage more than the first, but the dictionary
doesn't cover that usage at all - possibly because it is simply a
combination of "hack" and "writer" using their individual meanings without
the combined meaning of "hack writer."
--Doug
------------------------------
Date: Fri, 11 Sep 1998 20:41:52 GMT
From: jasonburks@my-dejanews.com
Subject: Perl printing help
Message-Id: <6tc1uf$mis$1@nnrp1.dejanews.com>
I need to print to two filehandles at once in Perl can this be done?
example:
open(file1,"|command");
print file1 << EOF;
cd ~
ls
EOF
I need to print the results from between << EOF and EOF, mainly the results
from the ls. But I need to print the results from the print to file1 into
either another filehandle or a variable. Command in my case is ftp to a
machine. Thanks in advance! Jason Burks
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 11 Sep 1998 14:15:18 -0600
From: Ed Henderson <evhendrs@micron.net>
To: Claudio Felber <felber@cybernetic.ch>
Subject: Re: Problems with UNC on Windows platforms
Message-Id: <35F984D5.5C10D942@micron.net>
Claudio Felber wrote:
> Hi!
>
> I need to create directories and access files over UNC paths on
> Windows systems. Opening and working with files is no problem,
> but path manipulations such as creating or changing directories
> is. Probably because the Perl functions are based on the functionality
> of the basic change/make directory of Windows consoles which also
> do not work with UNC. So, what am I going to do? I would like to
> do something like that:
>
> chdir '//PDC-Intranet/Backup' or
> chdir "\\\\PDC-Intranet\\Backup' or
> mkdir '//PDC-Intranet/Backup/Linux'
>
> etc...
>
> Any ideas?
> -Claudio
Unfortunately the <*> syntax, and also glob "*" in perl execute in a
sub-shell.
Well the shell in winnt does not support UNC paths as the current working
directory.
Anyway, here is a workaround that will acomplish the task:
use Cwd; # cwd module gets current working directry in portable manner.
chdir "//hostname/foo/bar/bletch";
# old way:
# my @files = glob "*";
# New way:
my $cwd = cwd;
my @files = glob "$cwd/*"; #This is perl, no need for *.* anymore :-)
print "Files: \n\t" . join ("\n\t", @files) . "\n";
------------------------------
Date: Fri, 11 Sep 1998 22:32:51 GMT
From: t-dog98@usa.net
Subject: Re:[Re:Searching for a few CGI scripts]
Message-Id: <6tc8ej$ur1$1@nnrp1.dejanews.com>
Thanks for your suggestion. I hope my message did not offend anyone.
Terence
In article <35F968DC.11DB753@mail.law.berkeley.edu>,
Edwin Shin <eshin@mail.law.berkeley.edu> wrote:
> you'll probably have better luck asking on
> comp.infosystems.www.authoring.cgi or doing a search on the web.
>
> there are a variety of perl-cgi related links from the perl.com page
> under the CGI link.
>
> t-dog98@usa.net wrote:
> >
> > Hi,
> >
> > I am looking for several scripts which I have seen many times on the web. I
> > was wondering if they are custom-made scripts or availible for download.
> >
> > 1. A search engine position analyzer. It searches the top search engines
for
> > your URL with keywords which you specify, and return with your rankigs.
> >
> > 2. A link finder. It searches in several search engines for your URL and
> > returns with the webpages that have linked to you.
> >
> > 3. A Meta tag builder. <-- I bet this one is so simple people just make
their
> > own.
> >
> > 4. A multiple URL submission script. It submits several URL all at once to
> > the top search engines.
> >
> > I would greatly appreciate any help.
> >
> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 11 Sep 1998 20:08:18 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Regular expression question
Message-Id: <6tbv8e$797$1@rand.dimensional.com>
[posted to comp.lang.perl.misc and mailed to the cited author]
In article <35F91061.30F8@jump.net>
mikec@jump.net wrote:
>My question is: given an array of all five letter words, and a given
>crypt word like "mlkqk", what is the best way to filter the array down
>to only those words that might match?
TIMTOWTDI, here's one (although Sean's regular expression is
faster).
#!perl
use strict;
my $crypted_string = 'mlkqk';
my $length = length($crypted_string);
my $crypt_value = cryptogram ($crypted_string, 0);
open(DICT, '/usr/dict/words') || die "Oops: $!";
my @a;
chomp(@a = <DICT>);
for(@a) {
next unless length == $length;
print "$_\n" if $crypt_value == cryptogram ($_, $crypt_value);
}
sub cryptogram {
my ($string, $compare) = @_;
my (%hash, $i, $value);
if($compare) {
for(split //, shift) {
$hash{$_} = ++$i unless $hash{$_};
$value .= $hash{$_};
return 0 unless $value eq substr($compare, 0, length($value));
}
return $value;
}
for(split //, shift) {
$hash{$_} = ++$i unless $hash{$_};
$value .= $hash{$_};
}
return $value;
}
__END__
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
`Bangladesh. Because life is too short to run bad code.'
Jon Orwant
------------------------------
Date: Fri, 11 Sep 1998 17:09:13 -0500
From: "Robert S. Moore" <rsmoore@banton.com>
Subject: REMOTE_USER ENV variable trapping
Message-Id: <6tc6se$2iu$1@news.ro.com>
I would appreciate any advice regarding the following problem:
We are operating a web that does not restrict general access. We provide
restricted password access by setting protection on the htm that calls the
scripts. The problem comes when trying to trap the REMOTE_USER env variable
when these users access our perl scripts. REMOTE_USER is blank when we run a
.PL program but does show up when we run an .EXE out of the same directory.
We noticed that if we apply security to the entire web that we can retrieve
that REMOTE_USER but this is not a viable solution as we have many users and
different access levels.
We need the REMOTE_USER so we can do some database access checking with it.
Any ideas?
Thank you,
Bob Moore
Banton Research
rsmoore@banton.com
------------------------------
Date: Fri, 11 Sep 1998 14:24:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Search/Replace but Not under certain conditions. HOW?
Message-Id: <MPG.106334cb536fbcca9897a0@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6tbn5m$5tt$1@mathserv.mps.ohio-state.edu> on 11 Sep 1998
17:37:58 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler
> <lr@hpl.hp.com>],
> who wrote in article <MPG.1062d1eab5ee1c4989848@nntp.hpl.hp.com>:
> > $body =~ s!(http://[^\s@]+)(?=\s|$)!<a href="$1">$1</a>!g;
>
> Negative lookahead is your friend:
>
> http://[^\s@]+(?!\S)
Good. Are there many More Ways To Do It?
> And you do not *need* grouping - if $& slowdown is tolerable.
Never!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 11 Sep 1998 14:35:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Search/Replace but Not under certain conditions. HOW?
Message-Id: <MPG.10633764802d6b889897a1@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <6tbndq$66g$1@mathserv.mps.ohio-state.edu> on 11 Sep 1998
17:42:18 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> Oups, one needs to backwack the @-sign:
>
> http://[^\s\@]+(?!\S)
Why?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 5 Sep 1998 13:32:08 +0100
From: "Donal Lyons" <dlyons_remove_to_reply@stats.tcd.ie>
Subject: Selecting menu items in Telnet (W95)?
Message-Id: <6sraup$r5g@web3.tcd.ie>
I'd like to write a script to telnet to a specific server and download a
file. Starting telnet from perl is o.k. but the first problem is how to
select menu items. It seems that a two byte code (\0 \???) is needed for
the ALT+c required to select the connect menu item. Presumably there are
scripts somewhere that carry out this type of function - any pointers would
be appreciated.
Otherwise, can one use getc in some way to read an ALT+c from STDIN and
output it to a file which will be used as input to telnet?
TIA,
Donal.
P.S. I've had a look at Term::Readline::Perl and need something MUCH
simpler.
------------------------------
Date: Fri, 11 Sep 1998 15:18:17 -0600
From: Balazs Rauznitz <prauz@sprynet.com>
To: Sam Wang <samwang@freewwweb.com>
Subject: Re: setuid CGI
Message-Id: <35F99399.3C970FCC@sprynet.com>
Sam Wang wrote:
> let me get this straight, i can run the cgi script under me (the owner),
> if i set setuid to my ui, right? ok. great. but how do i find out my id?
Wrong. What system do you use. Under unix you can make a script setuid bye
chmod +s <filename>
This will automaticly make your script setuid.
However if the script is run by the http sever than this doesn't work. The
webmaster must install cgiwrap or suexec.
Balazs
------------------------------
Date: Fri, 11 Sep 1998 11:53:31 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sorting strings
Message-Id: <bikbt6.9mk.ln@metronet.com>
st (st@fr.com) wrote:
: Could someone point me in the right direction.
: I want to get @givenSizes to
: 13, 15, 22, "S", "M", "L", "XL", "XXL", "XXXL"
: What am doing wrong ?
Not using the -w switch, for one. It makes a bunch of complaints...
#!/usr/bin/perl -w
: my @givenSizes = ( "S", "XXL", "M", "L", 13, 22, 15, "XL", "XXXL" );
: sub sizeSort {
: my $sizes = { "S", "M", "L", "XL", "XXL", "XXXL" };
You are making a reference to an anonymous hash with only
*three* key=value pairs.
--------------------------------
#!/usr/bin/perl -w
my $sizes = { "S", "M", "L", "XL", "XXL", "XXXL" };
foreach ( keys %$sizes ) {
print "$_ = $$sizes{$_}\n";
}
--------------------------------
See?
I don't see how that will help in sorting.
You don't need references here. See below.
: $a <=> $b
: or
: $sizes{$a} cmp $sizes{$b}
^^^^^^
The %sizes hash has never been initialized.
(the %$sizes hash has been though...)
^^
^^ dereference it
: or
: $a cmp $b;
: }
: my @vals = sort sizeSort @givenSizes;
: print join( "\n", @vals );
Not very elegant, but it works:
--------------------------------
sub sizeSort {
my %sizes = ( S=>0, M=>1, L=>2, XL=>3, XXL=>4, XXXL=>5 );
return $a <=> $b if $a =~ /^\d+$/ && $b =~ /^\d+$/; # both are digits
return 1 if $b =~ /^\d+$/; # digits before alphas
return -1 if $a =~ /^\d+$/; # digits before alphas
$sizes{$a} <=> $sizes{$b} # else do hash lookup
}
--------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 11 Sep 1998 22:17:02 +0200
From: Stefan Buck <buck@writeme.com>
Subject: system "convert -monochrome...
Message-Id: <35F9853E.178624D0@writeme.com>
I'm trying to convert a Bitmap File within my perl script. We have
ImageMagick-3.7.1 installed on our unix system and I'm trying to manage
the conversion with the system command in perl. I know there are Modules
like PerlMagick, but it should work with system command, too right?
$check = system "convert -monochrome /home/buck/WWWMM/pulse/j0.jpg
/home/buck/WWWMM/pulse/j2.jpg";
Nothing! And the strange thing which hopefully has an easy solution:
I start the script via a form on a web page, but it doesn't work it does
nothing and $check is always 9. But if I start the script using telnet
it works!
I tought the problem might be the paths so I added
$ENV{"PATH"} =
"/bin:/usr/bin:/usr/openwin/bin:/usr/dt/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/opt/SUNWmotif/bin:/usr/depot/bin:/opt/tools/frame/bin:/soft/oracle/app/oracle/product/7.3.2/bin:/soft/oracle/dev2000/bin:/usr/ucb:/usr/depot/depot/ImageMagick-3.7.1/bin";
before the system call(I copied that path from the telnet window) but
that didn't work, too.
1. Any idea what I'm doing wrong?
2. What is the difference between using system command from perl>telnet
and from perl>form? The paths ya they are set different I found saw
that, some more differences?
3. How can I get the eroor messages from a system call? I tried
>errorfile but that didn't save any error messages!
Thanks for quick help!
Stefan Buck
------------------------------
Date: Fri, 11 Sep 1998 12:07:19 -0500
From: "Stefan Adams" <pinky@mail.usmo.com>
Subject: Re: Using perl to write a passwd program...
Message-Id: <6tblm5$1ak$1@news.usmo.com>
About writing a perl passwd script. I have already written all the
functions to crypt the password and to throw out bad passwords and do random
passwords. However, my problem is updating the /etc/passwd file. One way
that I have been doing it is opening /etc/passwd and making the change with
in a foreach $line (@line) {} of the OPEN(/etc/passwd) This works fine for
root. But note how the distributed passwd written in C program can be run
by any user to update the password for that user only. The way that I have
done it will only let root make changes because no other users have access
to /etc/passwd. How can I possibly get around this while leaving the
permissions of /etc/passwd set to -rwxr--r-- since the C passwd can make
changes with these permissions?
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3697
**************************************