[12620] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 29 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 6 22:47:13 1999

Date: Tue, 6 Jul 1999 19:36:51 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 6 Jul 1999     Volume: 9 Number: 29

Today's topics:
    Re: getting script source (Anno Siegel)
    Re: getting script source <garyg@gator.net>
    Re: getting script source <garyg@gator.net>
    Re: getting script source (Benjamin Franz)
    Re: getting script source <gellyfish@gellyfish.com>
    Re: getting script source <ngaccess@millions.net>
    Re: getting script source (Anno Siegel)
    Re: global substitution <gellyfish@gellyfish.com>
    Re: Help Excel functions to Perl Code <Russell_Schulz@locutus.ofB.ORG>
    Re: Help with Pattern Matching (Tad McClellan)
    Re: Help with Pattern Matching <JFedor@datacom-css.com>
        help with read( ) <bbridges@seark.net>
        Help with regex and general issue... <pyrodex@home.com>
    Re: Help with regex and general issue... (elephant)
    Re: Help with regex and general issue... <pyrodex@home.com>
    Re: Help with regex and general issue... (Ronald J Kimball)
    Re: Help with regex... (Bart Lateur)
    Re: HELP!!!! PLEASE!!!! <sjs@yorku.ca>
        HELP: Question about POST with a Perl CGI jfk120@my-deja.com
    Re: HELP: Question about POST with a Perl CGI (elephant)
    Re: HELP: Question about POST with a Perl CGI (Abigail)
        Help: simple questions <scientia@XXXtechnologist.com>
    Re: Help: simple questions (Arnaud Limbourg)
    Re: Help: simple questions (Bart Lateur)
    Re: Help: simple questions (elephant)
    Re: Help: simple questions (Abigail)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 3 Jul 1999 18:42:54 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting script source
Message-Id: <7lllje$jf3$1@lublin.zrz.tu-berlin.de>

pop  <ngaccess@millions.net> wrote in comp.lang.perl.misc:
>Tom Christiansen wrote:

[...]

>> Just because you've got a machine that's connected to the net doesn't
>> mean that anybody can do anything to it from anywhere that an authenticated
>> user with a proper account on that machine is able to do.
>> 
>> Does that make sense?
>> 
>
>Certainly that makes sense. I understand that completely, however you
>obviously (my fault) do not understand what I am asking.
>
>> It's still not related to perl, though.
>> 
>
>Since the scripts are written in perl I most certainly think it is
>related. (has to do with the internal workings of perl) If it was
>another language I would have went to that newsgroup.

You don't get it.  The issue is the same, whatever language your
executable (cgi) is written in.

>The following scenario is the '''opposite''' of what I am asking ... I
>want to try to 'protect' the scripts sorce code from being seen.
>
>You (anyone) have a custom written script (perl) running on your web
>server. (web server on a computer with 755 permission (standard for
>script on webserver))
>I (anyone) access the script through the internet. (network)
>Can I (anyone) 'trick', 'trigger', 'coerce' 'torture' or otherwise make
>make the script (source code) send itself (source code) back to me where
>I would then have your copywrited source code? (any trick 'keywords' or
>'codes' or whatever that can be sent to it to get it to do this)

That depends on the semantics of the script, not on how it's
implemented.  If the author has, deliberately or through sloppiness,
provided a way for the script to send itself to the user, it can
be done.  If he or she hasn't, it can't.

>I do not want to pay for 'copywrited' custom source code if you (anyone)
>can access it and reuse it as your own or whatever.
>
>The author says it can't be done - I want a second (or third) opinion
>but did not know it was that difficult to understand.
>
>I would have thought it was a 'common' concern.

Security of cgi's is a common concern. This particular issue is
just one minor aspect.  The question is really, do you trust the
author to have written the script with security concerns in mind?
Also, do you trust the admin of the web site it's running on to
have paid attention to security concerns?

That said, if it's a perl script, the first line can tell you
something about the authors state of mind.  If it doesn't set
"taint checking", that is, if it doesn't have a "T" in the
set of flags that are given to perl, it is probably insecure.
If it does have that, it shows the author was aware he was
writing code that is run under a user id not his own, and that
it was going to process strings that come from a potentially
malicious user.  It doesn't prove the script is secure, but
it shows the author has paid attention.

Anno


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

Date: Sun, 04 Jul 1999 09:17:37 -0400
From: "Gary M. Greenberg" <garyg@gator.net>
Subject: Re: getting script source
Message-Id: <377F5EF1.30AC7E83@gator.net>

pop wrote:

> > It's still not related to perl, though.
> 
> Since the scripts are written in perl I most certainly think it is
> related. (has to do with the internal workings of perl) If it was
> another language I would have went to that newsgroup.

I think this is a misunderstanding; it has nothing to do with Perl
per se because it is Network security that makes the source either
accessible or unaccessible. It matters NOT what language was used
to produce the source code. The issue afaict is whether or not your
network is secured and keeps unwanted eyes from preying at the source
code (presumably stored in a cgi-bin directory someplace).

Hope that's a little useful,
Gary


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

Date: Sun, 04 Jul 1999 09:23:15 -0400
From: "Gary M. Greenberg" <garyg@gator.net>
Subject: Re: getting script source
Message-Id: <377F6043.CB183DBD@gator.net>

Pop,
  [posted and mailed]
> Now you're getting close ...
> 
> I'm not concerned with 'physical access' type nabbing, (ftp, directory
> listings, telnet, etc) but rather some 'internal' code or function or
> keywords or whatever that can make the script 'hurl' itself?

I think the question you need to ask is "I have this Perl source code
that
I'm about to (or have already) paid for and I'm not sure that the
programmer
isn't also secretly selling or giving it to others.
Can someone look at this code and tell me if I'm being bamboozled?"

How's that? ;-)

Gary
	Putting out fire with gasoline.


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

Date: Sun, 04 Jul 1999 14:31:10 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: getting script source
Message-Id: <OeKf3.2504$vI3.121939@typhoon-sf.snfc21.pbi.net>

In article <377D549F.752834E9@millions.net>,
pop  <ngaccess@millions.net> wrote:
>
>I'm not concerned with 'physical access' type nabbing, 
>(ftp, directory listings, telnet, etc) but rather some 
>'internal' code or function or >keywords or whatever that 
>can make the script 'hurl' itself?

1) No. There is no 'secret code' built into the language
   that will let anyone magically cause a script to
   reveal its source code on a web browser.

2) Yes. *ANY* program, in *ANY* language can be rigged
   deliberately by the programmer to send its source
   code on demand. But if you don't trust the
   programmer not to have inserted backdoors like that
   - what are you doing trusting them to write scripts
   for you in the first place? *They* have the source
   code physically in their possession in the first
   place - they have no *NEED* to insert trapdoor
   access functions of that type.

3) Bad programming can leave security holes that give
   access to parts of web servers not intended to be
   public. In any language. And compiling code only
   makes it _harder_ to get get source (assuming you
   don't keep the source somewhere physically on the
   server so you can compile it) - not impossible. 
   Decompilers are available for just about every 
   platform and language. The way to avoid bad
   programming is to hire good programmers.

4) Mis-configured web servers also leave security
   holes.

5) You obviously are not competent to evaluate security
   issues. Hire someone who is. We are not a free
   consulting service.

-- 
Benjamin Franz


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

Date: 4 Jul 1999 14:37:40 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: getting script source
Message-Id: <7lnrjk$3vp$1@gellyfish.btinternet.com>

On Fri, 02 Jul 1999 20:09:03 -0400 pop wrote:
> Lee wrote:
>> 
>> In article <377BF4C5.6E4E3E70@millions.net>,
>> pop <ngaccess@millions.net> wrote:
>> 
>> >Is it possible to get a script to return the entire script contents?
>> 
>> I think the question you're trying to ask is:
>> 
>> Can any Joe with a web browser swipe the source to my nifty cgi script?
>> 
>> No.
>> 
>> However, all ISPs that I've dealt with have been set up so that anyone with
>> telnet or ftp access can wander in and grab them.
>> 
> 
> I'm not concerned with 'physical access' type nabbing, (ftp, directory
> listings, telnet, etc) but rather some 'internal' code or function or
> keywords or whatever that can make the script 'hurl' itself?

I'm now not sure what you are asking.  It appears you are suggesting that
there may be some bug or feature in Perl itself that will cause the
source code of the running script to be printed to STDOUT, where you
came by that particular idea I have no notion whatsoever, I can see no
possible utility for it if this were to be a feature and if it were a
bug then it would certainly have been subject to a CERT advisory notice
almost instantly that it appeared and subsequently fixed.

If on the other hand you are asking whether something external to the
program could cause the source code to be sent instead of the programs
output then you are asking in the wrong group.

Of course it would be possible to create a program that did this :


#!/usr/bin/perl -w

use strict;

use CGI qw(:standard);

if(param('sendme') == 1)
  {
    if(open(ME,$0))
     {
      print header('text/plain');
      print while <ME>;
     }
   else
     {
      print header,start_html('Somethings wrong');
      print "Couldnt open $0 - $!\n";
      print end_html;
    }
  }

Of course if your server is running an unpatched version of IIS3 then
anyone can get hold of the source of anything on your server whatever it
might be by simply appending ::$DATA to the URL.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 04 Jul 1999 16:52:12 -0400
From: pop <ngaccess@millions.net>
Subject: Re: getting script source
Message-Id: <377FC97C.4F21AE4@millions.net>

Thanks everyone for the help.

No I was not talking about external or physical access to get the code.
(security)

Yes I was talking about internal "easter eggs" type stuff in perl itself
or in the code itself but I guess I am not verbally eloquent enough to
convey my thoughts accurately.

Did not mean to stir up such a mess ... apologies ... 

Now that it's stirred up though I have another question.
What would I (anyone) search for in the code that would indicate it will
do inordinate things such as send its own code, etc or maybe worse?
(certain strings, etc)

TIA
more apologies ...


pop wrote:
> 
> Hello all,
> 
> Is it possible to get a script to return the entire script contents?
> 
> Or IOW, can someone get a script to 'send' itself to them?
> 
> I know it will if its setup wrong or misconfigured but I am speaking of
> a 'properly configured' working script.
> 
> TIA


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

Date: 4 Jul 1999 21:04:35 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting script source
Message-Id: <7loi93$l5n$1@lublin.zrz.tu-berlin.de>

pop  <ngaccess@millions.net> wrote in comp.lang.perl.misc:
>Thanks everyone for the help.
>
>No I was not talking about external or physical access to get the code.
>(security)
>
>Yes I was talking about internal "easter eggs" type stuff in perl itself
>or in the code itself but I guess I am not verbally eloquent enough to
>convey my thoughts accurately.

No.  Your eloquence has quite adequately conveyed your thoughts.
They are lacking clarity.

>Did not mean to stir up such a mess ... apologies ... 
>
>Now that it's stirred up though I have another question.
>What would I (anyone) search for in the code that would indicate it will
>do inordinate things such as send its own code, etc or maybe worse?
>(certain strings, etc)

Again, no.  There are no particular strings that give away an evil
intent of the programmer.  As you have been told more than once in
this thread, you have to trust the programmer.  If you don't, don't
buy their code.

Anno


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

Date: 4 Jul 1999 16:00:41 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: global substitution
Message-Id: <7lo0f9$41h$1@gellyfish.btinternet.com>

On 02 Jul 1999 12:05:24 -0400 Uri Guttman wrote:
> 
> BTW, thanx for tossing the bee at yapc.
> 

I think that should be reported to the National Apiary Society ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sun, 4 Jul 1999 14:08:02 -0400
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: Help Excel functions to Perl Code
Message-Id: <19990704.140802.4B5.rnr.w164w@locutus.ofB.ORG>

"Simmo" <simsiSPAM_ME_NOT@hotmail.com> writes:

> Has anyone any experience of creating Perl scripts that replicate
> Excel functions

I have a spreadsheet to source translator ss2src (currently produces
Pascal syntax, but there's not much Pascal-specific in there).  It
includes a free library of implementations of Excel functions.

ss_POWER ss_SAFEDIVIDE ss_IF ss_CHOOSE ss_EXP ss_LN ss_LOG ss_LOG10
ss_ROUND ss_SIN ss_COS ss_TAN ss_ATAN ss_AND ss_OR ss_TRUE ss_FALSE
ss_NOT ss_ABS ss_INT ss_TRUNC ss_FACT ss_FACTDOUBLE ss_MOD ss_PI
ss_DEGREES ss_RADIANS ss_SIGN ss_SQRT ss_SQRTPI ss_RAND ss_MIN ss_MAX

> [can't install the] spreadsheet::excel module

Did you actually find a copy?  Everything I see says that it's just
a suggested name, not an actual module.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Fri, 2 Jul 1999 18:07:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with Pattern Matching
Message-Id: <d7djl7.iu3.ln@magna.metronet.com>

Shaddy International Ltd. (shaddy@shaddy.com) wrote:

: This is a multi-part message in MIME format.


   Please don't do that.

   It makes people ignore your posting.

   Usenet is a plain text medium.


:     I'm trying to write a little script that'll replace all the " in a ~
: delimited text file with a space. 


   Perl FAQ, part 5:

      "How do I change one line in a file/
       delete a line in a file/
       insert a line in the middle of a file/
       append to the beginning of a file?"


: Code:
[snip code]


: Could somebody please give me some insight into this. I'm new to this
: Pattern Matching stuff


   I think your pattern matching is fine above.

   But you don't have any output statements, so I'm wondering
   what you examined to determine that it "isn't working"?

   (that is your problem, you need to output it after changing it)


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


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

Date: Sat, 3 Jul 1999 01:14:18 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Help with Pattern Matching
Message-Id: <7lk4c8$gqr$1@plonk.apk.net>


Shaddy International Ltd. wrote in message <377CE434.395CFFA3@shaddy.com>...
>Hey
>
>    I'm trying to write a little script that'll replace all the " in a ~

^^
>delimited text file with a space. The following code is what I got. I
>can't figure out way it won't replace. It'll find all the "'s in the
>fill.
>
>Code:
>$old_file = "j:\\scripts\\pricelist.txt";
>$search = '"';
>$replace = "";

You didn't put anything in the $search and $replace variables, they are
null.

Why are you going through the trouble to do this?
Unless quote marks will change in future databases, hard code it! Less
variables easier to read.

>open(PRICELIST, "$old_file");
>while ($line = <PRICELIST>)
>{


You would want to do the replacement here to avoid having to do multiple
matches here:
$line =~ s/\"/ /g;

> ($partno, $desc, $unit, $price) = split(/~/,$line,4);

Now do your split and $units will be de"quotified" too!

> $desc =~ s/$search/$replace/g;
>}
>close(PRICELIST);
>
>Sample Line from Data File:
>65211~MOUSE "MOUSE-IN-A-BOX" GREY~"U"~42.67
>
>Could somebody please give me some insight into this. I'm new to this
>Pattern Matching stuff
>
>Thanks
>Jason
>

Jody




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

Date: 6 Jul 1999 20:08:05 GMT
From: "Bob Bridges" <bbridges@seark.net>
Subject: help with read( )
Message-Id: <01bec7ea$945c3c60$8764f5d0@bbridges.seark.net>

How do I use the read ( ) operator.  Please help me.


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

Date: Mon, 05 Jul 1999 14:36:38 GMT
From: Richie Crews <pyrodex@home.com>
Subject: Help with regex and general issue...
Message-Id: <3780ED68.25667746@home.com>

Hello,

    I am currently working on a program from work... I have never
touched a regex before, and my luck be it, My regex book hasnt come in
=].  Anyway here is the the issue.... I am trying to match mutiple lines
inside a 15+ meg file... here is a sample line...

From patrol@pc003.engrs.infi.net  Wed Apr 14 12:43:52 1999


Now what i need the regex too do is to match that line sorta like this

* ($1)@($2) * $curmonabr $curdaynum * $curyear....    I need the user
and the host in the email address to be placed into varibles.. so I can
report them later...
and the $cur* varibles are ones i am using from Time::Local ... But here
is were I really lose myself... I need to grab all the information after
the pattern match and then stop before the next line occurs above
again... So sorta like this..

From patrol@pc003.engrs.infi.net  Wed Apr 14 12:43:52 1999
Blah
Blah
Blah
From patrol@pc003.engrs.infi.net  Wed Apr 14 12:43:52 1999

    Of course it wont be the same pattern matching line =],  now I have
been told to try the .. operator, but how would that be used?  Becuase I
then need to search that little chunk of stuff between the lines for a
simple thing (Which i have got down...) but then i need to start the
whole process over again... So anyone got any ideas?  I would be willing
to chat via email, please catch me at pyrodex@home.com or ICQ
2122263.... thanks



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

Date: Tue, 6 Jul 1999 01:11:01 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Help with regex and general issue...
Message-Id: <MPG.11eb7612b2d62d81989af1@news-server>

Richie Crews writes ..
>    I am currently working on a program from work... I have never
>touched a regex before, and my luck be it, My regex book hasnt come in
>=].  Anyway here is the the issue.... I am trying to match mutiple lines
>inside a 15+ meg file... here is a sample line...
>
>From patrol@pc003.engrs.infi.net  Wed Apr 14 12:43:52 1999

looks like a mail file .. if so then try the Mail::Header module - part 
of the MailTools package on CPAN

-- 
 jason - remove all hyphens for email reply -


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

Date: Mon, 05 Jul 1999 15:45:01 GMT
From: Richie Crews <pyrodex@home.com>
Subject: Re: Help with regex and general issue...
Message-Id: <3780FD6C.8D17A4A1@home.com>

Its not a normal mail header... it varies a bit... I could regex the line,
then pull the information out with that module you said?

elephant wrote:

> Richie Crews writes ..
> >    I am currently working on a program from work... I have never
> >touched a regex before, and my luck be it, My regex book hasnt come in
> >=].  Anyway here is the the issue.... I am trying to match mutiple lines
> >inside a 15+ meg file... here is a sample line...
> >
> >From patrol@pc003.engrs.infi.net  Wed Apr 14 12:43:52 1999
>
> looks like a mail file .. if so then try the Mail::Header module - part
> of the MailTools package on CPAN
>
> --
>  jason - remove all hyphens for email reply -



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

Date: Mon, 5 Jul 1999 21:20:10 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Help with regex and general issue...
Message-Id: <1duhhxy.1gxwryc9555w6N@p21.block2.tc2.state.ma.tiac.com>

Richie Crews <pyrodex@home.com> wrote:

> From patrol@pc003.engrs.infi.net  Wed Apr 14 12:43:52 1999
> 
> 
> Now what i need the regex too do is to match that line sorta like this
> 
> * ($1)@($2) * $curmonabr $curdaynum * $curyear.... 


if (/^From +([^\@]+)\@(\S+) +\S+ +(\S+) +(\d+) +\S+ +(\d+)$/) {
  ($username, $hostname, $month, $day, $year) = ($1, $2, $3, $4, $5);
}


Please note that certain degenerate but legal email addresses will not
be matched properly.  Fortunately, such addresses are rather unlikely to
appear in your mail file.


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 03 Jul 1999 07:24:56 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Help with regex...
Message-Id: <377db8e7.1606281@news.skynet.be>

dave shaffer wrote:

>I could use something like this: $text =~ tr/<.*>//;  but how do you match
>when spanning multiple lines.

You mean  { s/<.*>//g; }. What you wrote, will count less-thans,
greater-thans, dots and stars.

Solution: 

 A) Read in the whole text as one string
 B) Add the //s modifier, so "." accepts newlines too
 C) Make the ".*" non-greaady, or else everything between the first "<"
and last ">" will be gone.

	s/<.*?>//sg;

	Bart.


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

Date: Sat, 3 Jul 1999 14:31:39 -0500
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: HELP!!!! PLEASE!!!!
Message-Id: <931030444.2047474363@newshub.ccs.yorku.ca>

On Thu, 01 Jul 1999, Kent Perrier wrote:
>Ice Nyne <anfinger@mediaone.net> writes:
>
>> How do I start the program activeperl?!?  please help!
>
>By reading the nice documentation that came with it.

You, sir, think far too clearly for usenet.

BTW, here's a riddle: Who answers silly questions of home users who are trying
to figure out how to run their newsreader {whilst avoiding the docs like the
plague)?


Steve





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

Date: Mon, 05 Jul 1999 17:15:19 GMT
From: jfk120@my-deja.com
Subject: HELP: Question about POST with a Perl CGI
Message-Id: <7lqp6v$nvj$1@nnrp1.deja.com>

I am trying to post form data to a web server with
out the use of a submit button.  Does anyone know
how this is done or the syntax involved??  I am
using CGI.pm.

thanks
Jon K.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 6 Jul 1999 04:27:30 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: HELP: Question about POST with a Perl CGI
Message-Id: <MPG.11eba41aa5a166f9989af4@news-server>

jfk120@my-deja.com writes ..
>I am trying to post form data to a web server with
>out the use of a submit button.  Does anyone know
>how this is done or the syntax involved??  I am
>using CGI.pm.

it's a client side operation .. you can't do it without submitting the 
form .. of course - you can submit a form without a submit button via 
javascript and via the type="image" mechanism .. but I doubt that's what 
you're looking for

both of these are beyond the scope of this newsgroup anyhow

-- 
 jason - remove all hyphens for email reply -


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

Date: 5 Jul 1999 15:18:09 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: HELP: Question about POST with a Perl CGI
Message-Id: <slrn7o24nd.h6v.abigail@alexandra.delanet.com>

jfk120@my-deja.com (jfk120@my-deja.com) wrote on MMCXXXIV September
MCMXCIII in <URL:news:7lqp6v$nvj$1@nnrp1.deja.com>:
:: I am trying to post form data to a web server with
:: out the use of a submit button.  Does anyone know
:: how this is done or the syntax involved??  I am
:: using CGI.pm.


No, it cannot be done, at least not reliable. (Short of telnetting
to port 80 and typing in the data). Of course, this has absolutely
nothing to do with Perl.

Followups set.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 05 Jul 1999 13:52:41 -0700
From: Scientia <scientia@XXXtechnologist.com>
Subject: Help: simple questions
Message-Id: <37811B19.D77@XXXtechnologist.com>

Help: simple questions

Hello

I am learning PERL because I have to make very simple CGIs
(I am already able to make very simple programs).

I have some questions and I hope that someone can help me.

1) How can I deal with strings in PERL?
In Basic I can use functions such as  left$(a$,3) or mid$(a$,5,2)
but I do not know I can Make the same in PERL!
I know that "Scalar" variables may be either numbers or strings:
this seems strange to me.

2) I have Win95 and I would like to test my PERL programs before
uploading into my web site.
I visited www.perl.org and through several links I found 
"Active PERL" to download. But there are a lot of warnings that I do
not understand. So my question is: what can I download, considering
that I need something very simple, and that my programs will be
short and simple?

Thanks
Fabrizio
scientia@technologist.com


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

Date: Mon, 05 Jul 1999 12:42:28 GMT
From: haytounet@my-deja.com (Arnaud Limbourg)
Subject: Re: Help: simple questions
Message-Id: <3780a7e2.21319443@news.bull.fr>

>2) I have Win95 and I would like to test my PERL programs before
>uploading into my web site.
>I visited www.perl.org and through several links I found 
>"Active PERL" to download. But there are a lot of warnings that I do
>not understand. So my question is: what can I download, considering
>that I need something very simple, and that my programs will be
>short and simple?

Yep, activePerl is what runs on windows systems, downnload it from
www.activestate.com.

It's perl, perl scripts will run on it.


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

Date: Mon, 05 Jul 1999 13:26:36 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Help: simple questions
Message-Id: <3781ae46.2940629@news.skynet.be>

Scientia wrote:

>1) How can I deal with strings in PERL?
>In Basic I can use functions such as  left$(a$,3) or mid$(a$,5,2)
>but I do not know I can Make the same in PERL!

See the documentation on "substr". But you wouldn't want to do that.
Perl is FAR MORE POWERFUL with regards to strings, than Basic: it has
regular expressions, which mean that you can vaguely describe what kind
of data you expect, and Perl will get it for you. For example, if your
string should look something like

	var = 12.3

where var and the number may change, and the whitespace before and after
the "=" sign may differ, this pattern can do that for you:

	/([a-zA-Z]\w*)\s*=\s*(\d+\.?\d*|\.\d+)/

This means: 

	[a-Za-Z]	a variable's name must start with a letter
	\w*		followed by ANY number (incl. none) of letter,
digit or underscore
	(...)		keep the value in a (special) variable: if the
pattern matches, the variable's name will be stored into $1.

	\s*		optional whitespace (any number of tabs, spaces
or even newlines)
	=		the "=" sign
	\s*		optional whitspace

	\d+\.\d*	one or more digits, which MAY be followed by a
dot and (optionally) more digits, e.g. "123", "123.45", "123."
	|		OR (alternatively)...
	\.\d+		a dot plus some digits (at least one), e.g. ".5"
	(...|...)	grouping. Whichever matches, tht result will be
in $2.

Try it:

	$_ = "I tell you that AZ123= 12.15!";
	if(/([a-zA-Z]\w*)\s*=\s*(\d+\.?\d*|\.\d+)/) {
		print "Found: variable name = \"$1\" and value = $2\n";
	} else {
		print "No match.\n";
	}
-->
	Found: variable name = "AZ123" and value = 12.15

Let me tell you: once you tasted the power of regular expressions, you
never want to go back to the way of BASIC again.
	
>I know that "Scalar" variables may be either numbers or strings:
>this seems strange to me.

It is strange. It means that you can treat a number as if it was a
string.

	$var = 12 * 5;
	print substr($var,0,1);	# first character of $var
	# "0" -> number of characters before it
	# "1" -> wanted length
-->
	6

   HTH,
   Bart.


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

Date: Tue, 6 Jul 1999 00:18:34 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Help: simple questions
Message-Id: <MPG.11eb69c9c5e6f467989aed@news-server>

Bart Lateur writes ..
>where var and the number may change, and the whitespace before and after
>the "=" sign may differ, this pattern can do that for you:
>
>	/([a-zA-Z]\w*)\s*=\s*(\d+\.?\d*|\.\d+)/

cool .. watch his VB brain sizzle *B^)

-- 
 jason - remove all hyphens for email reply -


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

Date: 5 Jul 1999 15:22:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help: simple questions
Message-Id: <slrn7o24v3.h6v.abigail@alexandra.delanet.com>

Scientia (scientia@XXXtechnologist.com) wrote on MMCXXXIV September
MCMXCIII in <URL:news:37811B19.D77@XXXtechnologist.com>:
\\ Help: simple questions
\\ 
\\ Hello
\\ 
\\ I am learning PERL because I have to make very simple CGIs
\\ (I am already able to make very simple programs).
\\ 
\\ I have some questions and I hope that someone can help me.
\\ 
\\ 1) How can I deal with strings in PERL?

*boggle* Did you actually open any book about Perl? Read a single
manpage? Perhaps you should. This group isn't about spoonfeeding
Perl.

\\ In Basic I can use functions such as  left$(a$,3) or mid$(a$,5,2)
\\ but I do not know I can Make the same in PERL!
\\ I know that "Scalar" variables may be either numbers or strings:
\\ this seems strange to me.

They might be references too! Hurray. Now, go read the man page.
And if you don't like it, there are many languages out there offering
a gazillion different numerical types.

\\ 2) I have Win95 and I would like to test my PERL programs before
\\ uploading into my web site.
\\ I visited www.perl.org and through several links I found 
\\ "Active PERL" to download. But there are a lot of warnings that I do
\\ not understand. So my question is: what can I download, considering
\\ that I need something very simple, and that my programs will be
\\ short and simple?


Well, you download Perl. We can't explain the warnings if you don't
tell us what they are. There's no need to get ActiveStates Perl.
Grab the sources and compile.


Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

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

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


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