[6932] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 557 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 2 11:07:34 1997

Date: Mon, 2 Jun 97 08:01:50 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 2 Jun 1997     Volume: 8 Number: 557

Today's topics:
     Newbie question <nospam@nospam.org>
     Re: Newbie question <seay@absyss.fr>
     Re: Password Protection - NT <petri.backstrom@icl.fi>
     Passwords in Perl (John F Duggan)
     Perl and Excel spreadsheets - WIN32 jbcofino@shadow.net
     Re: Perl and Excel spreadsheets - WIN32 (Nathan V. Patwardhan)
     Re: Perl and Excel spreadsheets - WIN32 <buzz@bear.com>
     Re: Perl error handling for s/ and associative arrays (Chipmunk)
     Re: Printing Arrays to a file <jbokma@caiw.nl>
     Re: Protecting perl code *Important* <petri.backstrom@icl.fi>
     Refresh and Environment Variables. (John F Duggan)
     Re: Slices of lists (Brian Orpin)
     Re: Slices of lists (Brian Orpin)
     String::Approx 2.1 <jhi@alpha.hut.fi>
     Re: Submit form via script? (Bob Wilkinson)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 02 Jun 1997 10:05:01 -0400
From: Bill Thompson <nospam@nospam.org>
Subject: Newbie question
Message-Id: <3392D30C.ACDF50C8@nospam.org>

To get the number of characters in a string, I'm using the following:

sub ChkQID {
    my ($QID) = @_;
    my ($nchars, $i);

    $_ = $QID;
    $nchars = tr/\000-~//;        # get the number of characters

Is there a better way?

Thanks in advance



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

Date: Mon, 02 Jun 1997 16:38:27 +0200
From: Douglas Seay <seay@absyss.fr>
Subject: Re: Newbie question
Message-Id: <3392DAE3.1689A062@absyss.fr>

Bill Thompson wrote:
> 
> To get the number of characters in a string, I'm using the following:
> 
> sub ChkQID {
>     my ($QID) = @_;
>     my ($nchars, $i);
> 
>     $_ = $QID;
>     $nchars = tr/\000-~//;        # get the number of characters
> 
> Is there a better way?

yes there is.  look in the "perlfunc" man page.  start with the section
"Functions for SCALARs or strings" near the top of the file.

- doug


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

Date: Fri, 30 May 1997 11:51:36 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Password Protection - NT
Message-Id: <338EA328.68A3@icl.fi>

Jay Scherberth wrote:
> 
> Is is possible to password protect a cgi-bin on an NT server using IIS3.0?
> 
> I have set up a  cgi based discusion group (WEBbbs) that needs restricted
> access but have yet to firgure out how this can be accomplished. I have set
> up a .asp based login scheme which checks a MS Access database for
> authentication so the UserID and Pasword have already been entered. The
> user is taken to a "Private area" of the site which is a Active Server Page
> with links to the WEBbbs discussion group. There are links to 8 different
> discussion groups (www.mydomain.com/cgi-bin/configx.pl) Config.pl is the
> executable. I need a way to intercept someone who can simply enter in the
> correct URL, thus bypassing the security all together.
> 
> Thanks in advance for any help on this!
> 
> Jay Scherberth
> www.editorsguild.com

This isn't a Perl issue at all, but if I were you, I'd put the CGI
scripts under the protected directory tree, and access it via
'/protected/cgi-bin' instead of '/cgi-bin', which is "public".

If you need more help, ask in, e.g., Microsoft's IIS newsgroups
on msnews.microsoft.com.

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 2 Jun 1997 13:54:18 GMT
From: duggan@kira.ecs.umass.edu (John F Duggan)
Subject: Passwords in Perl
Message-Id: <5mujaa$bp9$1@risky.ecs.umass.edu>

Hello,

I am working on acessing a database via a web browser. I have the database
access up and running just fine. But I need to be able to pass a username and
password for database access to the SQL statements that I have. The perl
scripts are running under Netscape's Commerce Server. 

According to page 394 of the CGI programming book by O'Reilly:

    The password field in the TYPE=password is not secure.

Is this secure if combined with the Commerce Server.

One last problem that I have is that if I used the TYPE=password, then I have
the password displayed with the NETSITE url at the top of the page within
Netscape. I have used the refresh command to reset the web page. But I lose
all environment data when this is done. I use the command:

    $ENV{'USER_PASSWORD'} = ...

Once the screen/page is refreshed the data is gone.

Any ideas would be greatly appreciated.

Thanks,

John Duggan

----------------------------------------------------------------------------
 John Duggan                       Internet : duggan@zonker.ecs.umass.edu
 Engineering Computer Services
 Univ. of Massachusetts            
 Amherst, MA 01003                         
----------------------------------------------------------------------------


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

Date: Fri, 30 May 1997 21:22:03 -0400
From: jbcofino@shadow.net
Subject: Perl and Excel spreadsheets - WIN32
Message-Id: <338F7D3B.718F@shadow.net>

Looking for help in obtaining information to read Excel spreadsheets
from within a perl script. The environment is WIN95 using Perl-WIN32.

Any help is appreciated.

JBC


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

Date: 2 Jun 1997 13:48:02 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl and Excel spreadsheets - WIN32
Message-Id: <5muiui$t0g@fridge-nf0.shore.net>

jbcofino@shadow.net wrote:
: Looking for help in obtaining information to read Excel spreadsheets
: from within a perl script. The environment is WIN95 using Perl-WIN32.

The OLE extensions should be described the helpfiles included with
your distribution of NTPerl.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Mon, 02 Jun 1997 10:49:19 -0400
From: Buzz Moschetti <buzz@bear.com>
Subject: Re: Perl and Excel spreadsheets - WIN32
Message-Id: <3392DD6F.1386@bear.com>

jbcofino@shadow.net wrote:
> 
> Looking for help in obtaining information to read Excel spreadsheets
> from within a perl script. The environment is WIN95 using Perl-WIN32.
> 
> Any help is appreciated.
> 
> JBC

Look at www.activeware.com


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

Date: 2 Jun 1997 06:43:21 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Perl error handling for s/ and associative arrays
Message-Id: <5mtq29$vfb$1@dartvax.dartmouth.edu>

In article <338A7B97.2373@korridor.se>
Joakim Larsson <joakim@korridor.se> writes:

> $err =~ s/<!MGFFORM (.*)>/$FORM{$1}/ge;
> 
> The idea is to replace all occurences of <!MGFFORM xxx> with the
> contents of the associative array $FORM{'xxx'} It works well until
> an undefined slot in the associative array is referenced. In that
> case it skips that whole row continuing with the next one:
> 
> $FORM{'a'} = 'Hi ';$FORM{'B'} = 'there ';$FORM{'c'} = 'guru! ';
> $err = '<!MGFFORM a><!MGFFORM b><!MGFFORM c>';
> $err =~ s/<!MGFFORM (.*)>/$FORM{$1}/ge;
> print $err;
> 
> If for instance 'b' isn't a valid key 'a' and 'c' will not get
> replaced either or at least they will not get back to $err.
> However, putting them on separate rows is a different story:
> 
> $FORM{'a'} = 'Hi ';$FORM{'B'} = 'there ';$FORM{'c'} = 'guru!';
> $err = '<!MGFFORM a>\n<!MGFFORM b>\n<!MGFFORM c>';
> $err =~ s/<!MGFFORM (.*)>/$FORM{$1}/ge;
> print $err;
> 
> In this case only the 'b' case will be missing in the resulting $err.

The problem is not that 'b' is not a valid key.  The problem is that
'a><!MGFFORM b><!MGFFORM c' is not a valid key.
(Have you actually tried the substitution on a string containing all
valid keys, such as '<!MGFFORM a><!MGFFORM c>'?)

Let's look at your regexp:

s/<!MGFFORM (.*)>/$FORM{$1}/ge;

This matches '<!MGFFORM ', followed by any number of characters,
followed by '>'.  It's important to remember that * is a greedy
operator - it matches as much as possible.  Thus, in '<!MGFFORM
a><!MGFFORM b><!MGFFORM c>', the regexp matches once, with (.*)
matching 'a><!MGFFORM b><!MGFFORM c', instead of three times, with (.*)
matching 'a', 'b', and 'c'.

The reason it works with '<!MGFFORM a>\n<!MGFFORM b>\n<!MGFFORM c>' is
that a period actually matches any character *except* a newline.  Since
(.*) can't match 'a>\n<!MGFFORM b>\n<!MGFFORM c', it only matches 'a'
the first time.

What you want to do is this:

s/<!MGFFORM (.*?)>/$FORM{$1}/ge;

The ? makes the * non-greedy, so it matches as few characters as
possible.
However, this would be even better:

s/<!MGFFORM ([^>]*)>/$FORM{$1}/ge;

Which explicitly matches characters up to the first '>'.

> How can I tune the expression to return an empty string for 
> non valid keys? Is it a bug or a feature?

Neither.  It's a mistake in your regexp.  :-)


Chipmunk


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

Date: 2 Jun 1997 07:13:53 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: Printing Arrays to a file
Message-Id: <01bc6f24$43278320$a80ab2c2@tschai>



Tad McClellan <tadmc@flash.net> wrote in article
<dpurm5.vn.ln@localhost>...
> Tung-chiang Yang (tcyang@netcom.com) wrote:
> : Bugsy (rlall1@mugca.cc.monash.edu.au) wrote:
> 
> [ snip good comments about other strangeness in the posted code ]
> 
> 
> : If you do want to print the entries of @altsorted as one entry
per line,
> : use
> 
> :    while (@altsorted){
> :       print AG "$altsorted[0]\n";
> :       shift(@altsorted);
> :    }
> 
> : Gurus might write above codes into two lines or even one line.
> 
> 
> Even a simple "Intermediate Perler" such as myself might write
> it in two lines:
> 
> $" = "\n";
> print "@altsorted\n";
> 

How about:

print join("\n", @altsorted), "\n";

No need to change $" or other weird variables...

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: Mon, 02 Jun 1997 10:37:46 +0200
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Protecting perl code *Important*
Message-Id: <3392865A.4FBF@icl.fi>

Carl Eklof wrote:
> 
> How does one protect perl code.
> 
> I have a very serious issue; I am selling some code that I wrote and
> would like to protect it against copying, etc. I have heard that there
> are ways to convert perl into its binary form. Is that true? That would
> certainly solve my problem.
> 
> The code will be on their machine, so they could pretty much do what
> ever they want.
> 
> Please help,
> 
> Thanks it advance,
> 
> -Carl

Go to 

    http://www.dejanews.com 

and search this newsgroup for, e.g., "undump" and "compiler" or
"obfuscate" to find the numerous discussions regarding this subject, 
which also happens to be on the Frequently Asked Questions (FAQ) list 
as "How can I hide the source for my Perl program?" and "How can I 
compile my Perl program into byte-code or C?".

Start at:

    http://www.perl.org/CPAN/doc/FAQs/FAQ/html/

(and remember to consult it, and dejanews, first for any future 
questions you may have; as they may very well have been asked and 
answered before).


regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 2 Jun 1997 14:00:52 GMT
From: duggan@kira.ecs.umass.edu (John F Duggan)
Subject: Refresh and Environment Variables.
Message-Id: <5mujmk$bp9$2@risky.ecs.umass.edu>

Hello,

I have been using a refresh within a perl script to allow me to clear the
query string information from being displayed as part of the url. I do this
by setting the refresh time for 0. When I do this, I lose all of the Envir-
onment Variables information. Is there any way around that? Would embedding
the refresh within a form solve the problem?

Thanks.

John Duggan

----------------------------------------------------------------------------
 John Duggan                       Internet : duggan@zonker.ecs.umass.edu
 Engineering Computer Services
 Univ. of Massachusetts            
 Amherst, MA 01003                         
----------------------------------------------------------------------------


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

Date: Mon, 02 Jun 1997 07:07:49 GMT
From: brian.orpin@gecmX.com (Brian Orpin)
Subject: Re: Slices of lists
Message-Id: <3397705f.3167883@news.geccs.gecm.com>

On 29 May 1997 13:13:05 -0700, colink@latticesemi.com (Colin Kuskie)
wrote:

>In article <339671cd.18396087@news.geccs.gecm.com>,
>Brian Orpin <brian.orpin@gecmX.com> wrote:
>>As a newcomer to Perl I have hit my first (apparently) insurmountable
>>problem which on line help (The downloaded HTML man pages are broken
>>but that's another thread) hasn't and is beyond 'Learning Perl' (what
>>a great starter).
>This should not be a problem.  You shouldn't need the "downloadable
>HTML man pages" because all installations of perl come with a copy
>of those very man pages (in man, HTML, and various other sundry forms).
>On my Solaris box, I find them in:
>/usr/local/lib/perl5/html    --> for HTML
>/usr/local/man               --> for man
>/usr/local/src/perl5.002/pod --> raw form

These also appear to be broken which is why I tried an alternative
source.  I'm on a win95 machine and it may be due to the need to use
Winzip to get inside a tar.gz file.  I'm not convinced of this
especially as the online man pages are also broken.

--
Brian Orpin    (These thoughts are my own ......... for once!)
brian.orpin@gecmX.com or BrainOrpin@BigfootX.com  
http://www.borpin.demon.co.uk/  **Anti-spam reply-to remove X**


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

Date: Mon, 02 Jun 1997 08:42:48 GMT
From: brian.orpin@gecmX.com (Brian Orpin)
Subject: Re: Slices of lists
Message-Id: <339b86e9.8938097@news.geccs.gecm.com>

On Thu, 29 May 1997 21:13:51 GMT, ced@bcstec.ca.boeing.com (Charles
DeRykus) wrote:

>In article <339671cd.18396087@news.geccs.gecm.com>,
>Brian Orpin <brian.orpin@gecmX.com> wrote:
> > I wish to replace a slice of an array.
>
>Presuming your array is well behaved as far as start,end 
>item uniqueness, you could at least reduce the searches to 
>a couple of short one-liners:
>
>$start++,$end++ until $old[$start] eq "start_string";
>$end++          until $old[$end]   eq "end_string";

This I like. the only problem I had was getting an error trying to use
an uninitialised variable.

this I solved by
$start++,$end++ until $old[$start] =~  /start_string/i;

which works great.
Thanks


--
Brian Orpin    (These thoughts are my own ......... for once!)
brian.orpin@gecmX.com or BrainOrpin@BigfootX.com  
http://www.borpin.demon.co.uk/  **Anti-spam reply-to remove X**


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

Date: 2 Jun 1997 14:42:47 GMT
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: String::Approx 2.1
Message-Id: <5mum57$fju$1@nadine.teleport.com>


The String::Approx release 2.1 is available as

	http://www.perl.com/CPAN/authors/id/JHI/String-Approx-2.1.tar.gz

If you have been using the release 2.0 I suggest upgrading.

Some minor bugs and documentation typos have been fixed and one big
problem has been somewhat circumvented: the problems with long match
patterns some users have seen ("regexp too large"), usually when
patterns are longer than 15 characters.

The cure for the long patterns is only partial and a compromise:
it does not help substitutions at all and for matches it makes matching
a bit slower and in general a bit more approximate.  However, for long
pattern matches the fix works quite nicely and if failures are caused
by long patterns the failures are now more graceful and the issues
behind the failure are explained in the documentation.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen




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

Date: Mon, 02 Jun 1997 14:19:32 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: Submit form via script?
Message-Id: <b.wilkinson-0206971419320001@ip57-york.pindar.co.uk>

In article <338BF650.3CD4@moriah.com>, scott@moriah.com wrote:

> Question: +++++++++++
> Is it possible to submit a form via a script instead of having to
> "click" on a submit button?
> 
> Background (fluff!): +++++++++++
> We are adding 500+ of our clients pages to many of the search engines. I
> have already written a script which gathers descriptions and the like
> from their pages on our site and then presents me with a list of buttons
> from each of the search engines.
> 
> However, it makes more sense to me to click one button and have a script
> submit all the forms. Taking this a step further, I could simply give a
> list of URL's to the script and let it do the work.
> 
> Possible?
> 
> Would either Post or Get cause any additional trouble? I'm using Perl.
> 
> Thanks in advance.
> scott@moriah.com

Hello,

      I think that this looks like a CGI question. Why not post it to
comp.infosystems.www.authoring.cgi?

Bob

P.S. I presume that you've downloaded and installed and read fully the
documentation for Lincoln Stein's CGI.pm module (since you're using Perl).

-- 
I have become death, destroyer of the worlds.


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 557
*************************************

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