[13222] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 632 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 24 18:07:13 1999

Date: Tue, 24 Aug 1999 15:05:17 -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, 24 Aug 1999     Volume: 9 Number: 632

Today's topics:
        ANNOUNCE: XML::RSS 0.3 (Jonathan Eisenzopf)
        Briles' Law <sariq@texas.net>
        CORRECTION: XML::RSS 0.3 URL (Jonathan Eisenzopf)
    Re: DBM question (should be easy) <gellyfish@gellyfish.com>
    Re: Environment variables <gellyfish@gellyfish.com>
        Extracting Data From HTML wired2000@my-deja.com
    Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54 <henry@dotrose.com>
    Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54 <gellyfish@gellyfish.com>
        filtering files on opendir / readdir (Eric Smith)
    Re: filtering files on opendir / readdir <cs004@wg.waii.com>
    Re: How add a new key to a hash <makkulka@cisco.com>
    Re: How to avoid "Repost from data?" question? <gellyfish@gellyfish.com>
    Re: how to capture STDOUT from external command? <gellyfish@gellyfish.com>
    Re: Insecure $ENV{PATH} while running setuid at /dev/fd <kagel@bloomberg.net>
    Re: need script for fetching documents via POST. <gellyfish@gellyfish.com>
    Re: newbi: Registry Help under NT <carvdawg@patriot.net>
    Re: newbie: need help,LEARNING FROM A BOOK <gellyfish@gellyfish.com>
    Re: PERL & EXCEL <l463520@lmtas.lmco.com>
    Re: POP is pooped! <gellyfish@gellyfish.com>
    Re: POP is pooped! (Randal L. Schwartz)
    Re: Problem opening a flat-file for read <news@news.news>
    Re: Problem opening a flat-file for read (Sean McAfee)
    Re: Problem opening a flat-file for read <cassell@mail.cor.epa.gov>
    Re: Problem opening a flat-file for read <cassell@mail.cor.epa.gov>
    Re: Problem opening a flat-file for read <cassell@mail.cor.epa.gov>
    Re: Problem opening a flat-file for read <sariq@texas.net>
    Re: Problem opening a flat-file for read <news@news.news>
        Problem processing form variables in CGI siafhir2@my-deja.com
    Re: Returning an absolute value from a variable <cassell@mail.cor.epa.gov>
    Re: Returning an absolute value from a variable <gellyfish@gellyfish.com>
    Re: Running Apache & Active PERL! <gellyfish@gellyfish.com>
    Re: setuid question <kagel@bloomberg.net>
    Re: Shamefully simple question. <anti@spin.de>
        textarea problem <ab@cd.com>
    Re: THE CPU and LOOPS IN PERL <chriskm@empirenet.com>
    Re: Why use Perl when we've got Python?! <ramune@bigfoot.com>
    Re: Win32::OLE to read Word file <cassell@mail.cor.epa.gov>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 24 Aug 99 20:38:20 GMT
From: eisen@pobox.com (Jonathan Eisenzopf)
Subject: ANNOUNCE: XML::RSS 0.3
Message-Id: <37C302BC.D5F5C1E2@pobox.com>


DLSI=adpO

This is an alpha release because the API has not been
finalized. The module will be available at your local
CPAN archive. Alternatively, try one of the 2 URLs:
http://www.perl.com/CPAN/authors/id/E/EI/EISEN/XML-RSS-0.2.tar.gz

http://www.perlxml.com/modules/XML-RSS-0.2.tar.gz

This Perl module provides a basic framework for creating and
maintaining Rich Site Summary (RSS) files. RSS is primarily
used for distributing news headlines, commonly called
channels, and is used primarily on Netscape's Netcenter,
http://my.netscape.com, and Userland Software's
http://my.userland.com.

This distribution includes several examples that allow you
to generate HTML from an RSS file. This might be helpful if
you want to include news feeds on your Web site from sources
like Slashot and Freshmeat.

This latest release adds support for RSS version 0.91. More
information on RSS can be found at:
http://my.netscape.com/publish/help/mnn20/quickstart.html

Please send comments, problems, etc. to eisen@pobox.com.

Jonathan.




xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)




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

Date: Tue, 24 Aug 1999 16:40:21 -0500
From: Tom Briles <sariq@texas.net>
Subject: Briles' Law
Message-Id: <37C31145.8E9753DF@texas.net>

The quality of questions and answers in c.l.p.misc is inversely
proportional to the number of Perl programmers attending conferences.

- Tom


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

Date: 24 Aug 99 20:53:56 GMT
From: eisen@pobox.com (Jonathan Eisenzopf)
Subject: CORRECTION: XML::RSS 0.3 URL
Message-Id: <37C30664.1536ECCE@pobox.com>

The correct URLs for the module are:
http://www.perl.com/CPAN/authors/id/E/EI/EISEN/XML-RSS-0.3.tar.gz

http://www.perlxml.com/modules/XML-RSS-0.3.tar.gz



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)




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

Date: 24 Aug 1999 21:53:00 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: DBM question (should be easy)
Message-Id: <7pv47s$1ag$1@gellyfish.btinternet.com>

In comp.lang.perl.misc Matt Baker <matt@betcha.net> wrote:
> Here is what my books says to do to tie a HASH to a database on the Win32
> platform.  (The code below is a direct pull from the book)
> use Fcntl;
> use SDBM_File;
> tie %hash, "SDBM_File", 'data',O_RDWR|O_CREAT|O_EXCL,0644;
> $hash{drink}='root beer';
> untie %hash;
> 
> When I run this code it creates two files:  data.dir and data.pag  .
> The problem is that although it creates the database files, it fails to put
> any data in either of them.  They are 0kb in length.
> What do I need to do to make this work?

What happens when you try to access the data ?

If you put:

  tie %hash, "SDBM_File",'data',1,0;
  print each %hash;

at the end of the script what does it do ?

/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: 24 Aug 1999 21:07:18 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Environment variables
Message-Id: <7pv1i6$14a$1@gellyfish.btinternet.com>

On Tue, 24 Aug 1999 18:37:16 +0200 Thomas Rassmann wrote:
> Lee Mulleady wrote:
>> 
>> Is there any way to set Environment variables (on Unix), so that they
>> stay set after the script ends?
>> 
> 
> That couldn't work, because of the perl-script runs in a new shell. It's
> exactly the same problem as in a normal shell. Variable definition only
> works for the shell and (with export) also for childs of that shell.
> When your perl-script ends, the shell which called the script doesn't
> know anything about the defined variables.

While you are strictly correct it is nonetheless possible for a Perl
program to be used to *define* an environment that can be used in a
parent shell.  Say you wanted to process some file to derive some 
environment variables that were needed in some subsequent operation :
you could have your Perl program create a shell script that has the
necessary statements to define the variables then after the Perl
program has completed your shell script can read and execute this
script using either 'source' or the '.' depending on your shell.

Of course you could always turn the whole thing inside out and run
the remainder of your shell script (or its equivalent) from within
your Perl program.

/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: Tue, 24 Aug 1999 20:39:24 GMT
From: wired2000@my-deja.com
Subject: Extracting Data From HTML
Message-Id: <7puvtq$fn1$1@nnrp1.deja.com>

Hello,

Quick question. I have a line of HTML code like this:
<tr><td><a
href=http://www.secapl.com/secapl/quoteserver/glossary.html#last>Last
Traded at</a></td><td align=right><strong>39.1250</strong></td><td><a
href=http://www.secapl.com/secapl/quoteserver/glossary.html#datetime>Dat
e/Time</a></td><td
align=right>1999/08/24 15:47:00</td></tr>

How abouts can I exptract the date/time and the stock price and store
them into variables? (Note: Stock price must be recognized as digits,
not text)

My idea was to grab this line, so a search and replace on all the text
around it, that could work, but not exactly since there's 2 unknowns on
the same line (time/date and stock price). Isn't there any easy way to
grab the value between <strong> and the time/date like that?

Sounds like something which is easy, but its not coming to me :(


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


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

Date: Tue, 24 Aug 1999 16:32:48 -0400
From: Henry Hartley <henry@dotrose.com>
Subject: Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54
Message-Id: <37C30170.70708E59@dotrose.com>

I've done it with only a little fiddling.  What specifically goes
wrong?  Do you get an error message?  If so, what?  If not, post some
code.

Henry Hartley


Dallas Jones wrote:
> I'm running NT and have ActivePerl and CGI.pm-2.54 installed. I can't get
> any of the scripts I've found to upload a file from a user's browser. I've
> searched through the posts herein and through the help files, but I still
> don't really have a handle on what's going on. If someone would be so kind
> as to explain to me what needs to be done, I will in turn create a web page
> explaining that same process and post it as a resource for people who ask in
> the future.


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

Date: 24 Aug 1999 21:24:24 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: File Upload for WinNT W/ ActivePerl and CGI.pm-2.54
Message-Id: <7pv2i8$15b$1@gellyfish.btinternet.com>

On Mon, 23 Aug 1999 23:32:31 GMT Dallas Jones wrote:
> Hi, all:
> 
> I'm running NT and have ActivePerl and CGI.pm-2.54 installed. I can't get
> any of the scripts I've found to upload a file from a user's browser. 
> 

Beyond reading what it has to say in the CGI.pm documentation you have
made sure that you have used binmode on the filehandles concerned ?

/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: 24 Aug 1999 21:08:03 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: filtering files on opendir / readdir
Message-Id: <slrn7s62dj.l1t.eric@plum.fruitcom.com>


Hi is it possible to filter for say .csv files at the opendir or readdir
level or does one have to do this as a seperate statement.

Thanx

-- 
Eric Smith
eric@fruitcom.com
www.fruitcom.com

If Bill Gates had a dime for every time a Windows box crashed...
                ...Oh, wait a minute, he already does.


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

Date: Tue, 24 Aug 1999 16:18:54 -0500
From: Art Haas <cs004@wg.waii.com>
Subject: Re: filtering files on opendir / readdir
Message-Id: <37C30C3E.510FF912@wg.waii.com>

Eric Smith wrote:
> 
> Hi is it possible to filter for say .csv files at the opendir or readdir
> level or does one have to do this as a seperate statement.
> 

perl's grep is your friend ...

my $dir = '/your/directory/here';
opendir(DIR,$dir) || die "Can't open '$dir'! $!\n";
my @csvfiles = grep(/\.csv$/, readdir(DIR));
closedir(DIR);

-- 
###############################
# Art Haas
# (713) 689-2417
###############################


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

Date: Tue, 24 Aug 1999 13:18:06 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: How add a new key to a hash
Message-Id: <37C2FDFE.F498DDDD@cisco.com>

[ Alec Kelingos wrote:

> I tried:
> foreach $col ( keys $columns ) {
>    %data = ( $col  => [ $fields[$columns{$col}[1]] ]); }
> }

foreach $col ( keys $columns )  looks suspicious. keys() expects a hash.

Try
while (($key,$value) = each %$columns) {  $data{$key}=$value;   }
assuming $columns is a ref to a hash whose keys and values you want to
duplicate.
==



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

Date: 23 Aug 1999 21:22:44 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to avoid "Repost from data?" question?
Message-Id: <7pse34$33n$1@gellyfish.btinternet.com>

On Mon, 23 Aug 1999 15:44:54 GMT Jon Peterson wrote:
> Abigail <abigail@delanet.com> wrote:
> 
>> 1) That is not a Perl question.
>> 2) That is not an HTML question either.
>> 3) That is not a Perl question.
> 
> Ping! Repetition! With 27 seconds left on the clock it is now someone elses
> turn to talk about how little newbies know.

Actually I thought it was deviation - and anyhow who gets to wear the
stripey blazer ...

/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: 24 Aug 1999 21:12:22 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to capture STDOUT from external command?
Message-Id: <7pv1rm$14o$1@gellyfish.btinternet.com>

On Tue, 24 Aug 1999 03:57:37 GMT angpung@my-deja.com wrote:
> I call external shell command by using pipe like:
> 
> open (SQL,"| sqlplus ");
> print SQL "select * from xxx;\n";
> 
> and I want to capture the output from that external command to a variable,
> how can I do this?
> 

You will want to use the standard module IO::Open2 as described in the
section entitled:

     Bidirectional Communication with Another Process

in the perlipc manpage.

/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: Tue, 24 Aug 1999 16:17:11 -0400
From: "Art S. Kagel" <kagel@bloomberg.net>
To: mr_potato_head@my-deja.com
Subject: Re: Insecure $ENV{PATH} while running setuid at /dev/fd/4 line 2.
Message-Id: <37C2FDC7.6CEA2601@bloomberg.net>

Sounds like a permissions problem.  Try wrapping the suid perl script in 
a non-suid perl or shell script the sets INFORMIXSERVER then calls the 
suid script.

Art S. Kagel

mr_potato_head@my-deja.com wrote:
> 
> Hi,
>    Ok, I give up.  I'm lame and I need help.  My problem is that I have
> the following script that I need to allow a user to run on my informix
> database.  This user needs to run this script as user "informix".  When
> I change the permissions on the script to "4755" and ran the scripts, I
> get  the following error: "Insecure $ENV{PATH} while running setuid at
> /dev/fd/4 line 2.".  Can anyone show me what line I need to add to get
> rid of this error?  Thanks in advance...
> 
> #!/usr/local/bin/perl
> $mmddhhmmss = `date +%m%d%H%M%S`;
> chop $mmddhhmmss;
> 
> if ($ARGV[0] eq "") {
>    print "Exiting, Bad Format...\n";
> }
> $ENV{INFORMIXSERVER} = "n41_shm";
> 
> #################################################################
> # if user uses the '-u' flag, just unload the trunk_grp_dim table
> #################################################################
> if ($ARGV[0] eq "-u") {
>    open DBACCESS, "| /usr/informix/bin/dbaccess" or die "Couldn't run
> dbaccess:
> $!; aborting";
>       print DBACCESS qq{
>          database pmrpt\@n41_shm;
>          UNLOAD TO './trunk_grp_dim.$mmddhhmmss'
>          select * from trunk_grp_dim
>       };
>    close DBACCESS or die "Couldn't close dbaccess: $!; aborting";
>    exit;
> }
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


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

Date: 24 Aug 1999 21:55:43 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: need script for fetching documents via POST.
Message-Id: <7pv4cv$1aj$1@gellyfish.btinternet.com>

On Tue, 24 Aug 1999 12:22:18 +0530 uma mohan wrote:
> Hi,
> 
> I want a perl script that will fetch a document with a  cgi/normal URL.
> wget works fine for normal URL's but I dont' think it supports the POST
> method.
> 
> The script should support both GET and POST methods, and preferably
> should take all it's parameters thru command line (to automate it).
> 
> I know it should be quite trivial with libwww, but in case someone
> already has it, it would help me avoid reinventing the wheel.
> 

The author of libwww-perl has already done it - there is a script
called lwp-request that comes with the distribution of that suite of
modules.

/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: Tue, 24 Aug 1999 17:45:44 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Re: newbi: Registry Help under NT
Message-Id: <37C31288.4FCA121B@patriot.net>

I would suggest using Win32::TieRegistry to do this...if you had filled in
the
values for "a", "b", and "c", I could have just sent you the code...

"Andrew C. Holmes" wrote:

> Hello all,
>
> I am trying to extract a value from an NT Server registry.
> When I run this I get "Query: Cannot create a file when that file already
> exists."
> Obviously the QueryValue is failing, but why.  any ideas anybody???
>
> Thanks V much
>
> Andy Holmes
>
> <snip>
> # Its getting scary....now to update the servers registry.
> $main::HKEY_LOCAL_MACHINE->Open("SOFTWARE\\a\\b\\c", $key) ||
>     die "Create: $!";
>
> $key->QueryValue("Sync Level", $current_level) ||
>     die "Query: $!";
>
> print "Current: $current_level\n";
>
> $next_level = $current_level + 1;
> $next_update = sprintf("upd.%06d",$next_level);
> print "Next: $next_level\n";
> rename ("updates","update_files/$next_update");
>
> # Now set the registry key to the new value
> $key->SetValueEx("Sync Level", 0, REG_SZ, $next_level);
> </snip>



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

Date: 24 Aug 1999 21:40:27 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: newbie: need help,LEARNING FROM A BOOK
Message-Id: <7pv3gb$168$1@gellyfish.btinternet.com>

On Mon, 23 Aug 1999 21:09:39 GMT zev0@my-deja.com wrote:
> I dont understand the concepts, of perl,when do you use " this and when
> do you use 'this,.?2.) what means,exponentation,?and precedence?in
> simple jargon,even a newbie will understand,. 

I would look in the perlop manpage under the heading "Quote and Quote-like
operators" for the answer to the first question - in a dictionary for
the answers to the other two as their meanings are the same in whatever
context you use them.

/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: Tue, 24 Aug 1999 16:29:51 -0500
From: Michael Hill <l463520@lmtas.lmco.com>
To: Eduard Wulff <ewulff_no@spam_compuserve.com>
Subject: Re: PERL & EXCEL
Message-Id: <37C30ECF.E83599D0@lmtas.lmco.com>

Will this run in unix or is this only for dos versin of perl?

Mike

Eduard Wulff wrote:

> kilimount <kilimount@earthling.net> wrote:
>
> >I've been trying this code under windows NT, but being a very early
> >beginner in Perl, I cannot figure out what's wrong.
> ...
>
> >Perl Builder's debugger is returning this line :
> >Can't call method "Worksheets" without a package or object reference at
> >script line 19.
>
> I have not tried your code. I rather edited a working snippet I tried
> some days ago for Word (I use version 9 of Word and Excel).
>
> I used the WIN32::OLE module that came with my ActiveState Perl (I use
> build 519).
>
> Your code seems to be correct - Excel wise.
>
> Check the VBA-object model on Excel objects and their methods and
> properties and the ActiveState documentation on Win32.
>
> I recomment visible=on in the developing phase <g>
>
> This works for me:
>
> use strict;
> use Win32::OLE;
> use Win32::OLE::Const 'Microsoft Excel';
>
> my $xlfile =q(c:\filename.xls);
>
> # Create OLE object - Excel Application Pointer
> my $Excel = Win32::OLE->new('Excel.Application') || die $!;
>
> # Set Application Visibility
> # 0 = Not Visible
> # 1 = Visible
> $Excel->{'Visible'} = 1;
>
> # Open Excel File
> my $workbook = $Excel->Workbooks->Open($xlfile);
>
> # setup active worksheet
> my $worksheet = $workbook->Worksheets(1);
>
> # retrieve value from worksheet
> my $cellA1 = $worksheet->Range("A1")->{'Value'};
> my $cellB1 = $worksheet->Range("B1")->{'Value'};
>
> # Close It Up
> $Excel->ActiveWorkbook->Close(0);
> $Excel->Quit();
>
> print "A1: $cellA1 B1: $cellB1\n";





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

Date: 24 Aug 1999 21:18:52 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: POP is pooped!
Message-Id: <7pv27s$158$1@gellyfish.btinternet.com>

On Tue, 24 Aug 1999 13:28:49 +0200 Alan J. Flavell wrote:
> On 24 Aug 1999, Sam Holden wrote:
> 
>> >	flock(KEYS, 2);
>> 
>> You should really use the human readbale constants LOCK_SH, etc...
> 
> Yes, I was trying to make that point to a student recently, and then
> noticed to my surprise that Merlyn's Web techniques articles are all
> using numbers:
> 
> http://www.stonehenge.com/cgi/wtsearch?search=flock
> 
> Comments?
> 

flock() was around before the Fcntl module : the entries in both the 1st and
2nd editions of the Camel book are the same.  The perlfunc entry however
does describe the use of the manifest constants as defined by Fcntl.

I think we can let Randal off ;-}

/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: 24 Aug 1999 14:42:26 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: POP is pooped!
Message-Id: <m1pv0c97p9.fsf@halfdome.holdit.com>

>>>>> "Alan" == Alan J Flavell <flavell@mail.cern.ch> writes:

Alan> Yes, I was trying to make that point to a student recently, and then
Alan> noticed to my surprise that Merlyn's Web techniques articles are all
Alan> using numbers:

Alan> http://www.stonehenge.com/cgi/wtsearch?search=flock

Alan> Comments?

Well, I think the chance of those numbers changing is pretty small.

Then again, that's how I got into trouble on chat2.pl. :)

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 24 Aug 1999 21:19:38 +0100
From: news <news@news.news>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C2FE5A.C01ECF21@news.news>

Guys,
I narrowed it down a bit.. it is opening the file ok, but the problem is with
the if statement:

  ($fieldname,$fieldage,$fieldcountry)=split(/:/);
#  $numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
   $numofpeople=$_;

This works ok (as at test), but commenting out the third line and commenting
in the second causes it to fail.. any ideas?
Thanks for your help


Andrew Crawford wrote:

> try  open(READ, "<$database") || die $!;
> -- note that '<'
>
> news wrote:
>
> > Can anyone tell me what is wrong with this piece of code? I am trying to
> >
> > open a flat-file that contains data like:
> >
> > Joe:20:foobar
> > Jack:20:foobar
> >
> > and then match up some fields. Any help would be much appreciated.
> >
> > (ps thanks to whoever orignally posted this code)
> >
> > saiid@excite.com
> >
> > open(READ, "$database") || die $!;
> > while(<READ>)
> >   {
> >   ($fieldname,$fieldage,$fieldcountry)=split(/:/);
> >   $numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
> >   }





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

Date: Tue, 24 Aug 1999 20:37:18 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Problem opening a flat-file for read
Message-Id: <2oDw3.3077$J72.638434@news.itd.umich.edu>

In article <37C2FE5A.C01ECF21@news.news>, news  <news> wrote:
>Guys,
>  ($fieldname,$fieldage,$fieldcountry)=split(/:/);
>#  $numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
>   $numofpeople=$_;

>This works ok (as at test), but commenting out the third line and commenting
>in the second causes it to fail.. any ideas?

Yes.  Run your program with the -w switch, and Perl will tell you exactly
what's wrong.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Tue, 24 Aug 1999 13:53:40 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C30654.BDC87442@mail.cor.epa.gov>

[In future, please put your answers after the question, so that
threads make sense.  Thank you.]

> news wrote:
[snip]
> > open(READ, "$database") || die $!;

Andrew Crawford wrote:
> try  open(READ, "<$database") || die $!;
> -- note that '<'

No, that won't do it.  The default is to open for read, so
that part of the poster's code is acceptable.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 24 Aug 1999 13:57:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C3073A.1FB919EC@mail.cor.epa.gov>

news wrote:
> 
> Guys,
> I narrowed it down a bit..

Excellent.  This is the way to work.  By narrowing the 
problem down to a single line [or so], you not only get
closer to solving it yourself, but you really help the
rest of us.

>                            it is opening the file ok, but the problem is with
> the if statement:
> 
>   ($fieldname,$fieldage,$fieldcountry)=split(/:/);
> #  $numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
>    $numofpeople=$_;
> 
> This works ok (as at test), but commenting out the third line and commenting
> in the second causes it to fail.. any ideas?

Yes.  split() won't trim off the newline at the end of each line.
So $fieldcountry never equals 'foobar'.. although it may
equal "foobar\n" some of the time.  In the line after
your 
    while (<READ>) {
put this line:

        chomp;

to trim off that pesky newline.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 24 Aug 1999 13:59:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C307A0.1C4CE2A1@mail.cor.epa.gov>

Samay wrote:
> 
> try
> 
> while(<READ>){
  ^^^^^^^^^^^^^^   <--------------
>   whatever..
> }
> You are just opening the file,
> and not reading it at all..
> 
> (Naming the FileHandle READ will not do the magic. -:)

Hunh??!?!?!?

The poster *did* have the very line you're claiming
was missing.  The response trimmed it off, but...

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 24 Aug 1999 16:02:43 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C30873.BCD23FE0@texas.net>

news wrote:
> 
> Can anyone tell me what is wrong with this piece of code?
>
> open(READ, "$database") || die $!;
> while(<READ>)
>   {
>   ($fieldname,$fieldage,$fieldcountry)=split(/:/);
>   $numofpeople++ if $fieldage ==20 and $fieldcountry="foobar";
>   }

I was really avoiding answering this, since the responses so far have
been so entertaining.  But...

You're performing an assignment, not an evaluation.  And '==' isn't the
correct operator for a string evaluation.  Check out perlop.

You also need to remove the newline or include it in the evaluation.

- Tom


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

Date: Tue, 24 Aug 1999 22:32:06 +0100
From: news <news@news.news>
Subject: Re: Problem opening a flat-file for read
Message-Id: <37C30F56.86186F5C@news.news>

Thanks David, got it done with a chomp and an eq instead of =
Cheers,
Saiid.



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

Date: Tue, 24 Aug 1999 20:51:46 GMT
From: siafhir2@my-deja.com
Subject: Problem processing form variables in CGI
Message-Id: <7pv0kt$g9k$1@nnrp1.deja.com>

I have a problem processing a form variable passed by the URL where the
variable's value contains a period followed by a space, or a period at
the end.  I suspect any punctuation will cause the problem, but I hadn't
tested that.

Here's an example of code in the URL:
http://www.website.com/script.cgi?facility=S.E.+Rink

The trouble here is that the period followed by the space (substituted
by "+")causes the CGI script to read it as a blank field.  I don't have
the problem if the value above read "S.E+Rink", "SE+Rink", or
"S.E.Rink".

I experimented with the problem by typing the value into a search
engine.  There were no problems, so I must be missing something in the
CGI script.

Does anyone know how to fix this problem?

Thanks in advance,
SiaFhir


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


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

Date: Tue, 24 Aug 1999 13:39:17 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: willow <chettah@msn.com>
Subject: Re: Returning an absolute value from a variable
Message-Id: <37C302F5.B4B1BC80@mail.cor.epa.gov>

[courtesy cc e-mailed to poster]

willow wrote:
> 
> I apologize for asking these questions here, but I don't have perldoc.  I
> guess we don't have all of Perl but when I typed that in, it wasn't found.

That's bad.  You don't have a proper install of Perl unless
the docs and tools are there too.  I suggest that you either
get the docs from CPAN (www.cpan.org) or you install a new
copy of Perl. [After all, if you're missing that much, who knows
how much else is missing?]

If you have this on a win32 machine, go to www.activestate.com and
download 'Build 518', the current stable version of ActiveState
Perl.  It will also put a set of HTML docs on your Start Menu.

If you have a non-win32 machine, go to CPAN to get the latest
version.  It installs pretty easily [for a unix install].
 
> I have been reading "Programming Perl" and the "Perl Cookbook" trying to
> resolve this on my own.

Now that's good.  You should have been able to find abs()
in the camel book, though.  Note that the electronic form
of the documentation is more up-to-date than the Camel.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 24 Aug 1999 20:14:11 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Returning an absolute value from a variable
Message-Id: <7puuej$12q$1@gellyfish.btinternet.com>

On Tue, 24 Aug 1999 10:18:50 -0800 "willow" wrote:
> I apologize for asking these questions here, but I don't have perldoc.  I
> guess we don't have all of Perl but when I typed that in, it wasn't found.
> 
> I have been reading "Programming Perl" and the "Perl Cookbook" trying to
> resolve this on my own.
> 

Hmm unsurprisingly the index of 'Programming Perl' might have proved
useful to you in this circumstance ...

/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: 24 Aug 1999 21:28:09 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Running Apache & Active PERL!
Message-Id: <7pv2p9$15q$1@gellyfish.btinternet.com>

On Mon, 23 Aug 1999 17:20:08 -0700 David Cassell wrote:
> Brian Enderle wrote:
>> 
>> Once I have installed both Apache and ActivePerl, how do I go about
>> running a cgi script on my personal computer?
> 
> The first thing to do is to go to your Start Menu and click
> on the Perl documentation.  Your favorite browser will come up,
> with the docs in frames.  Go to the ActivePerl FAQ and click on
> the sub-heading "Web Server Config".  There's a whole section
> on getting Apache to run Perl scripts.
> 

He might also find the Apache documentation useful - it will have installed
at <http://localhost/manual/> (I hope).

/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: Tue, 24 Aug 1999 16:03:43 -0400
From: "Art S. Kagel" <kagel@bloomberg.net>
To: mr_potato_head@my-deja.com
Subject: Re: setuid question
Message-Id: <37C2FA9F.A129D618@bloomberg.net>

The script has to run owned by root with the suid bit set.  Then in the 
script you have to call the setuid system call twice.  The first time 
call it with an argument of zero (setuid( 0 );) to hard change user id to 
root.  Next you can call setuid() with the user id of the user you want 
the script to become.  For security reasons you many want to make this 
a 'C' program that verifies the identity itself of the user running it and 
then, if the real user is authorized, runs the perl script.  This is more 
secure and the DBAs will be able to just run the perl script directly 
since they have permissions already and the ordinary users will have to 
run the suid program to run the script for them.  While you're at it:  
Whenever I write one of these permission buster programs I ALWAYS have it 
log the real user and time of execution in a secure and inaccessible log 
file so I can bash heads when I need to and for CYA.

Art S. Kagel

mr_potato_head@my-deja.com wrote:
> 
> Hi,
>   I have some users that need to drop tables in my informix database but
> I do not want to give any user "resource" or "dba" permission.  Can
> anyone show me in a simple perl script on how to change the user's id to
> run my perl scripts as a different user?   This way I can allow the user
> to drop tables but without giving them permissions other than "connect".
>  Any other ideas would be appreciated.   Thanks in advance...
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


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

Date: 24 Aug 1999 11:56:16 +0200
From: Andi Hechtbauer <anti@spin.de>
Subject: Re: Shamefully simple question.
Message-Id: <m36725lcxr.fsf@hic.hq.spin.de>

>>>>> "mrbog" == mrbog  <mrbog@my-deja.com> writes:

    mrbog> Alright I'm ashamed to ask this, because I'm a somewhat
    mrbog> experienced perl programmer, but I couldn't find this in
    mrbog> the camel book (or the cookbook, or the advanced perl book,
    mrbog> etc etc see I TOLD you I was fairly experienced!)

($has_read_books != $is_experienced)

    mrbog> All I want to do is, instead of a cgi constructing and
    mrbog> returning a page to the user, I want it to push the user to
    mrbog> a URL.

use CGI;
$query = CGI->new();
print $query->redirect('http://somewhere.else/in/movie/land');

All this and more in your friendly "perldoc CGI".

regards,

-- 
Andi Hechtbauer                                           anti@spin.de 
System Administration                         voice: +49 941 94 65 937
SPiN GmbH               http://www.spin.de/     fax: +49 941 94 65 938  
------- web design - java chats - guestbooks - java/cgi coding -------


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

Date: Tue, 24 Aug 1999 15:17:22 -0500
From: "Blair Heuer" <ab@cd.com>
Subject: textarea problem
Message-Id: <7puuqe$2rq$1@oak.prod.itd.earthlink.net>

I have a script that opens a text file, and then puts that text file into a
list with this code:

            open(FILE,"$in{'loc'}\\$in{'current'}"); #
"$in{'loc'}\\$in{'current'}" is the location of the file.
            @file = <FILE>;
            close FILE;
            chomp @file;

Then that is put into the textarea in the html file like so, which shows up
just as it is in the file:

            <textarea>@file</textarea>

Then when saved, the returned input is stored like so:

            open(FILE,">$in{'loc'}\\$in{'current'}");
            truncate(FILE, 0);
            print FILE "@file";
            close FILE;

The problem is that data that is entered into the textarea which originally
would be:

Line 1
Line 2
Line 3

But becomes:

Line 1
 Line 2
 Line 3

Each line, following the first gets a space before it. This messes up the
document, and I need to figure out how to fix it.

Thanks, Blair Heuer





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

Date: 24 Aug 1999 12:02:32 -0700
From: Chris Mahmood <chriskm@empirenet.com>
Subject: Re: THE CPU and LOOPS IN PERL
Message-Id: <m3lnb1m27r.fsf@loafer.worldhq.org>

"Mujakporue, Trey" <tmujak@wcom.co.uk> writes:

> I needed to create a script that would continuously do a few things and not
> exit (until i explicitly killed it!) but after writing and running it, i
> found out that it was taking up to much CPU time and slowing the machine
> down. 
nohup(1) and renice(8).  
-ckm


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

Date: 24 Aug 1999 13:04:42 -0700
From: Graffiti <ramune@bigfoot.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <7putsq$3ql$1@lycaeus.calstatela.edu>

In article <slrn7s2lb3.k6b.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
[snip amusing rant]
>Yeah, those math texts from the 16th and 17th century, they are sooooo easy
>to read, because they lack all the symbols. Not to mention the original
>Euclid and those other Greeks, who had no symbols at all!

<GRIN>
Oh, but they're written with only symbols!  All those confusing greek symbols
that mathematicians use are the basic building blocks for the language!  Why
didn't they just use English?
</GRIN>

>"" On a personal note...  Do you know what a computer science degree is these
>"" days? They require you understand shits like lambda calculus, logic, graph
>"" theory, combinatorics, or even algorithms?? All for what? All the Perl

Sure, why not?

>"" programers I know doesn't understand any of these, and they all are making
>"" big bucks in fortune 500. I'm not ashamed that I dropped out of school. I
>"" hope that Larry and Tom's teachings will eventually make such subjects
>"" disappear for good.

You don't *have* to know them.  Just in the same way you don't *have* to
Perl to get a job administering web servers.  They just help.  (Of course,
while the abstract material in CS can come in handy, if they're taught
wrong, what's the point?)

>Hahahahahahahahahahhahahahahaahahahahahaha.
>
>
>If you think there's much relationship between programming and Computer
>Science, you're utterly mistaken. It's the same relationship between
>driving your Morris Minor and designing and producing a new car.

There's quite a bit of relation.  You don't need to understand how relational
databases work and the theory behind them.  But I wouldn't trust my
business or life to a database server written by someone who didn't have a
firm understanding of database theory.

Same way, I wouldn't want someone who never studied lambda calculus and logic
to write an expert system that would be used for emergency room diagnostics
where the wrong decision can KILL.  (I've heard of Prolog used to write an
expert system for just this purpose.  Dunno about perl.)

Just think of them as a way to increase your understanding.  (Of course,
whether the instructors at most universities are competent and know what
they're teaching is a different story altogether. :-)

>Larry and Tom can teach all they want; their teachings will have no impact
>on Computer Science what so ever. Just like their teaching will have no
>impact on the grow of potatoes in Idaho.

Sure it will.  Much of what they teach will expose Perl programmers to new
ways of thinking and solving problems.  By helping people think out of the
electrified-ivory-tower-deathmatch-cage that some schools tend to put up
around the students' minds, they'll help people find new and innovative
ways to solve problems.

And it's not so far-fetched to think that agricultural supply vendors would
be using perl to help manage operations for their clients, which may include
potato farmers, no? ;-)

-- DN


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

Date: Tue, 24 Aug 1999 13:51:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Win32::OLE to read Word file
Message-Id: <37C305CA.62D415A5@mail.cor.epa.gov>

Peter Wilkinson wrote:
> 
> I would be interested in the example you mention that
> prints a word file. What exactly do you mean by 'print'?
> It could mean send to the printer, or show on the screen.
> Anyhow, a reference to it would be useful.

I assumed the original poster was referring to the detailed
example in the ActivePerl FAQ.  Just go to your Start Menu
and open the HTML documentation; go to the ActivePerl FAQ
section "Usiung OLE with Perl" [oddly enough]; and then 
click on the question "How do I print a Microsoft Word 
document?"  You'll get a chunk of code which shows how.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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