[10631] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4223 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 15 13:07:12 1998

Date: Sun, 15 Nov 98 10:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 15 Nov 1998     Volume: 8 Number: 4223

Today's topics:
        A Newbie That Needs Some Quick Help <just_the_man@hotmail.com>
    Re: A Newbie That Needs Some Quick Help <r28629@email.sps.mot.com>
    Re: A Newbie That Needs Some Quick Help (Larry Rosler)
    Re: A Newbie That Needs Some Quick Help (Tad McClellan)
    Re: allowed index variables in foreach loops <r28629@email.sps.mot.com>
    Re: allowed index variables in foreach loops <ghira@mistral.co.uk>
    Re: allowed index variables in foreach loops (Larry Rosler)
        changing formvalues <ours@casema.net>
    Re: changing formvalues <r28629@email.sps.mot.com>
    Re: Difference between netscape and microsoft cgi handl <crawford@dcrawford.com>
    Re: download never finishes <rbank@csf.edu>
        form with default values <prauz@sprynet.com>
    Re: Help Wanted:  Perl CGI Programming, etc. (Kal Kolberg)
        How do I check for a valid URL Rafely@xxiname.com
    Re: How do I check for a valid URL (Matt Knecht)
        I/O with Perl <crawford@dcrawford.com>
    Re: iis 4 problem with perl .... <steve@straytravel.com>
        Just a quick debugging problem..... <hutcheon@iaw.on.ca>
    Re: Just a quick debugging problem..... (Larry Rosler)
    Re: Just a quick debugging problem..... (Tad McClellan)
        New directories and regexps. <john.wood@diamond.co.uk>
    Re: New directories and regexps. (Tad McClellan)
    Re: New directories and regexps. (Matthew Bafford)
    Re: New directories and regexps. (Larry Rosler)
    Re: Newbie getopts() questions <r28629@email.sps.mot.com>
        Not deleting correctly... <anthony@nova-creations.com>
    Re: Not deleting correctly... <J.D.Gilbey@qmw.ac.uk>
        NT/Unix (Ben Walker)
        Perl script for changing page every day <tehan@online.no>
    Re: Perl script for changing page every day (Kal Kolberg)
    Re: Q: are symbolic refs really needed (was Re: Modific (Bart Lateur)
    Re: SIMPLE BLOWFISH IN PERL? (Kal Kolberg)
        testing problems <johnga@primenet.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sun, 15 Nov 1998 02:22:40 -0800
From: Lee <just_the_man@hotmail.com>
Subject: A Newbie That Needs Some Quick Help
Message-Id: <364EAB70.3B48@hotmail.com>

Hi, i'm a total newbie to Perl, i've read a "Perl By Example" Book,
but i'm not so hot with the lang. yet.  Anyways, I'm currently 
coding for a MUD (in C) but i just added in a new stat and this
needs to be updated in all the area files. I need to create a Perl
script that will automatically update the files. However, due to
the differences in each file and how the delimiter pattern isn't always
the same, I need a better method. I hope someone can help me out. Thank
you.

My idea is to find the field that has one of the variables of race,
the use s// to put in the value for the line after. If you need a
sample of an area file, i can send one to you. It would be greatly
apprecciated if someone could help.  Thanks again.


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

Date: Sun, 15 Nov 1998 10:02:48 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: just_the_man@hotmail.com
Subject: Re: A Newbie That Needs Some Quick Help
Message-Id: <364EED18.14124985@email.sps.mot.com>

Lee wrote:
> 
> Hi, i'm a total newbie to Perl, i've read a "Perl By Example" Book,
> but i'm not so hot with the lang. yet.  Anyways, I'm currently

We are only a bunch of very-hot-with-this-lang people trying to help the same
kind of people here. if you are not-so-hot about this lang, than I suggest you
leave this ng alone.

-tk


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

Date: Sun, 15 Nov 1998 08:53:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A Newbie That Needs Some Quick Help
Message-Id: <MPG.10b8a6cbbb82ef90989909@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <364EED18.14124985@email.sps.mot.com> on Sun, 15 Nov 1998 
10:02:48 -0500, Tk Soh <r28629@email.sps.mot.com> says...
> Lee wrote:
> > 
> > Hi, i'm a total newbie to Perl, i've read a "Perl By Example" Book,
> > but i'm not so hot with the lang. yet.  Anyways, I'm currently
> 
> We are only a bunch of very-hot-with-this-lang people trying to help the same
> kind of people here. if you are not-so-hot about this lang, than I suggest you
> leave this ng alone.

Totally wrong-headed attitude!  We are all here to learn, with varying 
temperatures.

Don't drive away newcomers who have legitimate questions.  Too bad 
that the post you tried to blow off was too vague to allow us to be more 
helpful.

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


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

Date: Sun, 15 Nov 1998 12:02:21 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A Newbie That Needs Some Quick Help
Message-Id: <dv4n27.1v9.ln@flash.net>

Tk Soh (r28629@email.sps.mot.com) wrote:
: Lee wrote:
: > 
: > Hi, i'm a total newbie to Perl, i've read a "Perl By Example" Book,
: > but i'm not so hot with the lang. yet.  Anyways, I'm currently

: We are only a bunch of very-hot-with-this-lang people trying to help the same
: kind of people here. if you are not-so-hot about this lang, than I suggest you
: leave this ng alone.


   That is simply not true.

   This newsgroup if for discussion of Perl programming.

   There is no "I'm hot with Perl" requirement.

   There is, however, a "I tried my best to find the answer on my
   own before posting" requirement.



   I have seen Tk posting here often, and am very surprised to
   hear that this is the perception of a clueful individual.

   It is usually the newbies that get it wrong like that.

   Do not follow his/her suggestion to leave this ng alone.

   If you tried (word search the standard docs, and search the ng
   at www.dejanews.com) to find the answer yourself, and came up
   short, please feel free to ask here.



   Lee did not give enough information to allow us to help him/her.

   Include a _small_ sample of what the input data looks like,
   and a sample of what you want the output data to look like.

   Then we might have enough to work with.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 15 Nov 1998 10:15:57 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Adam Atkinson <ghira@mistral.co.uk>
Subject: Re: allowed index variables in foreach loops
Message-Id: <364EF02B.A3161AD7@email.sps.mot.com>

Adam Atkinson wrote:
> 
> I've only just noticed that you can't do something like this:
> 
> foreach $a[0] (1..$n) {
> print $a[0];
> }
> 
> it says the foreach line is a syntax error
> 
> but
> 
> foreach (1..$n) {
> $a[0]=$_;

you are creating an array variable (@a, if not already created) an assign $_
to its zero-th element.

you could have said (and should have known this):

foreach (1..$n) {
   print;
}

> print $a[0];
> }
> 
> seems to be fine.
> 
> I've looked in the llama and the camel (and the FAQ) and they say
> that the loop variable needs to be a scalar. well, $a[0] may be an
> element of an array, but it IS a scalar value, surely?
> 
> Obviously, this isn't a real problem since I can use a normal foreach
> loop and assign to my array element inside the loop.
> 
> Still, I'm curious.. am I missing something here? Is this a design
> decision? Or am I doing something wrong?
> 
> (I have a set of nested foreach loops, each of which controls one
> element in an array. Then in the middle, the array is checked for a
> property I'm interested in. I originally wanted each foreach loop to
> say
> 
> foreach $a[3] (@list3) {
> ...
> 
> }

I trust you know what you should do here.

> I have various @list arrays containing lists of permitted values for
> each element of the array.
>
> Presumably I can't use hash entries as foreach control variables
> either.

Use the language correctly (as you learned from the Llama book), don't test it
- unless that's your objective.

-tk


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

Date: 15 Nov 98 17:00:04 +0000
From: "Adam Atkinson" <ghira@mistral.co.uk>
Subject: Re: allowed index variables in foreach loops
Message-Id: <1792.623T219T10202252@mistral.co.uk>

On 15-Nov-98 15:15:57, Tk Soh said:

>> I've only just noticed that you can't do something like this:
>> 
>> foreach $a[0] (1..$n) {
>> print $a[0];
>> }
>> 
>> it says the foreach line is a syntax error
>> 
>> but
>> 
>> foreach (1..$n) {
>> $a[0]=$_;

>you are creating an array variable (@a, if not already created) an assign $_
>to its zero-th element.

indeed I am

>you could have said (and should have known this):

>foreach (1..$n) {
>   print;
>}

absolutely. naturally the above fragment isn't my actual program, it's
just a minimal extract of it which suffices to exhibit what I'm
talking about.

>> foreach $a[3] (@list3) {
>> ...
>> 
>> }

>I trust you know what you should do here.

well, what I _currently_ do is

foreach (@list3) {
$a[3]=$_;

 ...

}

>Use the language correctly (as you learned from the Llama book), don't test
>it
>- unless that's your objective.

Am I really being so bad?

foreach $i (@wibble) {

}

is perfectly ok, after all.

I wasn't aiming to "test" the language... in the middle of my nested
loops, I do things with an array @a. each layer of the loop assigns
values to one element of the array. since "foreach $i
(@permitted_values)" is ok, I'd assumed "foreach $a[0]
(@permitted_values)" would be too - it would mean I wouldn't have to
have assigns just after each "foreach" line. after all, $a[0] is a scalar
value - it may be an element of an array, but it is a scalar (rather
than (say) an array slice of length one), and that's what the Llama
says you can put as a foreach control value. Obviously, now that I know
I can't do this, I won't.

I was curious, though. Why is this not permitted?

-- 
Adam Atkinson (ghira@mistral.co.uk)
"Let's catch that sick bird" he said, illegally.



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

Date: Sun, 15 Nov 1998 09:50:13 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: allowed index variables in foreach loops
Message-Id: <MPG.10b8b42c35a5ccae98990c@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <1792.623T219T10202252@mistral.co.uk> on 15 Nov 98 17:00:04 
+0000, Adam Atkinson <ghira@mistral.co.uk> says...
 ... 
>    in the middle of my nested
> loops, I do things with an array @a. each layer of the loop assigns
> values to one element of the array. since "foreach $i
> (@permitted_values)" is ok, I'd assumed "foreach $a[0]
> (@permitted_values)" would be too - it would mean I wouldn't have to
> have assigns just after each "foreach" line. after all, $a[0] is a scalar
> value - it may be an element of an array, but it is a scalar (rather
> than (say) an array slice of length one), and that's what the Llama
> says you can put as a foreach control value. Obviously, now that I know
> I can't do this, I won't.
> 
> I was curious, though. Why is this not permitted?

`perldoc perlsyn`:
---
The foreach loop iterates over a normal list value and sets the variable 
VAR to be each element of the list in turn.  If the variable is preceded 
with the keyword my, then it is lexically scoped, and is therefore 
visible only within the loop. Otherwise, the variable is implicitly 
local to the loop and regains its former value upon exiting the loop.
If the variable was previously declared with my, it uses that variable 
instead of the global one, but it's still localized to the loop.
---

Note that VAR must be a 'variable' that can be declared (and if not 
declared, is implicitly declared local to the loop).  $a[0] is a scalar, 
but cannot be declared.  (@a can be declared, but is not a scalar.)

I don't have the Llama at home to check, but it intends to be tutorial 
rather than precise in any case.  The quote above from 'perlsyn' isn't 
all that clear either, but the answer can be parsed out of it.

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


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

Date: Sun, 15 Nov 1998 14:41:03 +0100
From: "Casema" <ours@casema.net>
Subject: changing formvalues
Message-Id: <72mlo7$190$1@sun4000.casema.net>

Can man dynamically change values from <INPUT TYPE="TEXT"> from a Perl
script?
Like pressing a button would search my database and pass the found content
into a textbox, so I do not have to push a new form to the browser?

Michel




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

Date: Sun, 15 Nov 1998 10:21:13 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Casema <ours@casema.net>
Subject: Re: changing formvalues
Message-Id: <364EF167.8C9DA292@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Casema wrote:
> 
> Can man dynamically change values from <INPUT TYPE="TEXT"> from a Perl
> script?
> Like pressing a button would search my database and pass the found content
> into a textbox, so I do not have to push a new form to the browser?
> 
> Michel

you really should post these web-programming questions to the web-programming
ng. Using Perl for web-programming doesn't quite make them suitable for this
ng. (Make not mistake, I use perl for my CGI programming too)

-tk


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

Date: Sun, 15 Nov 1998 11:05:44 -0500
From: Dave Crawford <crawford@dcrawford.com>
Subject: Re: Difference between netscape and microsoft cgi handling?????
Message-Id: <364EFBD8.3252208D@dcrawford.com>

I'm led to believe you're have a mime type/file extension problem. Try
renaming the file to test.cgi or test.pl.

-Dave
Casema wrote:
> 
> I created a a simple test.bat in my cgi-bin directory on
> 195.166.50.141/cgi-bin/
> 
> now, when I open this in netscape nav. it does what I hoped.
> In ie it runs the stupid thing on my computer instead of on the server....
> why is this????
> to try use this: http://195.166.50.141/cgi-bin/test.bat
> I am pulling my hair out by now.
> Are there any standards on the .... net?
> 
> Thanks for supporting me,
> 
> Michel


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

Date: Sat, 14 Nov 1998 12:34:02 -0700
From: "Robin Bank" <rbank@csf.edu>
Subject: Re: download never finishes
Message-Id: <364de1ba.0@news.globalpac.com>

instead of printing each individual line, use this - 
print<<EOF;
All of your html code
blah 
blah 
blah
EOF

That should work better...

Cheers,

Robin
******|
------| rbank@csf.edu
******|


----------
In article <72kg79$8uh$1@sun4000.casema.net>, "Casema" <ours@casema.net>
wrote:


>how come when printing HTML to a browser, using PERL
>the gauge meter never stops?
>I mean, "document done" is a message that seems never to appear....
>
>print "content-type: text/html", "\n\n";
>print "<HTML><BODY>\n";
>print "TEST";
>print "</BODY></HTML>";
>
>above the testcode......
>is there a "document-done" statement I could/should use?
>
>thanks,
>
>Michel
>
>
>
>


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

Date: Sun, 15 Nov 1998 12:45:16 +0000
From: Balazs Rauznitz <prauz@sprynet.com>
Subject: form with default values
Message-Id: <364ECCDC.61CB8B31@sprynet.com>

Please make suggestion as which would be the most elegant way to do
this:

Right now I have a registration form for users, which is generated with
a perl script that uses templates (actually 4 templates as the site is
quad-lingual). I want to have a page where users can change their data,
so the same form should come up, but with the values(coming from a
database) already filled in. I was thinking about creating a query file,
but I guess in this case I'd need to rewrite the script to use 
print $q->textfield( .... ) instead of just plugging in variables to the
form. The best would if there was a script, that took an html file/form
as input and wrote out the same file except generating the form elements
with module CGI.

Thanks for any help:

Balazs


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

Date: Sun, 15 Nov 1998 13:17:01 GMT
From: kkolberg@att.com (Kal Kolberg)
Subject: Re: Help Wanted:  Perl CGI Programming, etc.
Message-Id: <364ed3ee.129635406@news.netnews.att.com>

Interesting:  recruiting method, Join us, spend your time and effort
working for us for free, but doesn't leave a url to even look at this
site of his...

Kal 

On Sun, 15 Nov 1998 07:27:06 GMT, ehpoole@ingress.com (Ethan H. Poole)
wrote:

>In article <72loks$u67$1@ostrich.cybercomm.net>, alsoft@cybercomm.net says...
>> * An anti-crack protection CGI script (and modules for several windows
>>programming languages), which would make it possible for windows programmers
>>to make applications that are completely piracy/crack-proof.
>
>Nothing like asking for the impossible, aye?
>
>-- 
>Ethan H. Poole              | Website Design and Hosting,
>                            | CGI Programming (Perl & C)..
>========Personal=========== | ============================
>* ehpoole @ ingress . com * | --Interact2Day--
>                            | http://www.interact2day.com/
>



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

Date: Sun, 15 Nov 1998 16:11:21 GMT
From: Rafely@xxiname.com
Subject: How do I check for a valid URL
Message-Id: <364efc65.29311866@news.iaehv.nl>

Hello,

I'm making a script where someone has to enter their e-mail address
and their URL. For the e-mail check I'm using Matt Wright's method:

if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
   $email !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)
   {&Error;}

I want to use a similar method for checking for a valid URL. All I
could think of is this:

if ($url !~ /^http:\/\/.+\..+/i) {&Error;}

I know there are a lot of you that think that this is useless because
you can NEVER prevent someone of typing a valid URL that's not theirs!
But still want to do it.

My question is, does anyone have a method for checking for a valid
URL? Maybe you're using one in a script or you've seen one in a script
somewhere!

Many Thanks,

Rafely
Rafely@xxiname.com


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

Date: Sun, 15 Nov 1998 16:44:11 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: How do I check for a valid URL
Message-Id: <vxD32.32756$%X2.4805635@news3.voicenet.com>

Rafely@xxiname.com <Rafely@xxiname.com> wrote:
>
>My question is, does anyone have a method for checking for a valid
>URL? Maybe you're using one in a script or you've seen one in a script
>somewhere!

Abigail posted a pretty exaustive regex that deals with validating an
URL.  Check dejanews with with a search string of
"~g comp.lang.perl.misc ~a Abigail ~s Counting URLs".

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: Sun, 15 Nov 1998 10:47:37 -0500
From: Dave Crawford <crawford@dcrawford.com>
Subject: I/O with Perl
Message-Id: <364EF799.17B3001E@dcrawford.com>

Could someone point me to some information on how (if possible) to
'read' the individual pins on the parallel port with Perl under Linux. I
am currently fooling around with data acquisition under Windows with a
Visual Basic interface and would love to move it to my Linux machine.
Thanks in advance.

-Dave


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

Date: Sun, 15 Nov 1998 13:01:18 -0000
From: "Steve Harris" <steve@straytravel.com>
Subject: Re: iis 4 problem with perl ....
Message-Id: <72mjrb$an9$1@newnews.global.net.uk>

What version of perl are you using.?

I have found this problem too on version 5.005 on iis3 however 5.005 works
ok on iis4.
Maybe related.
Try a prevoius version.Afraid that was my only fix unless someone can offer
a more in depth explination.

steve


Brent Michalski wrote in message <364E408E.1A1531C@technologist.com>...
>George Statis wrote:
>>
>> I installed ActiveWare's perl on an NT server machine runing options pack
4
>> .....
>>
>> I have tryed to test perl by puting the script bellow on the cgi-bin
>> directory of the server ...
>..SNIP..
>> the script works fine if i run it from the command prompt
>> but if I try to run it from the server I get the following msg ...
>>
>> -------------------------------------------------------------------------
---
>> CGI Error
>> The specified CGI application misbehaved by not returning a complete set
of
>> HTTP headers. The headers it did return are:
>>
>> hello
>> -------------------------------------------------------------------------
---
>> what could be wrong ????????
>> can anybody help me with that ???
>
>You need to set up IIS to recognize Perl.
>
>Go to: http://www.access.digex.net/~jurlwin/ and look under the "Hints
>to get CGI under NT/95 running" section.
>
>Good luck!
>Brent
>--
>Java?  I've heard of it, it is what I drink while hacking Perl! -me
>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
>$            Brent Michalski             $
>$         -- Perl Evangelist --          $
>$    E-Mail: perlguy@technologist.com    $
>$ Resume: http://www.inlink.com/~perlguy $
>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$




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

Date: Sun, 15 Nov 1998 10:48:08 -0500
From: "Tyler Hutcheon" <hutcheon@iaw.on.ca>
Subject: Just a quick debugging problem.....
Message-Id: <72mtbk$58o$1@supernews.com>

Hi.

I'm no beginner to programming perl, but I've found one problem that I can't
find the answer to.
Here is what perl is reporting the problem to be.

Use of uninitialized value at index.cgi line 52.
Use of uninitialized value at index.cgi line 70.

If anyone knows what this is, pleez tell me.

Tyler Hutcheon
hutcheon@iaw.on.ca
http://www.iaw.on.ca/~hutcheon/






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

Date: Sun, 15 Nov 1998 09:08:51 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Just a quick debugging problem.....
Message-Id: <MPG.10b8aa7f72d7cc6298990a@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <72mtbk$58o$1@supernews.com> on Sun, 15 Nov 1998 10:48:08 -
0500, Tyler Hutcheon <hutcheon@iaw.on.ca> says...
 ... 
> Use of uninitialized value at index.cgi line 52.
> Use of uninitialized value at index.cgi line 70.
> 
> If anyone knows what this is, pleez tell me.

Even in Canada, that is not how one spells 'pleez', eh?

It means that you are using an uninitialized value at lines 52 and 70.

It also means that you are using the '-w' flag, which is *good*.  Now if 
you add 'use strict;' at the front of your program (which will force you 
to declare all your variables), you may discover a typo where you assign 
a value to a variable but try to use it later with a different spelling.

Unless you submit a short code segment that displays the problem, no one 
here can help you further.  Our crystal balls are cloudy.

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


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

Date: Sun, 15 Nov 1998 12:04:27 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Just a quick debugging problem.....
Message-Id: <b35n27.1v9.ln@flash.net>

Tyler Hutcheon (hutcheon@iaw.on.ca) wrote:

: I'm no beginner to programming perl, but I've found one problem that I can't
: find the answer to.
: Here is what perl is reporting the problem to be.

: Use of uninitialized value at index.cgi line 52.
: Use of uninitialized value at index.cgi line 70.

: If anyone knows what this is, pleez tell me.


   Uhhh. 

   It means you are using an uninitialized value on lines 52 and 70.

   We kinda need to see the code to fix the code...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 15 Nov 1998 16:18:50 -0000
From: "Paul Wood" <john.wood@diamond.co.uk>
Subject: New directories and regexps.
Message-Id: <72muoh$k8f$1@nclient3-gui.server.ntli.net>

Two main problems here. They're probably easily solved, but i'm new to Perl
so i'm still struggling.

First problem:
My script creates new directories like this,

 mkdir ("$form_results{'name'}",0777) or die "can't open dir
$form_results{'name'}: $!";

which works fine, but the owner is set as "nobody", so i can't touch them
afterwards. Is there any way that i get get them owned by myself? Chown
won't work - i get "operation not permitted".

The second problem is a regular expression:

I need a regexp that will only match if the string is between 4 and 20 word
characters long, beginning with A-Za-z .

I've tried this sort of thing,

/(^[A-Za-z]{1,})&&(\w{4,20})/g

but it isn't working...
Thanks in advance,

-Paul.




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

Date: Sun, 15 Nov 1998 11:52:41 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: New directories and regexps.
Message-Id: <9d4n27.9u9.ln@flash.net>

Paul Wood (john.wood@diamond.co.uk) wrote:
: Two main problems here. They're probably easily solved, but i'm new to Perl
: so i'm still struggling.


: The second problem is a regular expression:

: I need a regexp that will only match if the string is between 4 and 20 word
: characters long, beginning with A-Za-z .

: I've tried this sort of thing,

: /(^[A-Za-z]{1,})&&(\w{4,20})/g

: but it isn't working...


   1)
   That matches 7 to 23 characters:

      1 letter
      2 ampersands
      4-20 word chars


   2)
   Since you anchor to the beginning of the string, the m//g option
   will have no effect, so it should not be there. Unless $_
   contains a multiline string, in which case you also need the
   m//m option to allow the m//g to find more than one match.



   3)
   A "bare" character class matches one character anyway, so the {1,}
   is not needed.


   I think this should do it:

      m/^[A-Za-z]\w{3,19}/;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 15 Nov 1998 12:27:55 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: New directories and regexps.
Message-Id: <MPG.10b8d92a57f7a975989710@news.scescape.net>

In article <9d4n27.9u9.ln@flash.net>, Tad McClellan <tadmc@flash.net> 
pounded in the following:
=> Paul Wood (john.wood@diamond.co.uk) wrote:

[snip]

=> : /(^[A-Za-z]{1,})&&(\w{4,20})/g
=> 
=> : but it isn't working...
=> 
=> 
=>    1)
=>    That matches 7 to 23 characters:
=> 
=>       1 letter
=>       2 ampersands
=>       4-20 word chars
=> 

That matches 7 to Infinity characters:

at least 1 letter
2 ampersands
4-20 word chars

'{1,}' eq '+'

:-)

[snip]

=> 
=>    3)
=>    A "bare" character class matches one character anyway, so the {1,}
=>    is not needed.

See above.

[snip]

HTH,

--Matthew


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

Date: Sun, 15 Nov 1998 09:33:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: New directories and regexps.
Message-Id: <MPG.10b8b0468f39d9e998990b@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <72muoh$k8f$1@nclient3-gui.server.ntli.net> on Sun, 15 Nov 
1998 16:18:50 -0000, Paul Wood <john.wood@diamond.co.uk> says...
 ...
>  mkdir ("$form_results{'name'}",0777) or die "can't open dir
> $form_results{'name'}: $!";
> 
> which works fine, but the owner is set as "nobody", so i can't touch them
> afterwards. Is there any way that i get get them owned by myself? Chown
> won't work - i get "operation not permitted".

You need to have write permission for the directory in which the new 
directories are created.

BTW, in your example above, none of the four quotes in 
"$form_results{'name'}" is needed.

> I need a regexp that will only match if the string is between 4 and 20 word
> characters long, beginning with A-Za-z .
> 
> I've tried this sort of thing,
> 
> /(^[A-Za-z]{1,})&&(\w{4,20})/g

You can't put logic like && inside a regex.  It just means 'match two 
ampersand characters'.  Conjunction is achieved by two regexes, or by 
sequential successful matching:

  /^[A-Za-z]\w{3,19}$/
 
This regex will match locale-specific letters in any position except the 
first!  A neat way that I learned here to specify 'match any letter' is 
this:

    [^\W\d_]

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


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

Date: Sun, 15 Nov 1998 09:56:10 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Jang Choe <gt6786b@acmez.gatech.edu>
Subject: Re: Newbie getopts() questions
Message-Id: <364EEB8A.3DB7B63F@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Jang Choe wrote:
> 
> I'm using the module Getopt::Std for this. The filename is "tep"
> and this is basically my code:
> 
> use Getopt::Std;
> getopts('h');
> if (defined($opt_h) && $opt_h)
      ^^^^^^^^^^^^^^^^^^
if you have -h in the command line, $opt_h is guaranteed to have something,
so you don't need to test for it's definedness.

> {
>    ##do stuff here
> }
> 
> Now, when I type "tep -h" it will do the ##do stuff here part. but if I
> type something like "tep -asdf" it gives me error messages like "Unknown
> option: a" which you guys probably know it would.  But how would I write my
> code so it won't give me the error messages when I run the program with an
> unknown option?  Thanks.

use getopt() if you don't want to see the message. also, use getopt('h',
%opts) calling method, this save you some trouble when you 'use strict' later.

RTFM, the answers are all in there. Have you?

-tk


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

Date: Sun, 15 Nov 1998 13:16:08 GMT
From: "Anthony F. Sanchez" <anthony@nova-creations.com>
Subject: Not deleting correctly...
Message-Id: <364ED322.6065D4CB@nova-creations.com>


--------------4DEF8AB17609806481D17056
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi!

Can anyone tell me why my delete_user subroutine is deleting ALL THE
RECORDS, instead of the one I single out?
I have been up since Friday morning and it is now 5:09 am on Sunday!!!

Help!

Anthony@nova-creations.com    (SOURCE BELOW)

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

sub delete_user {

 open (FILE,"$db") || die "Content-type: text/html\n\nCan't Open $db(r):
$!\n";
 my(@LINES)=<FILE>;
 close(FILE);
 $SIZE=@LINES;

 open (GUEST,">$db") || die "Content-type: text/html\n\nCan't Open
$db(w): $!\n";

 for ($i=0;$i<=$SIZE;$i++) {
 $_=$LINES[$i];
 my($date) = split(/\|/,$_);

#####################################################
#
# $date|$firstname|lastname|login|password|securitylevel    <--  Sample
Format of PIPE delimited Flat File I'm using...
#
#####################################################

 if ($login eq $FORM{'login'}) {
       print "Record Successfully Deleted.\n";
  } else {
       print GUEST $_;
  }
 }
};

--------------4DEF8AB17609806481D17056
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hi!

<P>Can anyone tell me why my delete_user subroutine is deleting ALL THE
RECORDS, instead of the one I single out?
<BR>I have been up since Friday morning and it is now 5:09 am on Sunday!!!

<P>Help!

<P>Anthony@nova-creations.com&nbsp;&nbsp;&nbsp; (SOURCE BELOW)

<P><FONT COLOR="#009900">--------------------------------------------------------------------------------------</FONT>

<P>sub delete_user {

<P>&nbsp;open (FILE,"$db") || die "Content-type: text/html\n\nCan't Open
$db(r): $!\n";
<BR>&nbsp;my(@LINES)=&lt;FILE>;
<BR>&nbsp;close(FILE);
<BR>&nbsp;$SIZE=@LINES;

<P>&nbsp;open (GUEST,">$db") || die "Content-type: text/html\n\nCan't Open
$db(w): $!\n";

<P>&nbsp;for ($i=0;$i&lt;=$SIZE;$i++) {
<BR>&nbsp;$_=$LINES[$i];
<BR>&nbsp;my($date) = split(/\|/,$_);

<P><FONT COLOR="#009900">#####################################################</FONT>
<BR><FONT COLOR="#009900">#</FONT>
<BR><FONT COLOR="#009900"># $date|$firstname|lastname|login|password|securitylevel&nbsp;&nbsp;&nbsp;
&lt;--&nbsp; Sample Format of PIPE delimited Flat File I'm using...</FONT>
<BR><FONT COLOR="#009900">#</FONT>
<BR><FONT COLOR="#009900">#####################################################</FONT>
<BR>&nbsp;
<BR>&nbsp;if ($login eq $FORM{'login'}) {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Record Successfully Deleted.\n";
<BR>&nbsp; } else {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print GUEST $_;
<BR>&nbsp; }
<BR>&nbsp;}
<BR>};</HTML>

--------------4DEF8AB17609806481D17056--



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

Date: Sun, 15 Nov 1998 14:49:14 +0000
From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
Subject: Re: Not deleting correctly...
Message-Id: <364EE9EA.210EB0D5@qmw.ac.uk>

Anthony F. Sanchez wrote:
> 
> Hi!
> 
> Can anyone tell me why my delete_user subroutine is deleting ALL THE
> RECORDS, instead of the one I single out?
> I have been up since Friday morning and it is now 5:09 am on Sunday!!!
> 
> Help!
> 
> Anthony@nova-creations.com    (SOURCE BELOW)

You should check out the definition of split.

> sub delete_user {
> [...]
> 
>  for ($i=0;$i<=$SIZE;$i++) {
>  $_=$LINES[$i];
>  my($date) = split(/\|/,$_);

So $date is set to 6, the number of fields.  Did you use
the -w flag when executing Perl?  It should have said
something like "Implicit split to @_ is deprecated".

> #####################################################
> #
> # $date|$firstname|lastname|login|password|securitylevel    <--
> Sample Format of PIPE delimited Flat File I'm using...
> #
> #####################################################
> 
>  if ($login eq $FORM{'login'}) {

Hang on -- you've never defined $login!!  (use strict;
would have caught this one.)

>        print "Record Successfully Deleted.\n";
>   } else {
>        print GUEST $_;
>   }
>  }
> };

I think your split line would have been better written
something like:

my(@fields) = split /\|/;  # Note that the $_ is implicit
if ($fields[3] eq $FORM{'login}) {

etc.

HTH,

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


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

Date: Sun, 15 Nov 1998 15:29:14 GMT
From: bw@allied.demon.co.uk (Ben Walker)
Subject: NT/Unix
Message-Id: <364ef2f6.230218@news.demon.co.uk>

My script works on Unix.
When changed to an NT server, the unix perl statement
require 'myfile.cfg';
causes error not found in @INC.

What is the correct statement to require a config file for the script
in NT.

Thanks


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

Date: Sun, 15 Nov 1998 13:44:20 +0100
From: "Terje Hansen" <tehan@online.no>
Subject: Perl script for changing page every day
Message-Id: <72mica$cjg$1@readme.online.no>

Is there a Perl script which automates the task of changing the content of a
certain url every day?
For example www.mydomain.com/page.htm and I want to change the content of
page.htm once a day
Cheers, Terje




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

Date: Sun, 15 Nov 1998 13:23:05 GMT
From: kkolberg@att.com (Kal Kolberg)
Subject: Re: Perl script for changing page every day
Message-Id: <364ed4f7.129899921@news.netnews.att.com>

Change the content of the page?   Try using the Location  header to
redirect to a specified file  or use date to select a file name then
use while (<>) {print} to send the html page out.

Kal

On Sun, 15 Nov 1998 13:44:20 +0100, "Terje Hansen" <tehan@online.no>
wrote:

>Is there a Perl script which automates the task of changing the content of a
>certain url every day?
>For example www.mydomain.com/page.htm and I want to change the content of
>page.htm once a day
>Cheers, Terje
>
>



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

Date: Sun, 15 Nov 1998 13:13:43 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <3650cf64.1707783@news.skynet.be>

Zenin wrote:

>	for (keys %assign) {
>	    ${"${Packagename}::$_"} = $assign{$_};
>	}
>: Maybe I'm overlooking something. :-)
>
>	$assign{'Foo;print "bye system!\n";`rm -rf /`; exit; $foo'} = 666;

I was assuming that you were being smart, and check for valid variable
names for the keys before running that. At least do 

	($varname) = /(\w+)/

Taint checking.

The next may be not THAT harmful, but it will not work either:

 ${"${Packagename}::.'Foo;print "bye system!\n";`rm -rf /`; exit; $foo'}
    = 666;

	Bart.


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

Date: Sun, 15 Nov 1998 13:01:06 GMT
From: kkolberg@att.com (Kal Kolberg)
Subject: Re: SIMPLE BLOWFISH IN PERL?
Message-Id: <364ecf8e.128514828@news.netnews.att.com>

Do you have the encryption method that blowfish uses?  If so it's
pretty easy to encrypt/decrpt.  I just finished a zip file conversion
in perl that encoded information using a private encrytion method.  No
problems at all though it does run a bit slower than native C would.  

The main reason for writing the program was for compatibility reasons,
ie 6 flavors of UNIX, Linux, NT, etc etc etc  and it ports across
machines easily.

Kal

On Sat, 14 Nov 1998 15:03:17 GMT, fantastic2@hotmail.com (Alex M)
wrote:

>I am having an argument with someone I work with about implementing an
>8-bit Blowfish decryption scheme in PERL.
>
>He says that you have to download and use a module like cryptix and I
>say that you could write the decryption using basic PERL commands.
>
>Has anyone come up with a single PERL script that will decrypt data
>encrypted with Blowfish? I checked CPAN and couldn't find it, but
>maybe someone has. 
>
>I hate to be wrong! You can respond here or to me directly at
>fantastic2@hotmail.com.
>
>-- Alex



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

Date: Sun, 15 Nov 1998 06:56:41 -0800
From: "John E. Garrott" <johnga@primenet.com>
Subject: testing problems
Message-Id: <364EEBA9.73E08E0@primenet.com>

Perl novice question:

Has any one else successfully compiled perl under
glibc2.06 and egcs1.03b  (or egcs1.1)?

Perl compiles ok, not even a warning.  It complains 
"Note (probably harmless): No library found for" 
-lgdb, -lucb, and -lcposix, but my reading leads
me to believe this is ok.

when I run "make test" a number of tests fail.
(miniperl passes all tests).  The problems 
seems to lie with the "require" statement,
especially within a BEGIN bloc. 

For example: (from test op/goto_xs.t) "eval 'require Fcntl'"

The failure is simply "Segmentation fault"

I've tried tracking it down with xxgdb, but no luck so far.

Any advice or help would be appreciated.  I've been reading
FAQ's and such for over a month, but can't seem to find 
an answer.

Thanks in advance,

John


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

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 4223
**************************************

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