[16753] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4165 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 29 14:10:40 2000

Date: Tue, 29 Aug 2000 11:10:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967572625-v9-i4165@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 29 Aug 2000     Volume: 9 Number: 4165

Today's topics:
        output fun ankban4@my-deja.com
    Re: output fun (Mike Stok)
    Re: output fun <philipg@atl.mediaone.net>
    Re: output fun <sariq@texas.net>
    Re: output fun (Rafael Garcia-Suarez)
    Re: output fun (Greg Bacon)
        Perl/Apache <Steve.Torgeson@icebergoffice.com>
    Re: Perl/Apache <gellyfish@gellyfish.com>
    Re: Perl/Apache <rmore1@my-deja.com>
        PGP Redirecting Output sean31@my-deja.com
    Re: PGP Redirecting Output (brian d foy)
    Re: PGP Redirecting Output <nickco3@yahoo.co.uk>
    Re: Please help: How to check for $var is null or not? (Jon S.)
    Re: Please help: How to check for $var is null or not? (Hasanuddin Tamir)
    Re: Programming Ethics <bart.lateur@skynet.be>
        reading a line from the serial port <dale@icr.com.au>
    Re: reading a line from the serial port (Greg Bacon)
    Re: replace some word in text file (Hasanuddin Tamir)
        Searching for SQL statements (Philip Taylor)
    Re: selling perl to management reg_exp@my-deja.com
    Re: selling perl to management <bart.lateur@skynet.be>
    Re: The Hacker signature disciplin (Jakob Schmidt)
    Re: The Hacker signature disciplin <sariq@texas.net>
        TMTOWTDI - but how best to do this ?? reg_exp@my-deja.com
    Re: TMTOWTDI - but how best to do this ?? reg_exp@my-deja.com
    Re: Unclosed HTML Tags <jeff@vpservices.com>
        Variable masks earlier declaration <cresentmoon@geocities.com>
    Re: Variable masks earlier declaration <bill.kemp@wire2.com>
    Re: Wierd problem with CGI.pm <rmore1@my-deja.com>
    Re: Wierd problem with CGI.pm (Rafael Garcia-Suarez)
        Win32::ODBC Perl problem (Signal SEGV???) <rob_99@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 29 Aug 2000 13:21:47 GMT
From: ankban4@my-deja.com
Subject: output fun
Message-Id: <8ogdcm$56v$1@nnrp1.deja.com>

HI
Without using the formatting features , how do i print an output like
this . i tried but my code is too huge and ugly.

          ABCDEFGFEDCBA
          ABCDEF FEDCBA
          ABCDE   EDCBA
          ABCD     DCBA
          ABC       CBA
          AB         BA
          A           A

Thanks for your time.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 14:02:58 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: output fun
Message-Id: <moPq5.22973$K5.382602@typhoon.austin.rr.com>

In article <8ogdcm$56v$1@nnrp1.deja.com>,  <ankban4@my-deja.com> wrote:
>HI
>Without using the formatting features , how do i print an output like
>this . i tried but my code is too huge and ugly.
>
>          ABCDEFGFEDCBA
>          ABCDEF FEDCBA
>          ABCDE   EDCBA
>          ABCD     DCBA
>          ABC       CBA
>          AB         BA
>          A           A
>
>Thanks for your time.

What is too huge and too ugly?  What have you tried out?  It's not hard to
make a 4 line chunk of code do the work.  One algorithm might be

  foreach character position (length of string - 1 .. 0) {
      print string, reversed (string except last character), "\n";
      replace character at character position with ' ';
  }

There are many different ways to achieve the same result.  Once you have
an algorithm in mind then translating it into perl is not a difficult
problem.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Tue, 29 Aug 2000 14:05:06 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: output fun
Message-Id: <mqPq5.74$gg.60685@typhoon.southeast.rr.com>

<ankban4@my-deja.com> wrote in message news:8ogdcm$56v$1@nnrp1.deja.com...
> HI
> Without using the formatting features , how do i print an output like
> this . i tried but my code is too huge and ugly.
>
>           ABCDEFGFEDCBA
>           ABCDEF FEDCBA
>           ABCDE   EDCBA
>           ABCD     DCBA
>           ABC       CBA
>           AB         BA
>           A           A
>

my @letters = ('A'..'G');
my $space = '';
while (@letters) {
    print join( "", @letters, $space x 2, (reverse @letters), "\n");
    $space .= ' ';
    pop @letters;
}

Oops... just realized this doesn't exactly meet the criteria (prints two
G's), but I'm late for work and don't have time to fix it.  Maybe it'll get
ya started, though.

Philip




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

Date: Tue, 29 Aug 2000 10:21:23 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: output fun
Message-Id: <39ABD4F3.237B87CE@texas.net>

ankban4@my-deja.com wrote:
> 
> HI
> Without using the formatting features , how do i print an output like
> this . i tried but my code is too huge and ugly.
> 
>           ABCDEFGFEDCBA
>           ABCDEF FEDCBA
>           ABCDE   EDCBA
>           ABCD     DCBA
>           ABC       CBA
>           AB         BA
>           A           A
> 
> Thanks for your time.

Homework?

I'm sure that we'll see an elegant regexp solution, but here's a fairly
general solution using substr():

#!/usr/bin/perl -w

use strict;
my $str = shift || 'ABCDEFGFEDCBA';
my $len = length($str);
my $off = int($len / 2);

for (my $i=1; $i<=$len; $i+=2) {
        print "$str\n";
        substr($str,$off--,$i,' ' x $i);
} 

----

- Tom


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

Date: Tue, 29 Aug 2000 15:35:21 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: output fun
Message-Id: <slrn8qnm6n.6j9.rgarciasuarez@rafael.kazibao.net>

ankban4@my-deja.com wrote in comp.lang.perl.misc:
>HI
>Without using the formatting features , how do i print an output like
>this . i tried but my code is too huge and ugly.
>
>          ABCDEFGFEDCBA
>          ABCDEF FEDCBA
>          ABCDE   EDCBA
>          ABCD     DCBA
>          ABC       CBA
>          AB         BA
>          A           A
>
>Thanks for your time.

$_="ABCDEFGFEDCBA\n";print;print while y/G/ /||s/(\w)( *)\1/' 'x(2+length$2)/eg;

-- 
Rafael Garcia-Suarez


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

Date: Tue, 29 Aug 2000 17:21:51 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: output fun
Message-Id: <sqns9fa0c5d144@corp.supernews.com>

In article <8ogdcm$56v$1@nnrp1.deja.com>,
     <ankban4@my-deja.com> wrote:

: Without using the formatting features , how do i print an output like
: this . i tried but my code is too huge and ugly.
: 
:           ABCDEFGFEDCBA
:           ABCDEF FEDCBA
:           ABCDE   EDCBA
:           ABCD     DCBA
:           ABC       CBA
:           AB         BA
:           A           A

    #! /usr/bin/perl -w

    use strict;

    my $letters = "ABCDEFG";

    my $out = $letters . reverse $letters;
    $out =~ tr/A-Z//s;

    for (split //, reverse $letters) {
        print $out, "\n";

        eval "\$out =~ tr/$_/ /";
    }

Greg
-- 
The O-O languages give you more of course - prettier syntax, derived types and
so on - but conceptually they provide little extra.
    -- Rob Pike


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

Date: Tue, 29 Aug 2000 08:44:25 -0500
From: "SWT" <Steve.Torgeson@icebergoffice.com>
Subject: Perl/Apache
Message-Id: <u6Pq5.2304$Ulh8.34996619@news.randori.com>

Hi,

We are running DBI/DBD with Perl through Apache.  We are having problems
setting the needed Oracle environment variables.

Here is an example of how I am setting the variables in the perl program.
$ENV{'ORACLE_HOME'} = '/usr/oracle/product/8.1.5';

With all variables set, the program works fine, and pulls the requested data
out of the oracle instance.  The problem is whenever I try to have the
program run as a cgi through our Apache web server it will not set the
variables and thus the program will not run.

Has anyone else run into this problem?  Any ideas?

Thanks for your assistance.

Steve




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

Date: Tue, 29 Aug 2000 14:06:55 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl/Apache
Message-Id: <3sPq5.507$pD2.63265@news.dircon.co.uk>

On Tue, 29 Aug 2000 08:44:25 -0500, SWT Wrote:
> Hi,
> 
> We are running DBI/DBD with Perl through Apache.  We are having problems
> setting the needed Oracle environment variables.
> 
> Here is an example of how I am setting the variables in the perl program.
> $ENV{'ORACLE_HOME'} = '/usr/oracle/product/8.1.5';
> 
> With all variables set, the program works fine, and pulls the requested data
> out of the oracle instance.  The problem is whenever I try to have the
> program run as a cgi through our Apache web server it will not set the
> variables and thus the program will not run.
> 
> Has anyone else run into this problem?  Any ideas?
> 

Look in the Apache manual manual about SetEnv - if you need more help
about that ask in the group comp.infosystems.www.servers.unix ...

/J\


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

Date: Tue, 29 Aug 2000 14:34:09 GMT
From: Rich More <rmore1@my-deja.com>
Subject: Re: Perl/Apache
Message-Id: <8oghl0$a9u$1@nnrp1.deja.com>

In article <u6Pq5.2304$Ulh8.34996619@news.randori.com>,
  "SWT" <Steve.Torgeson@icebergoffice.com> wrote:
> Hi,
>
> We are running DBI/DBD with Perl through Apache.  We are having
problems
> setting the needed Oracle environment variables.
>
> Here is an example of how I am setting the variables in the perl
program.
> $ENV{'ORACLE_HOME'} = '/usr/oracle/product/8.1.5';
>
> With all variables set, the program works fine, and pulls the
requested data
> out of the oracle instance.  The problem is whenever I try to have the
> program run as a cgi through our Apache web server it will not set the
> variables and thus the program will not run.
>
Put:

SetEnv ORACLE_HOME /usr/oracle/product/8.1.5
PerlPassEnv ORACLE_HOME

in your httpd.conf file.

See
http://perl.apache.org/guide/index.html
http://perl.apache.org/guide/databases.html
http://thingy.kcilink.com/modperlguide/config/PerlSetVar_PerlSetEnv_and_
PerlP.html

for more info.

=============================
Richard More
http://www.richmore.com/


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 14:20:26 GMT
From: sean31@my-deja.com
Subject: PGP Redirecting Output
Message-Id: <8oggqj$9g4$1@nnrp1.deja.com>

I'm writing a perl CGI script that invokes the PGP command-line
utilities.  The problem I am having is when inovking these utilities, a
banner message is always printed out, and there doesn't seem to be a
switch to turn it off.  I tried redirecting the output to /dev/null, but
the banner message is still written to stdout.  Any ideas on how I can
get around this?  I do not want this banner to be part of the HTML that
I am returning to the end-user.

-Sean


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 10:52:16 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: PGP Redirecting Output
Message-Id: <brian-ya02408000R2908001052160001@news.panix.com>

In article <8oggqj$9g4$1@nnrp1.deja.com>, sean31@my-deja.com posted:

> I'm writing a perl CGI script that invokes the PGP command-line
> utilities.  The problem I am having is when inovking these utilities, a
> banner message is always printed out, and there doesn't seem to be a
> switch to turn it off. 

which version of PGP?

there should be a batch mode.  look at the command line switches
to find it.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Tue, 29 Aug 2000 17:06:30 +0100
From: Nick Condon <nickco3@yahoo.co.uk>
Subject: Re: PGP Redirecting Output
Message-Id: <39ABDF86.13D6A30C@yahoo.co.uk>

sean31@my-deja.com wrote:

> I'm writing a perl CGI script that invokes the PGP command-line
> utilities.  The problem I am having is when inovking these utilities, a
> banner message is always printed out, and there doesn't seem to be a
> switch to turn it off.  I tried redirecting the output to /dev/null, but
> the banner message is still written to stdout.  Any ideas on how I can
> get around this?  I do not want this banner to be part of the HTML that
> I am returning to the end-user.

I don't have pgp so I can't say for sure, but it's probably writing to
STDERR



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

Date: Tue, 29 Aug 2000 16:01:53 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Please help: How to check for $var is null or not?
Message-Id: <39abdc8f.8235098@news.earthlink.net>

On 29 Aug 2000 07:13:09 +0100, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

>On Mon, 28 Aug 2000 19:17:26 GMT kiran_mamidi@my-deja.com wrote:
>> Hi Guys
>> I need help with the following.
>> 
>> How do I check if a variable is null.
>> 
>> 
>> For example if I want to check $rec_date is null or not. How do I do
>> that,
>> 
>
>Firstly you have to determine what you mean by 'null' - do you mean that
>it contains the empty string :
>
>   if ( $var eq '' )
>   {
>   }
>
>Or whether it contains an undefined value :
>
>   if ( not defined $var )
>   {
>   }
>
>You might also check the length of the contents of the variable :
>
>  if ( not length $var )
>  {
>  }

I've been using a scheme (after help from Larry and others a few weeks
ago) of naming $fooOK = "yes"; only on conditions where $foo actually
is okay.

So, I'll go...
my ($foo, $fooOK);
if ($foo eq "foocriteria") {$fooOK = "yes"}

In my checks, then, I use 
if ( $fooOK ) {print "foo's okay"}

Or

if ( !$fooOK ) {print "bad foo"}

(I use the !$fooOK when I have to do more complex boolean logic and
unless doesn't fit right, that's just an example)

Is this acceptable shorthand for what I'm doing, or am I leaving
something out not using the defined() or length() functions?

(Sorry if I forgot any ;'s, I usually catch those when I run the
script!  Still a newbie...)

Jon


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

Date: Wed, 30 Aug 2000 07:45:08 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: Please help: How to check for $var is null or not?
Message-Id: <slrn8qnu14.84f.hasant@borg.intern.trabas.co.id>

On Tue, 29 Aug 2000 16:01:53 GMT, jonceramic@nospammiesno.earthlink.net wrote:
[snipped]
> So, I'll go...
> my ($foo, $fooOK);
> if ($foo eq "foocriteria") {$fooOK = "yes"}

There are several shorthand alternatives,

    $fooOK = 1 if $foo eq "foocriteria";
    $fooOK++   if $foo eq "foocriteria";
    $fooOK =      $foo eq "foocriteria";

san
-- 
trabasLabs * hasant@trabas.com * http://www.trabas.com
Zero Point * hasant@zp.f2s.com * http://www.zp.f2s.com


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

Date: Tue, 29 Aug 2000 14:05:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Programming Ethics
Message-Id: <jognqs8u2rg5jlbgke3j3sh2ecjolmsqpk@4ax.com>

JL Goldstein wrote:

>Hey, I happen to like Brussels sprouts! When properly prepared (steamed
>to tenderness and topped with butter), they are divine....

No they're not. I hate them. Chocolate on the other hand...

(Note: I'm from Belgium. Brussels isn't too far from here.)

-- 
	Bart.


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

Date: Wed, 30 Aug 2000 00:36:33 +1000
From: Dale Walker <dale@icr.com.au>
Subject: reading a line from the serial port
Message-Id: <39ABCA71.6595D445@icr.com.au>


Hi guys, I'm trying to read and manipulate the logging output from our
phone system (attached via serial port)...

I had a shell script that did this by:

----------------
#!/bin/sh
exec </dev/cuaa1
while read Line; do

	echo $Line|insert to database,etc....

done
-----------------


I'm trying to re-write in perl....

I have got my main 'workings' sorted out OK, and tested by:
------------------
#!/usr/bin/perl
open (IN,"/tmp/test.dat");
while (<IN>) {

	yada yada,etc...

}
---------------------

now, I need to get my perl script to start looking at the serial line
for input..

I have tried 'open (IN,"/dev/cuaa1");' but it doesn't like it..

do I have to use Fcntl or am I missing something?? If I have to use
Fcntl, does anyone have any code snippets??

Thanks in advance..

-- 
Dale Walker                                              dale@icr.com.au


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

Date: Tue, 29 Aug 2000 16:39:32 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: reading a line from the serial port
Message-Id: <sqnpq44ec5d180@corp.supernews.com>

In article <39ABCA71.6595D445@icr.com.au>,
    Dale Walker  <dale@icr.com.au> wrote:

: Hi guys, I'm trying to read and manipulate the logging output from our
: phone system (attached via serial port)...

Have you seen the entry in Section 8 of the FAQ that deals with
serial communication?

Greg
-- 
A lawyer is an expert on justice in the same way that a whore is an expert on
love.


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

Date: Wed, 30 Aug 2000 04:42:37 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: replace some word in text file
Message-Id: <slrn8qnibc.734.hasant@borg.intern.trabas.co.id>

On Tue, 29 Aug 2000 14:39:02 +0400, ps@sbor.ru wrote:
## sorry for stupid question
## Is it possible to replace some word directly in text file (without coping
## file content to an array)?

Like this example?

-----file.txt----
I like VB.
I use VB.
-----------------

And then from the command line,

    perl -pi.bak -e 's/VB/Perl/' file.txt

Of course the substitution needs to be modified depends
how complex the replacement you want and the file itself.

HTH
san
-- 
trabasLabs * hasant@trabas.com * http://www.trabas.com
Zero Point * hasant@zp.f2s.com * http://www.zp.f2s.com


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

Date: Tue, 29 Aug 2000 17:36:59 GMT
From: phil.taylor@bigfoot.com (Philip Taylor)
Subject: Searching for SQL statements
Message-Id: <39abf2e4.15430261@news.btinternet.com>

I'm trying to analyse a large number of Ingres OpenROAD program source
files for SQL statements to produce information such as number of
SELECTS/INSERTS etc and which tables are used. I have several hundred
program export files to analyse.

I wondered if there are any  Perl facilities that can identify SQL
statements in a source file? 

Any help appreciated 	

Phil


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

Date: Tue, 29 Aug 2000 14:58:53 GMT
From: reg_exp@my-deja.com
Subject: Re: selling perl to management
Message-Id: <8ogj2v$c4i$1@nnrp1.deja.com>

thanks to the whole group for their contributions and the discussion -
there were a few differences of opinions there, but i think everybody
would be glad to know (i sure am happy !!) that:

my management has decided to implement the project using perl and have
agreed to my design !! my presentation went of well, and what they
basically said was "we cant argue with the numbers" the numbers being
the fact that:
* the perl code was 10 times smaller than the C code
* the perl code was 2 times as fast as the C code

thanks a lot for your valuable inputs,
thanks
-  reg_exp


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 15:18:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: selling perl to management
Message-Id: <5vknqsok96et9scdialqnesfoq5m1q3nba@4ax.com>

reg_exp@my-deja.com wrote:

>what they
>basically said was "we cant argue with the numbers" the numbers being
>the fact that:
>* the perl code was 10 times smaller than the C code
>* the perl code was 2 times as fast as the C code

Gee, that's what you knew when you fired this question.

The fact that the programming itself will go quite a lot faster in Perl
than doing the same in C, is very important to most people here.

-- 
	Bart.


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

Date: Tue, 29 Aug 2000 15:06:54 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: The Hacker signature disciplin
Message-Id: <1eg4rty.calmrjmbdtsN@[192.168.88.117]>

Chris Boyd <cboyd@holyrood.ed.ac.uk> wrote:

> "Just Another Perl
> Hacker" or "Just Another 
> Perl Haiku"?  Your choice.

Hehe

You just reminded me of the Black Perl poem in the Camel Book (at least
the version I read).

Any news of that disciplin?

-- 
Jakob

package p;sub TIESCALAR{shift;shift&&print tie$p,p,@_;shift};
tie$p,p,p,p,split//=>"\nrekcaH lreP rehtona tsuJ";


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

Date: Tue, 29 Aug 2000 09:09:21 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: The Hacker signature disciplin
Message-Id: <39ABC411.4C8AE536@texas.net>

Abigail wrote:
> 
> Jakob Schmidt (sumus@aut.dk) wrote on MMDLIV September MCMXCIII in
> <URL:news:1eg3nmp.17nqhqm1lkr7ggN@[192.168.88.117]>:
> !!
> !! I find myself wondering if there are some written or unwritten rules
> !! about the "Just another Perl Hacker" sig that some posters use?
> 
> From my JAPH talks:

Loses a bit without the actual talking I'm sure, but still fun and
educational.  Slides at:

http://ucan.foad.org/~abigail/Perl/Talks/Japhs/

- Tom


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

Date: Tue, 29 Aug 2000 17:11:45 GMT
From: reg_exp@my-deja.com
Subject: TMTOWTDI - but how best to do this ??
Message-Id: <8ogqrs$md8$1@nnrp1.deja.com>

hi,

i have a problem that is somewhat like calculating a check sum, i've
detailed it below.

i want to know how best and elegantly i can do this task - i feel there
should be a neat way by using the "map" and "split" functions, but i'm
too new to know how to exactly do it....

please help,
thanks,
- reg_exp

PROBLEM
-------
the task is: (this sounds complex in words, theres an example below
that will clarify it) -

for each digit of an eight digit number, multiply the digits
alternately by 1 and 2 and sum each digit of the result. subtract the
result from the next highest number divisible by 10 and make a 9 digit
number with the original 8 digit number + the calculated digit.

for eg: for the 8 digit number

04 997 7473 -
multiplying alternately by 1,2 we get :

 0  4  9  9  7  7  4  7  3
x1  2  1  2  1  2  1  2  1
--------------------------
 0  8  9  18 7  14 4  14 3

summing the digits of each number we get (note 18 is 1+8):
0+8+9+1+8+7+1+4+4+1+4+3 = 47
next highest number divisible by 10 without remainder = 50
last digit = 50-47 = 3

so final number = 04 997 7473 3



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 17:21:38 GMT
From: reg_exp@my-deja.com
Subject: Re: TMTOWTDI - but how best to do this ??
Message-Id: <8ogre9$n5k$1@nnrp1.deja.com>

whoops, sorry, the example should be:

for eg: for the 8 digit number

04 997 747 -
multiplying alternately by 1,2 we get :

0  4  9  9  7  7  4  7
x1  2  1  2  1  2  1  2
------------------------
0  8  9  18 7  14 4  14

summing the digits of each number we get (note 18 is 1+8):
0+8+9+1+8+7+1+4+4+1+4 = 47
next highest number divisible by 10 without remainder = 50
last digit = 50-47 = 3

so final number = 04 997 747 3



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 09:18:37 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Unclosed HTML Tags
Message-Id: <39ABE25D.DBC5E13E@vpservices.com>

Ilmari Karonen wrote:
> 
> In article <RGzq5.5228$EB2.117717@news2-win.server.ntlworld.com>, Tazz wrote:
> >I have a news Perl scrpt im working on, a user fills out a form, submits
> >it, and then it is later displayed with all the news items on one page,
> >the problem is this: if someone forgets to close an HTML tag in their
> >post (they use <b> but forget to add the </b> end tag) it makes the
> >entire page bold.
> 
> Parse the HTML, using HTML::Parser (or HTML::TokeParser).  Toss out
> any tags you don't recognize as safe.  Add missing end tags if you
> like.  Complain if parsing fails.
> 

Ilmari's suggestion is a good one if you go the Perl route.  You might
also look at Dave Raggett's "tidy.exe" which can clean up that and many
other kind of HTML slopinesses.

	http://www.w3.org/People/Raggett/tidy/  

But I will second and third Jason's response about user inputed HTML. 
There are many security issues involved in letting users enter HTML on
forms.

-- 
Jeff


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

Date: Tue, 29 Aug 2000 14:55:58 GMT
From: Farouk Khawaja <cresentmoon@geocities.com>
Subject: Variable masks earlier declaration
Message-Id: <8ogith$bro$1@nnrp1.deja.com>

Hi All,

I'm getting the following error.

"my" variable $config masks earlier declaration in same scope at
 ./createIBVUser.cgi line 240.
syntax error at ./createIBVUser.cgi line 241, near "my "
Global symbol "$result" requires explicit package name at
 ./createIBVUser.cgi line 241.
Missing right bracket at ./createIBVUser.cgi line 362, at end of line
Execution of ./createIBVUser.cgi aborted due to compilation errors.

Line 240 is:
238   sub addEntry($$)
239   {
240   my ($config, $t) = @_;
241   my ($result);

To me this looks like a bracketing problem but I've matched up all the
brackets.  Or so I think.

There is a $config variable in the subroutine preceeding this one, and
if I change the name of that $config variable, this error goes away, and
it only complains about a missing bracket.

I'm appending the preceeding subroutine in hopes that your eyes may see
what I cannot.  Any help would be appreciated.

I appologize in advance for including all this code in this posting.

 ##################################################################
# Subroutine: missingFieldValue -                                  #
#   will add new entries to LDAP server                            #
 ##################################################################
sub missingFieldValue($$$)
{
 my ($missingValue, $q, $config) = @_;
 my ($k, @allSubmitedFields);

 BookMarkHeader($q, $config);
 print
    br,br,br,
    $q->table({-width=>'550',
               -border=>'0',
               -cellspacing=>'2',
               -cellpadding=>'2'},
              td({-align=>'left',
                  -valigh=>'top',
                  -width=>'100'},
                  $q->font({-face=>'arial',
                            -size=>'5',
                            -color=>'red'},
                       -strong("Missing Field")),br,
                  $q->font({-face=>'arial',
                            -size=>'2',
                            -color=>'black'},
                       "$missingValue is a required field.  Please ",
                       "complete all required fields before submiting"),
                )
             ),
    $q->startform(-method=>'post',
                  -action=>$$config{'GENERATEREGISTRATIONLOCATION'},
                  -enctype=>'multipart/form-data');

    @allSubmitedFields = param;
    foreach $k (@allSubmitedFields)
    {
       print $q->hidden(-name=>$k,
                        -default=>param($k));
    }

    print $q->submit(-name=>'returntoreg',
                     -value=>'Complete Registration'),
    $q->end_form,
    $q->table({-width=>'610',
               -border=>'0',
               -cellspacing=>'2',
               -cellpadding=>'2'},
            tr(
              td({-colspan=>'2'
                  -align=>'center',
                  -valign=>'top',
                  -width=>'610'},
                 $q->img({-src=>$$config{'BOTTOMSRC'},
                          -width=>'610',
                          -height=>'84'}),
                 $q->p({-align=>'center'}),
                 $q->font({-face=>'Verdana, Arial, Helvetica,
sans-serif',
                            -size=>'1'},
                      "$$config{'COPYRIGHT'}")
                )
              )
             ),
    $q->end_html;
}



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 17:10:22 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Variable masks earlier declaration
Message-Id: <967565620.7723.0.nnrp-03.c3ad6973@news.demon.co.uk>

>"my" variable $config masks earlier declaration in same scope at
>./createIBVUser.cgi line 240.
>syntax error at ./createIBVUser.cgi line 241, near "my "
>Global symbol "$result" requires explicit package name at
>./createIBVUser.cgi line 241.
>Missing right bracket at ./createIBVUser.cgi line 362, at end of line
>Execution of ./createIBVUser.cgi aborted due to compilation errors.
>
>Line 240 is:
>238   sub addEntry($$)
>239   {
>240   my ($config, $t) = @_;
>241   my ($result);
>
>To me this looks like a bracketing problem but I've matched up all the
>brackets.  Or so I think.

<snip>

It is a bracketing problem.  Innacurate typing and silly errors being a
forte of mine.
I have seen this one a few times.  Your code might not help because the
missing brackets might be before many of the other subroutines.

I suggest you cut and paste (or vi ...) your code into sensible chunks and
'perl -c' them to find where the odd bracket is.
I did see a nice text editor once that coloured in the different levels of
brackets, but I didn't get what it was.




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

Date: Tue, 29 Aug 2000 14:42:08 GMT
From: Rich More <rmore1@my-deja.com>
Subject: Re: Wierd problem with CGI.pm
Message-Id: <8ogi3q$b00$1@nnrp1.deja.com>

In article <slrn8qnb2i.2h9.rgarciasuarez@rafael.kazibao.net>,
  rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
> Andy Holyer wrote in comp.lang.perl.misc:
> [...]
> >
> >The first line is
> >
> >$query = CGI->new();
> >
> >This should pop up a command-line interface to allow me to type in
the
> >params.
> >
> >But it doesn't. I know this sounds lame, but it doesn't. The new()
method
> >just returns.
>
> Have you upgraded CGI.pm recently?
> And, in this case, have you tried :
>     use CGI qw/-debug/;
CGI.pm allows you to enter name value pairs when the first method you
call ( ie param() ) is invoked.

--
=============================
Richard More
http://www.richmore.com/

--
=============================
Richard More
http://www.richmore.com/


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 29 Aug 2000 15:02:02 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Wierd problem with CGI.pm
Message-Id: <slrn8qnk87.6cv.rgarciasuarez@rafael.kazibao.net>

Rich More wrote in comp.lang.perl.misc:
>> Have you upgraded CGI.pm recently?
>> And, in this case, have you tried :
>>     use CGI qw/-debug/;
>CGI.pm allows you to enter name value pairs when the first method you
>call ( ie param() ) is invoked.

Yes, I know. But you didn't answer my question.
With CGI.pm 2.72,
  perl -MCGI -e 'new CGI'
terminates immediately, and
  perl -MCGI=-debug -e 'new CGI'
asks for name=value pairs on standard input.

-- 
Rafael Garcia-Suarez


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

Date: Tue, 29 Aug 2000 17:08:55 GMT
From: Robert Brown <rob_99@my-deja.com>
Subject: Win32::ODBC Perl problem (Signal SEGV???)
Message-Id: <8ogqmk$m2g$1@nnrp1.deja.com>

Hi,

Trying to run Win32::ODBC using ActiveState perl on my laptop, I
intatially had problems with PerlCRT.dll (which I think I've fixed by
DLing from CPAN and puting into c:/perl/bin).  I have also put
perlCRT.lib in c:/perl/lib and c:/perl/site/lib (is this the right
place?).

Anyway, now I get get a different error trying to use Win32::ODBC,
refer below.

Any help would be much appreciated,


Rob

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-1999 Microsoft Corp.

C:\>perl -de 0
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main::(-e:1):   0
  DB<1> use Win32::ODBC;
Signal SEGV at (eval 4)[C:/Perl/lib/perl5db.pl:1510] line 2
        main::BEGIN() called at C:/Perl/lib/DynaLoader.pm line 0
        eval {...} called at C:/Perl/lib/DynaLoader.pm line 0
        eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main;
$^D = $^D | $DB::db_s
top;
use Win32::ODBC;;

;' called at C:/Perl/lib/perl5db.pl line 1510
        DB::eval called at C:/Perl/lib/perl5db.pl line 1389
        DB::DB called at -e line 1

C:\>ppm
PPM interactive shell (2.0) - type 'help' for available commands.
PPM> query
Archive-Tar   [0.072] module for manipulation of tar archives.
Compress-Zlib [1.03 ] Interface to zlib compression library
HTML-Parser   [2.23 ] SGML parser class
MIME-Base64   [2.11 ] Encoding and decoding of base64 strings
PPM           [2    ] Perl Package Manager: locate, install, upgrade
software
                      packages.
URI           [1.04 ] Uniform Resource Identifiers (absolute and
relative)
Win32-ODBC    [0.03 ] ODBC implementation
XML-Element   [1.07 ] Base element class for XML elements
XML-Parser    [2.27 ] A Perl module for parsing XML documents
libwin32      [0.16 ] A collection of extensions that aims to provide
                      comprehensive access to the Windows API.
libwww-perl   [5.45 ] Library for WWW access in Perl
PPM>exit
C:\>perl -v

This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 616 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 13:47:17 Jul 14 2000


Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to
the
Internet, point your browser at http://www.perl.com/, the Perl Home
Page.


C:\>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4165
**************************************


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