[11050] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4650 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 14 13:03:22 1999

Date: Thu, 14 Jan 99 10:00:32 -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           Thu, 14 Jan 1999     Volume: 8 Number: 4650

Today's topics:
    Re: @ARGV and $_ Question <tbriles@austin.ibm.com>
    Re: @INC - Path on Win32 <matthew.sergeant@eml.ericsson.se>
    Re: __DATA__ (Tad McClellan)
    Re: A book abot Perl. (Tad McClellan)
    Re: A book abot Perl. (Abigail)
        Calculating to Decimal Places <r2-d2@REMOVEbigfoot.com>
    Re: Calculating to Decimal Places (brian d foy)
    Re: Can I use perl with https? jhall@idiglobal.com
    Re: changing text in files probs (Tad McClellan)
        Clean Perl Script exiting Michael.Hudacko@revlon.com
    Re: Data Structure Notation <jeromeo@atrieva.com>
    Re: determine, if file is directory jhall@idiglobal.com
        Dynamic HASHES :-(( <stefan.nonneman@cec.be>
        FORM to two different CGI? <globus@infonet.ee>
    Re: FORM to two different CGI? <ringwood@berbee.com>
    Re: FORM to two different CGI? (Adrian Price)
    Re: Help CGI times out (doc contains no data) (jim barchuk)
    Re: Help please..bad file handle error <dave@icepop.demon.co.uk>
    Re: Help please..bad file handle error <eugene@snailgem.org>
        leading zeros <studmail@dutwmail.wbmt.tudelft.nl>
    Re: leading zeros <tbriles@austin.ibm.com>
    Re: leading zeros (brian d foy)
    Re: Logic flow (Larry Rosler)
    Re: max. length of perl regexp (Tad McClellan)
    Re: max. length of perl regexp <aqumsieh@matrox.com>
    Re: max. length of perl regexp (Snowhare)
    Re: mkdir with specified owner or group (Greg Ward)
        Module Date:Interval documentation nguyen.van@imvi.bls.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 14 Jan 1999 09:21:59 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: @ARGV and $_ Question
Message-Id: <369E0B96.68A9BE7F@austin.ibm.com>

Brad wrote:

> That was incredible help...Thank you so much for answering my question! I
> never thought of reading the documentation...how stupid of me?!
>
> Don't you think I read the documentation and still didn't quite understand?
> Or are you just some kind of a smart-ass? If you aren't going to be of any
> help just stay out of newsgroups. You aren't helping me or anyone else who
> might have the same question or having the same problem.
>
> You must be some kind of expert and if that is the case maybe you should be
> writing the documentation or spending your time more wisely by writing code.
>
> Maybe to feel good about yourself by putting other people down or by stating
> the obvious. I wish you many years of good fortune.
>
> Once again, cheers Andre, your the best.
>
> Brad
>
> Andre L. wrote in message ...
> >In article <77j8bf$kgg$1@news.monad.net>, "Brad" <roclimb@yahoo.com> wrote:
> >
> >> Could someone give me a good definition of these two items and a couple
> good
> >> examples? Or point me in the direction where I can find good definition
> and
> >> examples.
> >
> >How about... the documentation? :)
> >
> >Andre

Brad -

What documentation did you read?

Did you try "perldoc perlvar"?  That gives a very reasonable definition of both
"$_" and "@ARGV".

If you did read that entry, and still have questions, you need to be more
specific about what parts of the definition(s) are unclear to you.

It's always a good idea to "lurk" in a group for a bit before posting.  If you
had, you would have seen that this particular newsgroup is a stickler for
reading the documentation.  The reasoning is simple...Perl has terrific on-line
documentation, so try there first - always.

Andre's response was much friendlier than the responses you could have gotten
(and may well still get) from other regular posters to this newsgroup.  And it
was also a very valid post, by the way.  You owe him an apology.

- Tom




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

Date: Thu, 14 Jan 1999 17:28:51 +0000
From: Matt Sergeant <matthew.sergeant@eml.ericsson.se>
Subject: Re: @INC - Path on Win32
Message-Id: <369E2953.87315D39@eml.ericsson.se>

"Jvrg Dolle" wrote:
> 
> Who can help me with this entry?
> 
> C:\>perl -e "print (@INC)"
> C:\PERL\5.005\lib/MSWin32-x86-objectC:\PERL\5.005\libC:\PERL\site\5.005\lib/
> MSWi
> n32-x86-objectC:\PERL\site\5.005\libC:\PERL\site\lib.
> 
> How could I change "/" to "\" in the @INC variable?

s/\//\\/g;

But why would you want to? Win32 perl accepts either \ or / as path
delimiters, even mixed up like this.

-- 
<Matt email="matt@teamamiga.org" />

| Fastnet Software Ltd              |   Perl in Active Server Pages   |
| Perl Consultancy, Web Development |   Database Design   |    XML    |
| http://come.to/fastnet            |    Information Consolidation    |


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

Date: Thu, 14 Jan 1999 09:22:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: __DATA__
Message-Id: <032l77.ula.ln@magna.metronet.com>

James B Crigler (james.b.crigler@lmco.com) wrote:
: Abigail wrote:

: > If you don't have the man pages, you don't have perl.

: Though the docs come with perl, it does not follow necessarily that they
: are available to users.


   Then whoever decided to withhold that information should be
   made aware of their error.

   Each and every user should send email to the system administrator
   for each and every Perl question that occurs to them.

   Eventually, the sysadmin will either install the docs or quit.

   Repeat with the replacement until you come across a clever one...

   ;-)


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


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

Date: Thu, 14 Jan 1999 08:51:27 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: A book abot Perl.
Message-Id: <f90l77.tba.ln@magna.metronet.com>

Sergey (y@mail.ru) wrote:

: Please, tell me where I can get an electronic book  about the language. 


   http://language.perl.com/info/documentation.html


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


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

Date: 14 Jan 1999 17:11:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: A book abot Perl.
Message-Id: <77l8gh$m6r$1@client2.news.psi.net>

Sergey (y@mail.ru) wrote on MCMLXII September MCMXCIII in
<URL:news:77kol2$n8d@green.kosnet.ru>:
&& Hi, guys!
&& Please, tell me where I can get an electronic book  about the language. I am
&& just starting learning it so I need much inforation and help... Thanking in
&& anticipation your answer.


man perl



Abigail


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

Date: Thu, 14 Jan 1999 16:57:09 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Calculating to Decimal Places
Message-Id: <77l7p5$l1a$1@plug.news.pipex.net>

Hi all

How can you calculate something to a certain number of decimal points?  eg:
2038/58 calculated to two decimal places rather than 14 places.

Thanks for any help
Artoo




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

Date: Thu, 14 Jan 1999 13:06:06 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Calculating to Decimal Places
Message-Id: <comdog-ya02408000R1401991306060001@news.panix.com>

In article <77l7p5$l1a$1@plug.news.pipex.net>, "Artoo" <r2-d2@REMOVEbigfoot.com> posted:

> How can you calculate something to a certain number of decimal points?  eg:
> 2038/58 calculated to two decimal places rather than 14 places.

Perl is going to calculate it to whatever precision it likes.  you can,
however, print or format it it with as many decimal places as you like,
as shown in the first answer perlfaq4.

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


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

Date: Thu, 14 Jan 1999 17:03:53 GMT
From: jhall@idiglobal.com
Subject: Re: Can I use perl with https?
Message-Id: <77l81j$93m$1@nnrp1.dejanews.com>

In article <77jo8d$3td@q.seanet.com>,
  "allen snook" <circuit@seanet.com.nospam> wrote:
> Hi all,
>
> I'm in the process of putting together a secure perl script, but I want the
> script to be run in an encrypted mode.  In my HTML that kicks off the
> script, I have a form call as follows:
>
> <FORM ACTION="https://www.charm.net/~seattle/cgi-bin/ss.pl" METHOD=POST>
>
> When I click on ye olde submit button, I get the following error
>
> Method Not Allowed
> The requested method POST is not allowed for the URL /~seattle/cgi-bin/ss.pl
>
> The permissions on the file are 755, of course.  If I replace the https with
> http, it works fine, but obviously it is no longer secure.
>
> Is this a problem with my ISP, or perl?  My ISP hasn't answered my question
> yet.
>
> Thanks
>
> ...Allen
> circuit@seanet.com.nospam
>
>


There is no problem with Perl and secure.  I do it all the time at my work. 
Try this, of course replacing the xx's with your location... <FORM
ACTION="https://www.xxxx" METHOD="POST"
ENCTYPE="application/x-www-form-urlencoded">

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 14 Jan 1999 08:47:10 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: changing text in files probs
Message-Id: <e10l77.tba.ln@magna.metronet.com>

Stephen Howe (stephen@bcl.com) wrote:

: I have a problem I hope you can please help me with.
: A program of mine doesn't work and this is how it goes:

: Discover names of files in a certain directory
: (c:\ftgate\spool\inbox).


   opendir(DIR, 'c:\ftgate\spool\inbox') || 
      die "could not opendir 'c:\ftgate\spool\inbox'  $!";


: Store filenames in an array.


   @filenames = grep -f "c:\ftgate\spool\inbox/$d_", readdir(DIR);
   closedir(DIR);


: Open a filename from array and see if they have a line containing
: "bcl"

: If the file has bcl in one of it's lines, replace it with "betsy.bcl".

: Close file and check the next file in the array.


   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?"


: This is the actual program code... (mesg follows below)

: system "cd \\ftgate\\spool";


   If you use single quotes you won't have to do all that
   escaping of the escapes.

   The system() might fail you know.

   You should do something graceful if it fails rather than
   plowing on...

      system 'cd \ftgate\spool' and die "could not change directory  $!";


: system "dir \\ftgate\\spool\\inbox\\*.ftw >\\ftgate\\spool\\dir.txt";

   This might fail too...

: open (DIRFILE,"<\\ftgate\\spool\\dir.txt");

   This might fail too...

: while ($line=<DIRFILE>)
: {  
:    if ($line=~/ftw/)
:    {
:       $pos=index($line, "f99");
:       print "pos $pos\n";
:       $filename1=substr($line, $pos, 25);


   You don't need the $pos temporary variable:

      $filename1=substr($line, index($line, "f99"), 25);


:       $files[$fileloop]=$filename1;
:       $fileloop=$fileloop+1;

   The common idiom in Perl for the above is:

      push @files, $filename1;


:    }
:    else
:    {}

   Why include a do-nothing else block?


: }
: close DIRFILE;
: print "4\n";
: while ($loopcheck<$fileloop)
: {
:    $filename=$files[$loopcheck];


   The common idiom in Perl for the above is:

      foreach $filename (@files)

   No need to explicitly index the array.


:    print "filename $filename\n";
:    open (FTWFILE,">/ftgate/spool/inbox/$filename");

   This might fail too...

:    while ($line=<FTWFILE>)


   You opened the file for writing (unless the open() failed. But 
                                    you'll never know because you
                                    did not check the return value)

   Here you are trying to _read_ from it.



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


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

Date: Thu, 14 Jan 1999 15:58:15 GMT
From: Michael.Hudacko@revlon.com
Subject: Clean Perl Script exiting
Message-Id: <77l46i$5ea$1@nnrp1.dejanews.com>

My current (new toPerl) project involves formating raw data into several
files for subsequent database loading.
I designed a main routine (initially)
that executed from top to bottom. After review I recognized the need to a
more modular approach (w/subroutines).
 My question is: how can I exit/die
when conditionsare appropriate? 

When the script was one long procedure an
if-elsif-elseconstruct included an --	if (condition) then "die" logic----.
With it modularized, with the calling of subs, I would like an elegant way
of testing the return value of a sub and CEASE execution of subsequent calls
to subs.See example below: Are there other ways?

#MAIN
$ret_val1 = &sub1;
$ret_val2 = &sub2;if ($ret_val2) {
  die();
}else{
  &sub3;
  &sub4;
}

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 14 Jan 1999 09:27:53 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Data Structure Notation
Message-Id: <369E2919.EA6E8892@atrieva.com>

Daniel Grisinger wrote:
> 
> Jerome O'Neil <jeromeo@atrieva.com> writes:
> I wanted to add some
> > notes to explain what the various data structures represent, and I
> > wasn't able to come up with a notation that was very satisfying.
> 
> If your data structures have gotten complex enough that you have
> to think about notation it's time to move past simple 80 column
> ascii to show them.  
>
> Take a look at perlguts illustrated (http://home.sol.no/~aas/perl/guts/)
> for a good example of how visual depictions of data can be used.

First let me say that you have put together some fantastic images. 
However, I am really looking for something I can embed in my code,  so,
ASCII is the media of choice.

I think I have decided that as long as I represent the data type
accurately, and use good names and a consistent blocking method, I'll be
OK.

%names => {%projects => @($lead, @personel($one,$two,...),
%accounts=>{$acount_number})}

Yes?

Anyway, what did you use to create the images in your page?  I have *no*
talent for imaging, so things like that have never been easy for me.

Thanks!
 
-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Thu, 14 Jan 1999 17:07:03 GMT
From: jhall@idiglobal.com
Subject: Re: determine, if file is directory
Message-Id: <77l87f$97h$1@nnrp1.dejanews.com>

In article <369d3cdb.31341568@129.217.240.1>,
  pat@uni.de (Patrick Clauberg) wrote:
> Hi folks,
>
> i would like to do a recursive search over a directory.
> Has readdir() a parameter to execute it recursively?
>
> I would like to check every file in the direcory, and if any file is a
> directory itself, I start the check function with the new path.
>
> A Perl Book tells me: if (-d $filename) { ....
>
> should work.
>
> Another one is the stat function.
>
> Both of them don't seem to work
>
> how can it be?
>
> I have a perl 5.004 on a Linux 2.0.33 machine
>
> Thanx
>
> Patrick
>
>

Well I use the if(-d $filename) in some scripts and it seems to work perfect.
If it's a directory it shoud enter the routine.

Jayce^

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 14 Jan 1999 18:37:40 +0100
From: Stefan Nonneman <stefan.nonneman@cec.be>
Subject: Dynamic HASHES :-((
Message-Id: <369E2B51.C2DAD817@cec.be>

Is it possible to append data pairs to existing hashes when a key is not
found?
>From the documentation it is not clear to me.

Thanks in advance,

Stefan



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

Date: Thu, 14 Jan 1999 17:09:18 +0200
From: Gleb Ekker <globus@infonet.ee>
Subject: FORM to two different CGI?
Message-Id: <369E089E.F93FE52@infonet.ee>

Hi,

Please help me!  I have FORM on my page which is need to be sent to two
different CGI scripts on two different servers.  Is it possible to put
two URLs in <FORM ACTION=...>,  or there is some other way to fix this
problem?

Thanks,
                            Gleb.





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

Date: Thu, 14 Jan 1999 10:41:09 -0600
From: Tim <ringwood@berbee.com>
Subject: Re: FORM to two different CGI?
Message-Id: <369E1E25.534B@berbee.com>

Gleb Ekker wrote:
> 
> Hi,
> 
> Please help me!  I have FORM on my page which is need to be sent to two
> different CGI scripts on two different servers.  Is it possible to put
> two URLs in <FORM ACTION=...>,  or there is some other way to fix this
> problem?
> 

Send it to the first, do the CGI work, then do a location in the
1st script to go to the 2nd. (That's what I do, maybe there is a
better way).

tim


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

Date: Thu, 14 Jan 1999 09:18:52 -0800
From: adrian@sequoiarecords.com (Adrian Price)
Subject: Re: FORM to two different CGI?
Message-Id: <adrian-1401990918520001@webgalaxy.com>

In article <369E089E.F93FE52@infonet.ee>, Gleb Ekker <globus@infonet.ee> wrote:

>Hi,
>
>Please help me!  I have FORM on my page which is need to be sent to two
>different CGI scripts on two different servers.  Is it possible to put
>two URLs in <FORM ACTION=...>,  or there is some other way to fix this
>problem?
>
>Thanks,
>                            Gleb.

Well, you can modify the script to save the QUERY_STRING and once the
script is done, send that off to the other CGI, AFAIK. I'm not sure
exactly how, but I've seen it done several places.

-- 
---
http://www.sequoiarecords.com/
Web Designer/Coder at Large


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

Date: Thu, 14 Jan 1999 12:13:43 -0500
From: jb@jbarchuk.com (jim barchuk)
Subject: Re: Help CGI times out (doc contains no data)
Message-Id: <7k8l77.1b7.ln@jbarchuk.tiac.net>

Hello Jim!

>    I wrote a CGI script that runs a number of processes and returns the
> result from each to the browser..This works fine until I run a large
> number of processes, then it times out.
> 
>    I suspect my server is buffering the output, otherwise I would be
> getting an incremental result as in http://www.go2net.com

The effect you're seeing there is not an 'incremental thing', it is an
HTML thing. The browser cannot display a TABLE until the entire TABLE
is downloaded. That little one at the top that displays first is a
relatively small TABLE. The rest of the page is larger/nested TABLEs,
it just takes much longer to download it all, and the browser does
seem to 'hesitate'.

I'm having the same problem with a long running script. I applied a
bandaid by kicking httpd.conf Timeout up to 60 mins, but I know that
is strictly a kludge and the vast majority of users cannot do that.

Last year someone sent me a set of shell scripts that work for him.
But the way they work are not 'fitting' very well into what I need
which is a single 'fully Perl/CGI driven FORM'.

Can someone name a module that can 'solve' this, or name a site that
describes how to deal with it? 

Thanks much. Have a :) day!

jb

-- 
jim barchuk
jb@jbarchuk.com




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

Date: Thu, 14 Jan 1999 16:58:02 +0000
From: David Robinson <dave@icepop.demon.co.uk>
Subject: Re: Help please..bad file handle error
Message-Id: <JBdayLAaIin2Ew5t@icepop.demon.co.uk>

In article <369DF489.6660646E@snailgem.org>, Eugene Sotirescu
<eugene@snailgem.org> writes
>> the line: open ($PRICE_FILE, "/sys2.txt");   may be the problem...
>> " bad file handle error"
>
>Looks like a mistake in the book:
>try PRICE_FILE everywhere where it says $PRICE_FILE


Thanks Eugene  just tried that and it still throws up the same
errors...it`s seems as though the script can`t interpret the data in the
data file. 

Cheers Dave
>
>
>
>David Robinson wrote:
>> 
>> Help Please.
>> 
>> I`m working my way through a book "Teach yourself cgi programming with
>> perl 5 in a week" and despite the fact that it is now 7 months since I
>> started I feel as though I am starting at least to make some progress.
>> 
>> My current project is to learn how to extract and manipulate data from a
>> simple database according to a user selection from a pull down menu on
>> an HTML page.
>> 
>> The example from the book illustrates a routine for a `Build Your Own
>> Computer` webpage. This consists of:
>> a. build.cgi
>> b. build.html
>> c. sys2 (The database)
>> 
>> I have reproduced these later in this message for examination.
>> 
>> I can get the various options to appear on the resulting webpage, but
>> the cost of the items [$price] will not generate. It simply returns a
>> value of 0.
>> 
>> the line: open ($PRICE_FILE, "/sys2.txt");   may be the problem...
>> " bad file handle error"
>> 
>> If it is written as above cgi-lib.pl throws up the following:
>> 
>> cgi-lib.pl: Unknown Content-type:
>> Content-type: text/html
>> 
>> <html>
>> <head>
>> <title>cgi-lib.pl: Unknown Content-type:
>> </title>
>> </head>
>> <body>
>> <h1>cgi-lib.pl: Unknown Content-type:
>> </h1>
>> 
>> If the line is written as ($PRICE_FILE= "/sys2.txt");
>> 
>> The webpage is generated but returns a value of 0 for $price
>> Presumably because the data from the database hasn`t been used/found.
>> 
>> I`m sorry if this goes on a bit, but I am reproducing the relevant code
>> and HTML in the hope that someone can help me to understand why the data
>> from the data file is not being read. (I have tried the script using
>> Perl Builder on my PC, and on the server. I think I`ve eliminated simple
>> potential problems like file permissions, paths etc and typos.)
>> 
>> ========================================================================
>> The HTML: (build.html)
>> 
>> <HTML>
>> 
>> <HEAD>
>> <TITLE></TITLE>
>> </HEAD>
>> 
>> <BODY>
>> <P>Or Build your own PC</P>
>> <P></P>
>> <CENTER>
>> <FORM METHOD="post" ACTION="/cgi-bin/build.cgi">
>> <TABLE WIDTH="50%" BORDER="1">
>> <TR>
>> <TD>CPU <P><SELECT NAME="cpu"><OPTION VALUE="P75">Pentium 75</OPTION>
>> <OPTION VALUE="486d66">486 DX2 66</OPTION><OPTION VALUE="P60">Pentium 60
>> </OPTION><OPTION VALUE="P100" SELECTED="SELECTED">Pentium 100 </OPTION>
>> </SELECT>
>> </P>
>> </TD>
>> <TD>Memory<P><SELECT NAME="memory"><OPTION VALUE="16 MEG">16 Meg Memory
>> </OPTION><OPTION VALUE="4 MEG">4 Meg Memory</OPTION><OPTION VALUE="8
>> MEG">8 Meg
>> Memory </OPTION><OPTION VALUE="32 MEG" SELECTED="SELECTED">32 Meg Memory
>> </OPTION></SELECT>
>> </P>
>> </TD>
>> <TD>Hard Disk<P><SELECT NAME="disk"><OPTION VALUE="850 IDE">850 Meg IDE
>> </OPTION><OPTION VALUE="560 IDE">560 Meg IDE </OPTION>
>> <OPTION VALUE="1 GIG IDE" SELECTED="SELECTED">1 Gig
>> IDE</OPTION></SELECT>
>> </P>
>> </TD>
>> <TD></TD>
>> </TR>
>> <TR>
>> <TD>Video Card <P><SELECT NAME="video"><OPTION VALUE="2 MEG">2 Meg card
>> </OPTION><OPTION VALUE="1 MEG">1 Meg card</OPTION>
>> <OPTION VALUE="4 MEG" SELECTED="SELECTED">4 Meg card</OPTION></SELECT>
>> </P>
>> </TD>
>> <TD>Monitor<P><SELECT NAME="monitor"><OPTION VALUE="15 INCH">15.28 NI
>> </OPTION>
>> <OPTION VALUE="14 INCH">14.28 NI</OPTION>
>> <OPTION VALUE="17 INCH" SELECTED="SELECTED">17.28 NI </OPTION></SELECT>
>> </P>
>> </TD>
>> <TD>CD ROM<P><SELECT NAME="cdrom"><OPTION VALUE="2X CDROM">Double Speed
>> </OPTION><OPTION VALUE="NONE">NONE </OPTION>
>> <OPTION VALUE="4X CDROM" SELECTED="SELECTED">Quad
>> Speed</OPTION></SELECT>
>> </P>
>> </TD>
>> <TD>Modem<P><SELECT NAME="modem"><OPTION VALUE="28.8 MODEM">28.8
>> </OPTION>
>> <OPTION VALUE="14.4 MODEM">14.4 </OPTION><OPTION VALUE="NONE">NONE
>> </OPTION>
>> </SELECT>
>> </P>
>> </TD>
>> </TR>
>> <TR>
>> <TD>&nbsp;</TD>
>> <TD>&nbsp;<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Get Current
>> Price"></TD>
>> <TD>&nbsp;<INPUT TYPE="RESET" NAME="Reset1"></TD>
>> <TD>&nbsp;</TD>
>> </TR>
>> </TABLE>
>> </FORM>
>> </CENTER>
>> <P></P>
>> </BODY>
>> </HTML>
>> ========================================================================
>> The Script ( build.cgi)
>> 
>> #!/usr/local/bin/perl
>> push(@INC, "/cgi-bin");
>> require("cgi-lib.pl");
>> 
>> &ReadParse(*input);
>> open($PRICE_FILE="/sys2.txt");
>> while (<$PRICE_FILE>) {
>> chop;
>> ($item, $price) = split(/:/,$_,2) ;
>> $price_list{$item} = $price ;
>> }
>> 
>> #Determine base price
>> $price = $price_list{$input{'cpu'}};
>> 
>> if ($input{'cpu'} eq "486d66") {
>> #set 486 variables
>> $computer_name = "486DX2-66";
>> $video = "VLB" ;
>> $price += $price_list{$input{'memory' }};
>> $memory =$input{'memory'};
>> }
>> else {
>> 
>> #not a 486 so must be a pentium
>> $computer_name = "Pentium";
>> $video = "PCI";
>>    $cache = "256K Cache";
>>      if  ($input{'memory'} ne "8 MEG"){
>>            $price += $price_list{$input{'memory'}};
>>               }
>> #32
>> if ($input{'memory'} eq "4 MEG"){
>>     $memory = "8 MEG";
>> }
>> else { $memory = $input{'memory'};}
>> 
>> #37
>> if ($input{'cpu'} eq "P100") {$ptype = 100}
>> elsif ($input{'cpu'} eq "P75") {$ptype = 75}
>> elsif ($input{'cpu'} eq "P60") {$ptype = 60}
>> }
>> #41
>> 
>> # add monitors over 14"
>> 
>> $monitor = $input{'monitor'};
>> $price += $price_list{$input{'monitor'}};
>> 
>> #45
>> #add mulitmedia
>> if ($input{'cdrom'} ne "NONE") {
>>    $price += $price_list{$input{'cdrom'}};
>>    if ($input{'cdrom'} eq "2X CDROM") {
>>        $multimedia="Double Speed Multimedia System";
>>             }
>>    else {
>>        $multimedia="Quad Speed Multimedia System";
>>             }
>>         }
>> #56
>> #add 14.4 modem price
>> if ($input{'modem'} ne "NONE") {
>>     $price += $price_list{$input{'modem'}};
>>     $modem = $input{'modem'};
>>         }
>> 
>> #63
>> #add disk price
>> $price += $price_list{$input{'disk'}};
>> $DISK = $input{'disk'};
>> 
>> #66
>> #add video
>> $price += $price_list{$input{'video'}};
>> $VIDEO = $input{'video'};
>> 
>> #70
>> print &PrintHeader;
>> #print <$in1>;
>> print<<"print_tag";
>> <html>
>> <head>
>> <title>$computer_name Systems from our store</title>
>> </head>
>> <body>
>> <h1 align=center> Our Store PC`s </h1>
>> <center>
>> <table border=5>
>> <th colspan=2 align=center> <h2>
>> ${computer_name} $ptype  only \$$price
>> </h2>
>> <tr><td><ul>
>> <li>$memory of Ram
>> <li>$cache $price
>> <li>Enhanced IDE In/Out Controller
>> <li>$monitor NIL SVGA Monitor
>> <

-- 
David Robinson


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

Date: Thu, 14 Jan 1999 12:39:15 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
To: dave@icepop.demon.co.uk
Subject: Re: Help please..bad file handle error
Message-Id: <369E2BC3.C3699F75@snailgem.org>

Problem also is, the author doesn't check return values.
Do this, to get better diagnostic messages:

$file = /full/path/to/yourfile; 
open (PRICE_FILE, $file) or die "Can't open $file: $!";

He also forgets to close the file. After the while loop you should:

close $file or die "Can't close $file: $!";

(This is not gonna fix the code, but might give you a better idea about
what's amiss).

I also don't understand why he keeps using $PRICE_FILE, since this is a
file handle not a variable.

Finally, FWTW, 2 pieces of advice:

1. cgi-lib.pl is old, unsupported technology. There's better stuff out
there now, like the CGI.pm module. Learn this one, and you won't be
wasting your time.
2. Judging from your confusion, you don't know enough Perl to deal with
this. Hermmann's book doesn't give you enough Perl background, and you
get stuck with nonsense code like open ($PRICE_FILE= "/sys2.txt").
Get yourself a good Perl book, otherwise you'll be following blindly
other people's mistakes, when you should be making your own.



David Robinson wrote:
> 
> In article <369DF489.6660646E@snailgem.org>, Eugene Sotirescu
> <eugene@snailgem.org> writes
> >> the line: open ($PRICE_FILE, "/sys2.txt");   may be the problem...
> >> " bad file handle error"
> >
> >Looks like a mistake in the book:
> >try PRICE_FILE everywhere where it says $PRICE_FILE
> 
> Thanks Eugene  just tried that and it still throws up the same
> errors...it`s seems as though the script can`t interpret the data in the
> data file.


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

Date: Thu, 14 Jan 1999 18:27:52 +0100
From: studmail <studmail@dutwmail.wbmt.tudelft.nl>
Subject: leading zeros
Message-Id: <369E2918.108734D0@dutwmail.wbmt.tudelft.nl>

I am a newbee in programming with Perl and i have the following
quastion:

How to print numbers to a file with leading zeros?

Thanks,

Koos de Wilde





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

Date: Thu, 14 Jan 1999 11:51:45 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: leading zeros
Message-Id: <369E2EB1.A17E1CD3@austin.ibm.com>

studmail wrote:

> I am a newbee in programming with Perl and i have the following
> quastion:
>
> How to print numbers to a file with leading zeros?
>
> Thanks,
>
> Koos de Wilde

perldoc -f sprintf (for the options)
perldoc -f printf (for the command to print to a file)

- Tom



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

Date: Thu, 14 Jan 1999 13:00:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: leading zeros
Message-Id: <comdog-ya02408000R1401991300200001@news.panix.com>

In article <369E2918.108734D0@dutwmail.wbmt.tudelft.nl>, Jac.deWilde@WbMT.TUDelft.nl posted:

> How to print numbers to a file with leading zeros?

see the printf() function.

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


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

Date: Thu, 14 Jan 1999 07:29:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Logic flow
Message-Id: <MPG.1107ad493952156098998a@nntp.hpl.hp.com>

In article <77j2e2$e93$1@nnrp1.dejanews.com>, hudacmi2433@my-dejanews.com 
says...
> My main routine consists of a series of subroutines.  After returning from
> any oneI may need to STOP execution (elegantly)  Is DIE the right way or
> elegant way?
#MAIN
blah...
blah...
&sub1;
&sub2;
if( $condition) {
  &sub3;
> &sub4;}else{
DIE???
}

#End MAIN

What are those characters you use as line separators?  Yuk.

'die' (not 'DIE') is the right way to stop execution iff you want a 
diagnostic printed to STDERR.  Otherwise, the right way is 'exit'.

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


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

Date: Thu, 14 Jan 1999 08:25:59 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: max. length of perl regexp
Message-Id: <npuk77.tba.ln@magna.metronet.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote:
: [A complimentary Cc of this posting was sent to Tad McClellan
: <tadmc@metronet.com>],
: who wrote in article <3g4k77.l28.ln@magna.metronet.com>:


: >    "A regular expression may not compile to more than 32767 
: >     bytes internally."

: No such limit with contemporary perls (starting from 5.004_56 or somesuch).


   Then the above in perl.pod and the below in perldiag.pod
   are bugs in the documentation?

-----------------
=item regexp too big

(F) The current implementation of regular expressions uses shorts as
address offsets within a string.  Unfortunately this means that if
the regular expression compiles to longer than 32767, it'll blow up.
Usually when you want a regular expression this big, there is a better
way to do it with multiple statements.  See L<perlre>.
-----------------

perl -v

This is perl, version 5.005_02 built for i586-linux



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


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

Date: Thu, 14 Jan 1999 10:47:51 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: max. length of perl regexp
Message-Id: <x3yemoxrh3t.fsf@tigre.matrox.com>


s_jagadish@yahoo.com writes:

> 
> is there a limit on the max. length of a regexp ? if so what is it ?

Nope ... and to prove it, get a copy of the Owls book (Mastering
Regular Expressions, by Jeffrey Friedl) and open page 316.
There, he lists a regex that is 6,598 bytes long for verifying email
addresses.

PS. If you ever manage to type in the whole regexp, let me know
please!

Ala



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

Date: Thu, 14 Jan 1999 17:19:48 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: max. length of perl regexp
Message-Id: <UGpn2.9114$kt3.77654@typhoon-sf.pbi.net>



Nothing above this line is part of the signed message.

In article <x3yemoxrh3t.fsf@tigre.matrox.com>,
Ala Qumsieh  <aqumsieh@matrox.com> wrote:
>
>s_jagadish@yahoo.com writes:
>> 
>> is there a limit on the max. length of a regexp ? if so what is it ?
>
>Nope ... and to prove it, get a copy of the Owls book (Mastering
>Regular Expressions, by Jeffrey Friedl) and open page 316.
>There, he lists a regex that is 6,598 bytes long for verifying email
>addresses.

Ummmm....That a regex of X bytes works is not a proof that there is
no limit. In fact there *are* limits, and I have run into them in
practice. I had to change my handling of 'robots.txt' files to
accomodate the limits because some (very poorly managed) sites
do stupid things like list 3,000 user directories one by one
as being off-limits in their robots.txt files. The resulting
regex exceeded the limits on Perl's regex parser.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNp4npujpikN3V52xAQHl1wP+Jbw6UVGsgqcxg16Z7tRQtdnopOmsIoms
8NF/joJXLRD3UyUamt206yLOeNuIdrogKEcee4J31TGyKA6cFWXXiUgkyA8iQov1
glIAscvX/LSBYoxPHQlxTSdg2DNUT+aqkFRKXxYrA6Dbat9HULEfExMeSOK7kThI
Lda9OdmA2EM=
=RtyB
-----END PGP SIGNATURE-----


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

Date: 14 Jan 1999 16:46:15 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: mkdir with specified owner or group
Message-Id: <77l70n$80a$2@news0-alterdial.uu.net>

Artoo <r2-d2@REMOVEbigfoot.com> wrote:
> Is it possible to mkdir and specify an owner or group for that dir while
> making it, rather than chown after it's creation.  I need to mkdir in a dir
> with chmod 775 but I can't just "mkdir (dirname, 0755)" because it isn't
> world writable, it must be run as owner (or group) to allow the dir to be
> created?

If your script is running as root (or setuid root), you could change the
effective user id (and gid too, probably) before creating the directory:

   {
      local $> = $some_uid;
      local $) = $some_gid;
      mkdir ($dir, 0775) || die "...";
   }

If you're *not* running as root, then you're going to have a hard time
calling chown on many Unices!  (I know that IRIX 4 and 5 let ordinary
users chown; Solaris and Linux do not.  Can't speak for others.)

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Thu, 14 Jan 1999 16:42:34 GMT
From: nguyen.van@imvi.bls.com
Subject: Module Date:Interval documentation
Message-Id: <77l6po$81b$1@nnrp1.dejanews.com>

I downloaded this module but couldn't load Interval.pod; therefore I couldn't
read docs. I need this docs in order to use it. do you know any way to load
the docs for this module again.

another question is this how can I print out date interval. For example, the
in put is this "01/12/1999-02/02/2000". I want the result print out like:
o1/12/1999 01/13/1999 ..... ....

02/01/2000
02/02/2000

put all of these element into an array. I thought that the Date:Interval
module might help. but don't know how to use it. Please give me suggestions.

Thanks
Van Nguyen

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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