[13512] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 922 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 27 17:07:22 1999

Date: Mon, 27 Sep 1999 14:05:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <938466319-v9-i922@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 27 Sep 1999     Volume: 9 Number: 922

Today's topics:
    Re: <> = new line? (Larry Rosler)
    Re: CGI or JDBC <makkulka@cisco.com>
    Re: Command Line CGI Script <AgitatorsBand@yahoo.com>
    Re: Help! How do I set a date field to empty via ODBC? (Kragen Sitaker)
    Re: How to create files from CGI script? (Kragen Sitaker)
    Re: Inserting HTML into document using PERL <makkulka@cisco.com>
        Installation Problem!!!! (Lance Stallcop)
    Re: Logfile analyzer (Michel Dalle)
        LOL, please don't overanalyze :) <Webmaster@copscorp.com>
    Re: Looking for Downloadscript <cassell@mail.cor.epa.gov>
    Re: Multiple Option <makkulka@cisco.com>
    Re: Parsing @argv <aqumsieh@matrox.com>
        Passing info to CGI's in the URL <r37116@email.sps.mot.com>
    Re: Passing info to CGI's in the URL <msfrost@celluloidnexus.com>
    Re: Passing info to CGI's in the URL (Kragen Sitaker)
    Re: pattern matching problem <aqumsieh@matrox.com>
    Re: pattern matching problem (Larry Rosler)
    Re: Q on file rights for CGI process <rootbeer@redcat.com>
    Re: Question About the last command (Greg Bacon)
    Re: Question About the last command (Kragen Sitaker)
    Re: Randomize array..... <aqumsieh@matrox.com>
    Re: Randomize array..... <cassell@mail.cor.epa.gov>
    Re: remove the html tag in the file (Randal L. Schwartz)
    Re: remove the html tag in the file <dan@tuatha.sidhe.org>
    Re: Replacement "CD" for win32 systems (Kragen Sitaker)
    Re: Replacement "CD" for win32 systems (Ray Dunn)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 27 Sep 1999 12:39:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: <> = new line?
Message-Id: <MPG.125967e1b9ae8b7989fe7@nntp.hpl.hp.com>

In article <37EFA5CB.16F1C6A0@dwc.ch> on Mon, 27 Sep 1999 18:13:47 
+0100, Christoph Wernli <cw@dwc.ch> says...
> Ran Shoham wrote:
> > 
> > I'm just wondering, if <> operator allows me to get the "next line" from
> > input,  is there a similar way for me to get the "next word"?
> 
> Play around with the input separator, i.e:
> 
> $/ = " ";

Unfortunately, that will return "foo\nbar" from an input file with 
"foo\n" ending one line and "bar" beginning the next line.  It will also 
return null strings on consecutive spaces.

Those problems can be corrected, but it is rather ugly.  There are two 
cleaner ways.

One way, if the file isn't too long and you would like to process all 
the words sequentially, is to read it all into a string, then use a 
regex to pick out the words:

    my $file = do { local $/; <DATA> };
    while ($file =~ /(\w+)/g) {
        # process the word in $1
    }

Another way is to do the standard line-at-a-time read, then split the 
input line:

    while (<DATA>) {
        my @words_on_this_line = split;
        # process the words in @words_on_this_line
    }

One might incorporate this into a subroutine that is the 'next word' 
function you asked for:

#!/usr/local/bin/perl -w
use strict;

{
    my @words;
    sub next_word {
        defined(local $_ = <DATA>) || return and @words = split
            until @words;
        shift @words;
    }
}

print "$_\n" while defined($_ = next_word);
__END__
foo bar

baz quux    
zilch

Output:

foo
bar
baz
quux
zilch

It gets more complicated to do this on several files simultaneously, but 
you get the idea.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 27 Sep 1999 12:06:40 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: CGI or JDBC
Message-Id: <37EFC040.8954FE8C@cisco.com>

 [ Thomas Haenel wrote:

> what are the pros and cons of using one technology over another ?

You cannot compare CGI with JDBC.  You might want to
compare DBI with jdbc.
--



------------------------------

Date: Mon, 27 Sep 1999 19:43:12 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Command Line CGI Script
Message-Id: <kNPH3.406$oy2.81036@news.shore.net>

Scott Beck <admin@gatewaysolutions.net> wrote:
: The script I am running is an install script for a program.
: The program will not run from the command line but from the browser.
: It will need read, write, and create privileges on the directories that are
: created
: with the install script.
: The only way to do this is set the directories permissions to 0777 or have
: them owned
: by the script.
: The first option is a security risk and should not be done.

Unfortunately, the second option is a risk, too, since a directory that is
writeable by "nobody" is writeable by *anybody's* CGI script, not just the
one you're installing. You're probably aware of this but it's worth
pointing out. 

Unfortunately again, I don't have a good solution to offer; if you want
something that's portable, you don't really have a lot of options (as far
as I know); you could try to chown the file and then make the permissions
0777 if that fails, but I wouldn't recommend either solution if the data
you're going to be writing is at all sensitive. 

What about having an install script that runs as a CGI instead of as a
shell script, at least to create the necessary directory?

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


------------------------------

Date: Mon, 27 Sep 1999 20:19:32 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help! How do I set a date field to empty via ODBC?
Message-Id: <ojQH3.2120$J66.240420@typ11.nn.bcandid.com>

In article <7soa5b$ai5@dfw-ixnews10.ix.netcom.com>,
Lin Parkh <lparkh1@ix.netcom.com> wrote:
>I'm using MS Access and wish to set a date field to empty (or null).  I've
>done a lot of SQL/ODB/Perl so probably my basic syntax is correct. I can
>also insert proper dates no problem.  The problem seems to be in how to
>express a null insert value. I've tried the following variants:
>  ''
> ""
> '##'
>0
>and none of these make ODBC driver/Access happy.

How about NULL?

>Here's an example failing call:
>
>   SET Table1.DateField = ""

SET Table1.DateField = NULL, I think.  Although it's been a few years
since I wrote SQL.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Sep 27 1999
42 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Mon, 27 Sep 1999 21:01:36 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to create files from CGI script?
Message-Id: <QWQH3.2179$J66.246693@typ11.nn.bcandid.com>

In article <37EF3779.53E87E10@desertigloo.com>,
David P. Schwartz <davids@desertigloo.com> wrote:
>Kragen Sitaker wrote:
>
>> In article <37EDAEFC.C929A798@desertigloo.com>,
>> David P. Schwartz <davids@desertigloo.com> wrote:
>> >This strikes me as very unusual and unexpected behavior.  Is there some
>> >chance that
>> >directories named "protected" are set to behave differently than normal?
>> >Or perhaps
>> >even subdirs beneath tmp (it's possible, but unlikely)?
>>
>> No.  What part of it strikes you as unusual and unexpected?  That I
>> couldn't rm or mv the file?
>> --
>
>Well, that too. You had read+write perms on the dir.  So it looks like
>you couldn't
>read or write from/to it.  What am I missing here?

I didn't have execute permission on the dir, so I couldn't access files
in it.  I thought I'd be able to delete files from it and rename files
into or out of it, too, but I couldn't do that either.  That's what
execute permission on a directory does.

This is why I was suggesting that 666 perms on a directory might be a
problem.  :)

Notice that 'ls' worked fine.  (ls -l doesn't, though, because it can't
lstat the files.)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Sep 27 1999
42 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Mon, 27 Sep 1999 12:11:23 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Inserting HTML into document using PERL
Message-Id: <37EFC15B.10F8699D@cisco.com>

[ Ion Hatzithomas wrote:

> How do I insert an extra html line using PERL.
> I donot want to use SSI..
> Can it be done?

Yes. I think what you need are templates that are processed
before HTML is sent to the browser.
Read this article on Hotwired
http://www.hotwired.com/webmonkey/code/97/21/index2a.html?tw=backend

--



------------------------------

Date: Mon, 27 Sep 1999 20:46:30 GMT
From: lance@claynet.com (Lance Stallcop)
Subject: Installation Problem!!!!
Message-Id: <37efd616.281101021@news.claynet.com>

I'm trying to install Perl 5.005_03.  I downloaded stable.tar.gz and
followed the instructions from there.  I ran Configure and checked all
the questions I was asked, everything looked normal.  Configure wrote
the config.sh file and gave me the opportunity to edit the file or
press return.  I pressed return, next thing I know my machine is
counting the RAM and rebooting!  I tried again, this time I can
Configure -d to let it do its own thing.... same problem.

I'm running Slackware 3.5 on an AMD 400.  Perl was already on the
system, 5.004.  Is there something I needed to do before trying to
upgrade it?  My perl programmer insisted that I would be much happier
with 5.005.




------------------------------

Date: 27 Sep 1999 20:47:17 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Logfile analyzer
Message-Id: <7sol4l$koo$1@nickel.uunet.be>

jester@dork.com (JeSTeR!) wrote in <7so9vv$mb6$1@dinkel.civ.utwente.nl>:

>Has anybody got (or knows where to find) a logfile analyzer written in
>Perl? 
>
>I would like to make my own stats-page of my WarFTPd-server, but I would
>like to see some examples first...
>
>I would appreciate it, if you also answer to this message straight to
>W.J.Huls@student.utwente.nl , because I don't check this newsgroup so
>often...
>

Have a look at some examples at the CGI Resource Index :

http://cgi.resourceindex.com/Programs_and_Scripts/Perl/Logging_Accesses_and
_Statistics/ 

Cheers,

Michel.


------------------------------

Date: Mon, 27 Sep 1999 16:25:39 -0400
From: "Eric Seiler" <Webmaster@copscorp.com>
Subject: LOL, please don't overanalyze :)
Message-Id: <WpQH3.155$AH1.184903@news.abs.net>

Perhaps, before you apply your Wall Street savvy to categorize my business
venture you should become more aware of the facts.  Since you have not
requested them yourself, I assume that you are not really interested, but
for those who haven't read this thread I will present a few more that will
clear up the situation.

First off, the reason that I am paying on the net profitability is because
if there are any profits left over I will gladly give them to those who
helped this venture.  Secondly, as soon as I can offer more equitable terms
for the people working with me then I most certainly will, but right now I
can't give them money that I don't have.  Okay, I could...but I'd like for
this venture to last more then a month.  Sending me to bankruptcy court
would certainly be the end of this venture. Third, any person accepted into
this venture will be considered an integral part of a team, and I will do
anything in my power to keep them around if they are not threatening the
health of the venture.  I am not, and let me make this very clear;
interested in turning a fast buck and those who choose to apply should be
made very clear on that point.  I am also very flexible on the terms of our
agreement.  I realize that what I have to offer right now is not a great
deal, but I encourage all of those whom do decide to give us a shot to name
any terms they would like to have in their contract.  If it is reasonable
and sound then I am willing to accommodate, but I can't make any short-term
promises, and I won't.

I think some people are confused, and think I am here to take other people's
time, and return nothing - that is completely false.  I believe in keeping
the key players around, and will offer whatever I can, at the time, to do
so.  I'm not asking for investors - I'm asking for people to help grow a
business.  If the business is a success then no doubt the pay plan will
change, but if it is a failure then we will all be looking for something
else and I will be the only one to lose money.

As for yahoo - it was started by two guys with little money.  If a person
has the drive, motivation, and talent to help me make this into the next
yahoo, then I will offer them terms on the gross revenue of the venture.  I
might find someone like that this way, or I might not, but I'm not going to
spend tens of thousands of dollars searching.

I find this whole discussing fascinating though, and I hope you continue to
respond. If you were in my situation, with very little capital (enough to
take care of the web account, some pre-written apps, etc.), no desire to
take out a loan (too risky when it is the Internet), a great idea, but needs
people willing to work with him, what terms would you offer them? Oh, I also
need to mention that I am only a partner in the company that has supported
this thus far; Therefore, I cannot extend partnership to someone else,
without the consent of everyone else.  Interesting situation, isn't it? So
what would you do? What form of agreement would you use that would be fair
to everyone involved?

I eagerly await your response(s).

Eric Seiler
Cops, Inc.




Eric Bohlman wrote in message <7sodjb$960@dfw-ixnews7.ix.netcom.com>...
>[comp.lang.perl.tk removed from followups]
>
>Ethan H. Poole (ehpoole@ingress.com) wrote:
>: Eric Seiler wrote:
>: >
>: > Hello, I am designing a business site that requires more then what I
can get
>: > out of pre-written scripts.  The sort of scripting I need is pretty
>: > advanced, and only those familar with user management, and ecommerce
>: > scripting need apply.  Pay would be dependent on the net profitability
of
>: > the website.
>:
>: You just ruled out all of the experienced programmers.
>:
>: Experienced programmers seldom ever choose to bear another party's risks
>: -- it almost never makes any financial sense unless there is a real
chance
>: that the business is going to become the next MS (which is unlikely and
>: even then they would demand shares).  The success of a venture depends at
>
>Furthermore, most new business ventures *never* turn a profit (if the
>people who did the programming for Amazon or Yahoo had done it on the
>terms Mr. Seiler is offering, they wouldn't have seen a penny yet).
>Second, most successful business ventures don't report any profit for the
>first few years of their existence, even if they're actually making
>money, because of the use of (entirely legitimate) accounting techniques
>intended to save on taxes.  IIRC, the only Web sites actually currently
>turning a profit are porn sites.
>
>Thus someone who does "spec work" in return for a percentage of the
>profits is unlikely to *ever* get paid.  If he does get paid, he's
>unlikely to see anything for several years.  The only thing dumber than
>agreeing to work for a percentage of the profits is agreeing to work for a
>fixed sum or hourly rate to be paid out of the profits.  That amounts to
>giving somebody an interest-free non-recourse loan.  Spec work only makes
>sense if the potential payment is open-ended, and even then it's rare in
>practice that the equivalent hourly rate you make on it is better than you
>could make asking customers if they want fries with that.  If you're
>foolish enough to do spec work for an hourly rate, you need to quote a
>rate based on dividing your normal hourly rate by the probability of
>getting paid the full amount.  For "paid out of profits" that probability
>is going to be about 2% (it would be higher, but still quite low, if you
>were talking about payment out of gross revenues instead), so if your
>normal hourly rate was $75/hr (pretty much the absolute low end for the
>kind of skills Mr. Seiler needs), you'd need a rate of $3750/hr!
>
>As you alluded to, those who *have* made substantial amounts of money from
>spec work did so by taking equity positions (shares of ownership in the
>company) in return for work, and then cashed in their shares when the
>company went public.  But there are signs that the stock market is losing
>its automatic infatuation with anything that has a .com in it, and that
>in the near future the only Internet ventures that will provide
>spectacular returns on going public are going to be those that establish
>a solid business track record while privately owned.
>
>To look at it another way, spec work is the equivalent of investing the
>amount of money that you'd normally bill for the time you spent.  You
>need to evaluate such propositions the same way you would any other
>investment.  Most offers of spec work represent extremely poor investments.
>




------------------------------

Date: Mon, 27 Sep 1999 13:52:49 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Looking for Downloadscript
Message-Id: <37EFD921.548EC7BB@mail.cor.epa.gov>

Ilia Benderski wrote:
> 
> Help!
> I"m lookink for download script.
> I want, that script downloads files from Internet to my Computer
> (Linux).

Since you weren't specific, I'll have to guess about exactly 
what you want [my PSI::ESP module is on the blink again].

You probably want to check into the LWP::Simple and/or
LWP::UserAgent modules.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Mon, 27 Sep 1999 12:22:27 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Multiple Option
Message-Id: <37EFC3F2.6F70369@cisco.com>

[ webmaster wrote:

> Can someone help me and tell me how to handle multiple selection from a
> dropbox in my form?

Depends on how you are writing your server side script. If you are NOT
using CGI.pm your script should consider the fact that there might
be more than one name/value pair with the same name and handle it
correctly. If you are using CGI.pm this is done automatically for you.
eg. @values = $cgiobject->param ('x')
is how you get all values for all CGI param with name = 'x'.

--



------------------------------

Date: Mon, 27 Sep 1999 13:36:33 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Parsing @argv
Message-Id: <x3yk8pcuuhq.fsf@tigre.matrox.com>


Brian Orpin <abuse@borpin.demon.co.uk> writes:

> Is there a simple way of parsing @ARGV?  I am sure that I have seen a
> parse-argv module in the past but can find no reference to it (but may
> not have looked in the right place).

You mean the Getopt::Std and the Getopt::Long modules? They are part
of the standard Perl distribution.

Personally, I never used those modules. I find it easier (and probably
faster) to write up my own parse_args() subroutine. Although I am
thinking of writing up my own Getopt module .. hmm... 

HTH,
--Ala



------------------------------

Date: Mon, 27 Sep 1999 12:17:58 -0700
From: Spencer Lamoreaux <r37116@email.sps.mot.com>
Subject: Passing info to CGI's in the URL
Message-Id: <37EFC2E6.5C3F08A5@email.sps.mot.com>

I have seen people pass information to cgi scripts in the url such as
 .../website/mycgi.cgi?id=89

How do you do this? Currently, I am embedding hidden information such as
<input type = "hidden" value...etc into the HTML file so that it will
pass the correct info to the scripts. However, it would be nice to have
one url that does it all so I could bypass certain web pages. (For
example, if you bookmark some of my pages, you will not be able to
access them later since the data must be passed from the previous web
page.)

HELP!
Thanks in advance.
-Spencer Lamoreaux


------------------------------

Date: Mon, 27 Sep 1999 14:58:58 -0500
From: Michael Frost <msfrost@celluloidnexus.com>
To: Spencer Lamoreaux <r37116@email.sps.mot.com>
Subject: Re: Passing info to CGI's in the URL
Message-Id: <37EFCC82.7479C081@celluloidnexus.com>

It's all based on your METHOD as listed in your <FORM> tag. The url-passed
parameters come from a GET method form. When you use the POST method, all
parameters come via standard input. The GET method can be especially useful
when you want to use a hypertext link into a cgi-bin, rather than having to
"turn-the-crank" by clicking a submit button. Careful though, the GET method
is a little less secure since the user can change the passed parameters just
by changing the URL. I believe the standard suggestion is to turn on the
taint flag. Check Chapter 6 of the Camel book for more info on playing it
safe.

Spencer Lamoreaux wrote:

> I have seen people pass information to cgi scripts in the url such as
> .../website/mycgi.cgi?id=89
>
> How do you do this? Currently, I am embedding hidden information such as
> <input type = "hidden" value...etc into the HTML file so that it will
> pass the correct info to the scripts. However, it would be nice to have
> one url that does it all so I could bypass certain web pages. (For
> example, if you bookmark some of my pages, you will not be able to
> access them later since the data must be passed from the previous web
> page.)
>
> HELP!
> Thanks in advance.
> -Spencer Lamoreaux





------------------------------

Date: Mon, 27 Sep 1999 20:33:17 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Passing info to CGI's in the URL
Message-Id: <hwQH3.2144$J66.242745@typ11.nn.bcandid.com>

In article <37EFCC82.7479C081@celluloidnexus.com>,
Michael Frost  <frostm@us.ibm.com> wrote:
>It's all based on your METHOD as listed in your <FORM> tag. The url-passed
>parameters come from a GET method form. When you use the POST method, all
>parameters come via standard input. The GET method can be especially useful
>when you want to use a hypertext link into a cgi-bin, rather than having to
>"turn-the-crank" by clicking a submit button. Careful though, the GET method
>is a little less secure since the user can change the passed parameters just
>by changing the URL.

The user can change the passed parameters for a POST method just by
changing the string they send.  The most convenient way for them to do
this is generally to save your HTML form to a file, edit it, and load
the edited version in their browser.

If you are relying on the parameters being restricted by your form for
security, you are in trouble regardless of what method you use.

The most important distinction between GET and POST is that GET is
supposed to not cause things to happen.  A browser or a cache is free
to resend GET requests whenever they want.  If running the same GET
request twice would cause a problem, it needs to be a POST request.

Another distinction, of course, is that GET queries can be embedded in
hotlinks -- so someone who sends a GET request may have come from
anywhere and may not be aware that, from your script's point of view,
they're "submitting a form".

> I believe the standard suggestion is to turn on the taint flag.

That's one thing you should definitely do.

> Check Chapter 6 of the Camel book for more info on playing it
>safe.

Check also the WWW security FAQ and the CGI security FAQ, which I
posted links to yesterday.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Sep 27 1999
42 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Mon, 27 Sep 1999 13:43:43 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: pattern matching problem
Message-Id: <x3yiu4wuu5s.fsf@tigre.matrox.com>


Gregory Geller <gregg@scad.edu> writes:

> Can someone out there tell me what I am overlooking?

I don't know. I haven't been able to reproduce your problem. But, you
should probably not be using $5 as the variable you want to match
against. The reason, as is indicated in perlre, is:

                     The scope of $<digit> (and $`, $&, and $')
     extends to the end of the enclosing BLOCK or eval string, or
     to the next successful pattern match, whichever comes first.

So you might be undefining some of your variables unintentionally.

HTH,
--Ala



------------------------------

Date: Mon, 27 Sep 1999 12:36:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching problem
Message-Id: <MPG.1259671941e621fa989fe5@nntp.hpl.hp.com>

In article <37EF8659.D708BC5D@scad.edu> on Mon, 27 Sep 1999 10:59:37 -
0400, Gregory Geller <gregg@scad.edu> says...
 ...
+ if ($5 !~ /MAC/i) { next; }
+ .
+ .
+ }
+ 
+ This works fine.  I end up processing only the lines that contain
+ "MAC" in field $5.  But if I do:
+ 
+ $type = "MAC";
+ 
+ while(<>) {
+ .
+ .
+ if ($5 !~ /$type/i) {next; }
+ .
+ .
+ }
+ 
+ This results in the program not processing any lines.  Apparently the
+ if statement evaluates to 1 every time.  I've looked
+ at the Programming Perl book and it seems that I should be able to do
+ this, but it's not working the way I expect.
+ 
+ Can someone out there tell me what I am overlooking?

Everything in Greg Bacon's response is correct and worth considering.  
However, he doesn't deal with your principal issue, which is why the 
literal regex works but the one with the interpolated string doesn't.

If the facts are exactly as you state, the interpolated regex should 
behave exactly the same as the literal one.  Examine the value of $type 
very carefully.  Do such tests as length($type) == 3, and look at the 
output of unpack('H*', $type).  If there are exactly the three 
characters 'M', 'A', and 'C', and nothing else, something is seriously 
amiss with your Perl installation.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 27 Sep 1999 13:43:34 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Q on file rights for CGI process
Message-Id: <Pine.GSO.4.10.9909271341470.26916-100000@user2.teleport.com>

On Sun, 26 Sep 1999 tavi367@ibm.net wrote:

> I have a CGI Perl script that runs fine on my NT, it runs fine from the
> infoboard shell prompt, but it fails when run as a CGI process.

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.cpan.org/
   http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
   http://www.cpan.org/doc/manual/html/pod/

> As CGI Process, the script:
>   - creates the file
>   - places data in the file
>   - it can not read data from the file.

Does that mean that open() failed? What error message did you find in $!
when you checked the return value from open?

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 27 Sep 1999 19:17:54 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: Question About the last command
Message-Id: <7soft2$5ee$4@info2.uah.edu>

In article <7sod82$mpo$1@nnrp1.deja.com>,
	reedjd@bitsmart.com writes:

: TEST: {
:   $LET = "A",
:     last TEST if $HOSTNAME eq "http://www.yahoo.com";
:   $LET = "B",
:     last TEST if $HOSTNAME eq "http://www.excite.com";
: }
: 
:   So my question about this is... are the assign statements being run
: before the last statement, or after?

Did you read the docs?  Did you try some simple test cases?

:   In the script there are about 100 of these total, and I'm wondering
: if we're doing a whole bunch of unneeded assign statements in here or
: not.

Why don't you just use a hash?  It would be much easier on the eyes:

    my %url2let = (
        'http://www.yahoo.com'  => 'A',
        'http://www.excite.com' => 'B',
        ...,
    );

    my $let = $url2let{$HOSTNAME};

Greg
-- 
God does not play dice with the universe.  -- Albert Einstein
Who are you to tell God what to do?        -- Niels Bohr


------------------------------

Date: Mon, 27 Sep 1999 20:24:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Question About the last command
Message-Id: <QnQH3.2127$J66.241015@typ11.nn.bcandid.com>

In article <7sod82$mpo$1@nnrp1.deja.com>,  <reedjd@bitsmart.com> wrote:
>I've been QAing a script someone wrote and they're using a syntax with
>the last command I've never seen before, and I'm a little confused how
>it works.  So here's a quick example:
>
>TEST: {
>  $LET = "A",
>    last TEST if $HOSTNAME eq "http://www.yahoo.com";
>  $LET = "B",
>    last TEST if $HOSTNAME eq "http://www.excite.com";
>}

The first statement is equivalent to:
if ($HOSTNAME eq "http://www.yahoo.com") {
	$LET = "A", last TEST;
}

last TEST goes to the end of the block labeled as TEST.

The comma in this context is equivalent to a semicolon, except that it
allows both expressions to be part of the same statement.

>  So my question about this is... are the assign statements being run
>before the last statement, or after?

Before.

>  In the script there are about 100 of these total, and I'm wondering
>if we're doing a whole bunch of unneeded assign statements in here or
>not.

There are simpler ways to do this one, as Greg Bacon pointed out.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Sep 27 1999
42 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Mon, 27 Sep 1999 13:04:49 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Randomize array.....
Message-Id: <x3yln9suvym.fsf@tigre.matrox.com>


"HKS" <hks3@usa.net> writes:

> i just learning perl for couple of days, and i encountered a problem on
> randomize the array elements and put the result into another
> array... 

see perlfaq4:
	How do I shuffle an array randomly?

> i tried using "srand and rand" ..it works, but sometimes i had the same
> number in the "@result" array.. (e.g "2,3,5,2,1,6") which i dont want.  is
> there any way i can make sure the result will not contain any duplicate
> numbers?

Does your initial array contain duplicate numbers?
If not, then the above faq will solve your problem.
If it does, then have another look at perlfaq4:

	How can I extract just the unique elements of an array?

HTH,
--Ala



------------------------------

Date: Mon, 27 Sep 1999 14:04:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Randomize array.....
Message-Id: <37EFDBC0.1015C762@mail.cor.epa.gov>

[BTW, please post *after* the text, rather than before it.
That way, we can have 'threads' in the newsgroup.  This way
it is like reading 'Jeopardy'.  TIA.]

HKS wrote:
> Yanick Champoux ¼¶¼g©ó¤å³¹ ...
[snip]
> >@result = sort By_Random @array;
> >sub By_Random
> >{
> >  return (-1,1)[rand(2)];  # return -1 or 1 at random
> >}
> >
> >print join ' ', @result, "\n";
> 
> ok, thx, even though i'm not quite understand some of the code and concept..

Ooh.  Bad choice.  This is about the only code in this thread
which you should actively avoid.  Some *good* code is listed
in the FAQ, which should be on your hard drive where you
installed Perl.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: 27 Sep 1999 13:36:41 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: remove the html tag in the file
Message-Id: <m1wvtchz1i.fsf@halfdome.holdit.com>

>>>>> "Dan" == Dan Sugalski <dan@tuatha.sidhe.org> writes:

Dan> That'd be kinda tough at this point. Perl's regexes are Turing-complete,
Dan> after all. (Anyone care to rewrite GCC as a regex? :)

I'm beginning to think that a "YACC-to-Perl" translator could possibly
rewrite the entire YACC grammar and associated actions as a *single*
regex using either 5.5 or perhaps 5.6 Perl.  The embedded (?{ ... })
blocks would allow the actions.

Your whole program would be driven by a single regex match then:

    $parser = qr{
      ... translator goes here ...
    };
    undef $/;
    while (<>) {
	    m/$parser/ or die "cannot parse $_: $@";
	    ## use variables set during the parse here
    }

:-)

/(?{print "Just another Perl hacker,"})/

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Mon, 27 Sep 1999 20:42:50 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: remove the html tag in the file
Message-Id: <eFQH3.1867$Af7.36082@news.rdc1.ct.home.com>

Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Dan" == Dan Sugalski <dan@tuatha.sidhe.org> writes:

> Dan> That'd be kinda tough at this point. Perl's regexes are Turing-complete,
> Dan> after all. (Anyone care to rewrite GCC as a regex? :)

> I'm beginning to think that a "YACC-to-Perl" translator could possibly
> rewrite the entire YACC grammar and associated actions as a *single*
> regex using either 5.5 or perhaps 5.6 Perl.  The embedded (?{ ... })
> blocks would allow the actions.

> Your whole program would be driven by a single regex match then:

[Snippage]

> :-)

Sure, why not? :)

Of course, then you have to ask yourself--when racing the heat death of
the universe, who'd win, your script or the universe? ;-P

					Dan


------------------------------

Date: Mon, 27 Sep 1999 20:53:57 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Replacement "CD" for win32 systems
Message-Id: <FPQH3.2170$J66.246047@typ11.nn.bcandid.com>

In article <37ef5cbd_2@newsread3.dircon.co.uk>,
Jonathan Stowe  <gellyfish@gellyfish.com> wrote:
>You cannot write a replacement CD with Perl (or
>indeed any language) without creating a whole new shell - that is why
>CD is invariably a shell builtin of any system that has the notion of
>directories such as MSDOS and Unix - well you could but it would involve
>exec'ing a new shell after each directory change ...

I believe MSDOS actually does let you spawn a program that will change
your current directory, although I may be mistaken; I seem to remember
several "enhanced" cd commands from my pre-Unix days (before 1992).
Early Unix, also, would have had no problem with this; around 1970 or
1971, according to my memory of the "history of C" article from HOPL
II, each non-shell command returned control to the shell by execing the
shell.

I also believe Plan9 and BSD allow you to rfork() a program such that
you share a current directory with it, but nothing else.  In principle,
this would allow execution of an "enhanced cd" program, but I don't
think the shells have a builtin that allows this.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Sep 27 1999
42 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


------------------------------

Date: Mon, 27 Sep 1999 21:02:32 GMT
From: NOraydunnSPAM@canada.com (Ray Dunn)
Subject: Re: Replacement "CD" for win32 systems
Message-Id: <IXQH3.168$iG2.5865@client>

In referenced article, Kragen Sitaker says...
>I believe MSDOS actually does let you spawn a program that will change
>your current directory, although I may be mistaken;

You are correct.

-- 
Ray Dunn
Montreal
raydunn@canada.com



------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 922
*************************************


home help back first fref pref prev next nref lref last post