[13810] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1220 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 29 12:05:48 1999

Date: Fri, 29 Oct 1999 09:05:20 -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: <941213120-v9-i1220@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 29 Oct 1999     Volume: 9 Number: 1220

Today's topics:
    Re: $formdata=~s/\s+$//;   ? <gellyfish@gellyfish.com>
    Re: adding data to beginning of file <flavell@mail.cern.ch>
    Re: Como Puedo trabajar con archivos de Foxpro <conford@ford.com>
        crypt() <bingy>" <cater@ionet.net>
    Re: decode $ENV{'HTTP_WEFERER'}? <rhomberg@ife.ee.ethz.ch>
    Re: FAQ 3.9: Is there an IDE or Windows Perl Editor? <kent@darwin.eeb.uconn.edu>
    Re: Forcing a submit <flavell@mail.cern.ch>
        hashing <g-preston1@ti.com>
    Re: hashing <sariq@texas.net>
    Re: hashing <g-preston1@ti.com>
        How do you strip spaces? <poohba@io.com>
    Re: How do you strip spaces? (Bill Moseley)
    Re: How do you strip spaces? <sariq@texas.net>
    Re: It is always like this here? (Greg Bacon)
    Re: It is always like this here? <jtraug@seanet.com>
    Re: It is always like this here? <flavell@mail.cern.ch>
    Re: It is always like this here? (Chris Nandor)
        jpeg-files <mlankamp@hotmail.com>
    Re: length (number of items) of an array (Greg Bacon)
    Re: mySQL -> Sybase <alex@kawo2.rwth-aachen.de>
        perl double-split <daniel.heiserer@bmw.de>
    Re: perl lang parser (Kevin Reid)
    Re: postgres and perl (Hugh Lawson)
    Re: Q: digit-wise number comparisons ? <rhomberg@ife.ee.ethz.ch>
    Re: remove the html tag in the file (Kragen Sitaker)
    Re: remove the html tag in the file (Kragen Sitaker)
        Return value from a stored procedure. <sg@midwal.ca>
        Searching within web pages for text <sloon@mindless.com>
        simplifying a script <wvandenbergNOSPAM@ttpdiskad.nl>
    Re: simplifying a script (Greg Bacon)
    Re: simplifying a script <wvandenbergNOSPAM@ttpdiskad.nl>
    Re: simplifying a script <wvandenbergNOSPAM@ttpdiskad.nl>
    Re: simplifying a script (Greg Bacon)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 29 Oct 1999 16:01:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: $formdata=~s/\s+$//;   ?
Message-Id: <3819b6be_2@newsread3.dircon.co.uk>

Yeong Mo/Director Hana co. <hmaster@factory.co.kr> wrote:
> Then, What is for $line=~s/!(\d+)!/$fields[$1]/g;    ?
> 

How about reading  the documentation occasionally - or alternatively
hire a programmer - there is no point in us writing your entire program
for you via usenet like this ...

/J\
-- 
"The teenage masturbators of today are the television executives of
tomorrow" - Melissa Cabriolet, Drop the Dead Donkey


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

Date: Fri, 29 Oct 1999 16:13:39 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: adding data to beginning of file
Message-Id: <Pine.HPP.3.95a.991029160929.13458H-100000@hpplus01.cern.ch>

On Thu, 28 Oct 1999, Aaron Walker wrote:

> First of all, I have not read the Perl FAQ.

So you're asking to get plonked?

> I thought we were just supposed to
> read the comp.lang.perl.misc FAQ.  

And why are we supposed to find this "thought" a valuable contribution
to the usenet community?

If you'd at least conceded that you now know different, there might have
been some hope.

Error checking and file locking are vital components of any CGI script
that does anything meaningful with files.  So when you say you leave it
out for simplicity, you toss out the baby with the bathwater, and are
left with nothing that's really worth discussing here.  Good luck.

b.t.w make yourself familiar with Merlyn's WebTechniques columns.



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

Date: Fri, 29 Oct 1999 10:19:58 -0400
From: "Proyecto Conford" <conford@ford.com>
Subject: Re: Como Puedo trabajar con archivos de Foxpro
Message-Id: <7vca01$54a3@eccws12.dearborn.ford.com>


Proyecto Conford wrote in message <7v9vbh$5413@eccws12.dearborn.ford.com>...
>A quien pueda interesar
>
>Necesito para ver quien puede ayudarme con respestos a como manipular
>archivos DBF, IDX, CDX
>
>Atentamente,
>
>Saśl Lucena
>Soporte Conford
>email: conford@ford.com
>Tlf: 58-41-406152
>
>




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

Date: Fri, 29 Oct 1999 12:02:34 -0400
From: "<bingy>" <cater@ionet.net>
Subject: crypt()
Message-Id: <7vcg7j$c6s$1@ionews.ionet.net>

I trying to create an administrative perl function to view the contents of
specific files on the server.  I want to use a username/password form to
allow access.  I'm not sure the best way to do this.  So far I have a form
to enter u/p, then gives you access, but if you view source you can see my
u/p fields.  I keep looking for more info. on the crypt() function but can't
find it.  I have tried to use it, but how do i decode it to see if the
contents are in fact correct?  any help about this or suggesting another
data structure would be great!

thanx
cater@ionet.net




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

Date: Fri, 29 Oct 1999 15:15:10 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: decode $ENV{'HTTP_WEFERER'}?
Message-Id: <38199DDE.EEDBB06C@ife.ee.ethz.ch>

Vadim Kulakov wrote:
> 
> How can I decode the string (Apache/1.3.4 (Unix)):
> HTTP_WEFERER=HYUCDDJBLVLMHAALPTCXLYRWTQTIPWIGYOKSTT

I am sure that this string was encrypted using some strong encryption
scheme similar to rot13, so it would be impossible for the echelon to
track this. But there is also a clever hint: the R in REFERER was
transformed to a W.
So my decryption command is:
tr/F-ZA-E/A-Z/;

This translates the W back to the R, so the decrypted data must be
CTPXYYEWGQGHCVVGKOXSGTMROLODKRDBTJFNOO !!!

- Alex


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

Date: 29 Oct 1999 08:25:39 -0400
From: Kent Holsinger <kent@darwin.eeb.uconn.edu>
Subject: Re: FAQ 3.9: Is there an IDE or Windows Perl Editor?
Message-Id: <877lk68ibg.fsf@darwin.eeb.uconn.edu>

>>>>> "Tom" == Tom Christiansen <perlfaq-suggestions@perl.com> writes:

    Tom> Perl programs are just plain text, though, so
    Tom> you could download emacs for Windows (???)

http://www.gnu.org/software/emacs/windows/ntemacs.html

-- 
Kent E. Holsinger                Kent@Darwin.EEB.UConn.Edu
                                 http://darwin.eeb.uconn.edu
-- Department of Ecology & Evolutionary Biology          
-- University of Connecticut, U-43                                       
-- Storrs, CT   06269-3043                                               


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

Date: Fri, 29 Oct 1999 15:57:17 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Forcing a submit
Message-Id: <Pine.HPP.3.95a.991029155459.13458G-100000@hpplus01.cern.ch>

On Thu, 28 Oct 1999 brsuresh@my-deja.com wrote:

> I need to get a webpage form, change the ACTION attribute of the FORM
> tag to my webserver and force a SUBMIT ACTION.

You may have convinced yourself that you have such a "need".  This is
likely misguided.

> Can some one tell me how
> to force the SUBMIT ?

"Force" doesn't work on the WWW, so your present quest is doomed.

Why not explain to the CGI authoring group just what it is that you want
to achieve, in terms of an operational requirement, and ask for a
suggestion that can work, instead of telling them that you have a "need"
which they already know to be insoluble.

And when you next have a Perl language question, we'll see you back
here.  OK?

good luck.




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

Date: Fri, 29 Oct 1999 09:04:42 -0500
From: Jerry Preston <g-preston1@ti.com>
Subject: hashing
Message-Id: <3819A97A.8DBFC5AE@ti.com>

Hi,

I have a hash that is made up of the following:

 % who =  $number, $name

 I have the number, but how do I get the name?

   $name = $who{ $number };

What is wrong?  How should I do this?

Thanks,

Jerry





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

Date: Fri, 29 Oct 1999 09:44:55 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: hashing
Message-Id: <3819B2E7.AE675D40@texas.net>

Jerry Preston wrote:
> 
> Hi,
> 
> I have a hash that is made up of the following:
> 
>  % who =  $number, $name

You're missing some parentheses and a semicolon.  And you should use the
'fat comma' in this case, for clarity.

>  I have the number, but how do I get the name?
> 
>    $name = $who{ $number };
> 
> What is wrong?  How should I do this?

perldoc perldata

- Tom


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

Date: Fri, 29 Oct 1999 10:56:11 -0500
From: Jerry Preston <g-preston1@ti.com>
Subject: Re: hashing
Message-Id: <3819C39B.B4B03B14@ti.com>

Tom, the hash is working well. Setting it up is no problem.
I do not understand who to get $name out if the hash when I
know the $number.  Do you know how??
I have tried this:

$name = $who{ $number };

But I get nothing.  I know that the data exits in the hash.
I can print it out.

Thanks,

Jerry

Tom Briles wrote:

> Jerry Preston wrote:
> >
> > Hi,
> >
> > I have a hash that is made up of the following:
> >
> >  % who =  $number, $name
>
> You're missing some parentheses and a semicolon.  And you should use the
> 'fat comma' in this case, for clarity.
>
> >  I have the number, but how do I get the name?
> >
> >    $name = $who{ $number };
> >
> > What is wrong?  How should I do this?
>
> perldoc perldata
>
> - Tom

Tom Briles wrote:

> Jerry Preston wrote:
> >
> > Hi,
> >
> > I have a hash that is made up of the following:
> >
> >  % who =  $number, $name
>
> You're missing some parentheses and a semicolon.  And you should use the
> 'fat comma' in this case, for clarity.
>
> >  I have the number, but how do I get the name?
> >
> >    $name = $who{ $number };
> >
> > What is wrong?  How should I do this?
>
> perldoc perldata
>
> - Tom



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

Date: Fri, 29 Oct 1999 09:04:45 -0500
From: Poohba <poohba@io.com>
Subject: How do you strip spaces?
Message-Id: <Pine.LNX.4.10.9910290858360.22062-100000@fnord.io.com>

I am trying to strip all spaces more than one.  I want to delete all of
the spaces except for one space.  How is this done?


	      *		Web Page Designs	  *
	     / poohba@io.com  |  www.io.com/~poohba\
	     ---------------------------------------
	     \ For info about me send message with /
	      *      subject "send file help"     * 
		



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

Date: Fri, 29 Oct 1999 07:30:37 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: How do you strip spaces?
Message-Id: <MPG.12834f6c40281862989825@nntp1.ba.best.com>

Poohba (poohba@io.com) seems to say...
> I am trying to strip all spaces more than one.  I want to delete all of
> the spaces except for one space.  How is this done?

#!perl -w
use strict;

$\ = "\n";
print foreach split /\n/, `perldoc -q strip`;


-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Fri, 29 Oct 1999 09:38:33 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How do you strip spaces?
Message-Id: <3819B169.E2BE5CDB@texas.net>

Poohba wrote:
> 
> I am trying to strip all spaces more than one.  I want to delete all of
> the spaces except for one space.  How is this done?
> 

Leading? Trailing?  Both?  What?

Give us an example.

- Tom


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

Date: 29 Oct 1999 14:46:22 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: It is always like this here?
Message-Id: <7vcbvu$i9h$5@info2.uah.edu>

In article <000b8d9b.40a12527@usw-ex0101-001.remarq.com>,
	Mark Bluemel <mark.bluemelNOmaSPAM@siemens.co.uk.invalid> writes:

: I've been teaching myself Perl for a few weeks, with moderate success,
: so I thought I'd join the newsgroup. After just one day, I'm more than
: half inclined to drop out again. Large amount of traffic, huge
: noise-to-signal ratio, cluelessness in abundance and a fair proportion
: of abuse - these all add up to somewhere that I'm not feeling like
: hanging round in.

comp.lang.perl.misc is really a gold mine.  Think of a real gold mine.
Is it solid gold through and through?  Nope, you have to dig a little.
With a little experience, you learn what to look for.

: Is it always like this, or have I picked a bad time?

You always wish there were more gold in a gold mine, but that's not
the reality of the situation.  There's always much more worthless
material in a gold mine than there is gold, but the gold is what makes
it worthwhile.

: Are there techniques we could use to improve things, like frequently
: posted pointers to FAQs etc... (No, not the whole flaming things - if
: people can read news, surely they can find a web page given a hint)? Or
: is it simply that Perl attracts a vast number of <insert your
: uncomplementary epithet here>?

I think we've tried damn near everything, but if you have a good idea,
feel free to try it out. :-)

Greg
-- 
Reality is only an illusion, albeit a very persistent one.
    -- Albert Einstein


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

Date: 29 Oct 1999 08:03:58 -0700
From: Jim Traugott <jtraug@seanet.com>
Subject: Re: It is always like this here?
Message-Id: <ubt9ius2p.fsf@seanet.com>

>>>>> "Greg" == Greg Bacon <gbacon@ruby.itsc.uah.edu> writes:

    > comp.lang.perl.misc is really a gold mine.  Think of a real gold mine.
    > Is it solid gold through and through?  Nope, you have to dig a little.
    > With a little experience, you learn what to look for.

Well put!
I've always considered myself a lurker here; being a Perl miner sounds
better...

jim (shoveling)


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

Date: Fri, 29 Oct 1999 17:29:44 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: It is always like this here?
Message-Id: <Pine.HPP.3.95a.991029172809.13458J-100000@hpplus01.cern.ch>

On 29 Oct 1999, Jim Traugott wrote:

> I've always considered myself a lurker here; being a Perl miner sounds
> better...
> 
> jim (shoveling)

I'm trying to work out how this relates to the old saying:
"when you find you're down a hole, stop digging".

I guess there must be an exception to every rule  ;-))



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

Date: Fri, 29 Oct 1999 15:44:58 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: It is always like this here?
Message-Id: <pudge-2910991143560001@192.168.0.77>

In article <000b8d9b.40a12527@usw-ex0101-001.remarq.com>, Mark Bluemel
<mark.bluemelNOmaSPAM@siemens.co.uk.invalid> wrote:

# I've been teaching myself Perl for a few weeks, with moderate success,
# so I thought I'd join the newsgroup. After just one day, I'm more than
# half inclined to drop out again. Large amount of traffic, huge
# noise-to-signal ratio, cluelessness in abundance and a fair proportion
# of abuse - these all add up to somewhere that I'm not feeling like
# hanging round in.

That is why comp.lang.perl.moderated was created.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Fri, 29 Oct 1999 17:30:57 +0200
From: "Michiel Lankamp" <mlankamp@hotmail.com>
Subject: jpeg-files
Message-Id: <3819bdc6$0$32608@reader1.casema.net>

Is it possible to check the height and width of a jpeg-file? If possible,
how?

Thankz




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

Date: 29 Oct 1999 14:41:49 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: length (number of items) of an array
Message-Id: <7vcbnd$i9h$4@info2.uah.edu>

In article <381919d0.424586352@news.nikoma.de>,
	nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton) writes:

: On 28 Oct 1999 14:40:09 GMT, gbacon@ruby.itsc.uah.edu (Greg Bacon)
: wrote:
: 
: >        return 0 if $#_ == -1;
: 
: What if someone outside of your subroutine fiddles with $[ ?

If you're using my sub to find the number of items in an array, then
someone fiddling with $[ is the least of your worries. :-)

Greg
-- 
They send you off to college to try to gain a little knowledge
But all you wanna do is learn how to score.
    -- Jimmy Buffett


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

Date: Fri, 29 Oct 1999 15:24:46 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Reinhold Jordan <r.jordan@gigabell.net>
Subject: Re: mySQL -> Sybase
Message-Id: <3819A01E.DC6BCC96@kawo2.rwth-aachen.de>

Reinhold Jordan wrote:
> I'm looking for an easy way to transfer tables from a mySQL to a Sybase.
> I think, this is often used, but I didn't find a solution.

Use DBI with both. See the explanations at
http://www.perl.com/pub/1999/10/DBI.html and 
http://www.ora.com/catalog/msql/chapter/ch10.html

/Alex


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

Date: Fri, 29 Oct 1999 15:30:01 +0200
From: Daniel Heiserer <daniel.heiserer@bmw.de>
Subject: perl double-split
Message-Id: <3819A159.55C6D670@bmw.de>

Hi,

assume I read a file into a variable in perl:

undef $/;
$data=<>;

I know how I can split the $data (according the lines) into field @Tmp
using 
@Tmp=split('\n',$data);

But assume I read a table, or comma separated file:

#-----------file------------
me,you,karl,mary,joan
23,3455,34543,2343,34
#-----------file------------

and I want to split it into a file using TWO separators:
"\n" for the "lines" and "," for the columns and the resultant
should be a double-indexed field @Tmp2:

@Tmp2=howtosplit_doubles('\n',',',$data);

So $Tmp2[1][1]=3455

How could that be done in a that simple and similar way??????

I know perl can do that easily. ;-)

Any hints?

Thanks daniel


mailto:daniel.heiserer@bmw.de


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

Date: Fri, 29 Oct 1999 11:53:33 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: perl lang parser
Message-Id: <1e0ep7c.my80qq1h29w0gN%kpreid@ibm.net>

Scott Lanning <slanning@bu.edu> wrote:

> Then how do you write a Perl program if you don't know the
> way it will work? I mean it as a rhetorical question. It seems
> it should be possible to parse Perl given you know the rules.
> (maybe all such processors are defined to be perl code?)

#!perl -w

BEGIN {
  eval 'sub foo (' . (rand > .5 ? '@' : '$') . ') {join "-", @_}';
}

print foo 1, 2, "\n";
# the way this line is parsed depends on the prototype of foo(),
# which is random.

__END__

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.


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

Date: 29 Oct 1999 15:43:27 GMT
From: hglawson@nr.infi.net (Hugh Lawson)
Subject: Re: postgres and perl
Message-Id: <slrn81jghi.lle.hglawson@cumquat.fruit.com>

On Fri, 29 Oct 1999 05:51:17 GMT, Lasengo <lasingero@hotmail.com> wrote:
>i have redhat 5.1 and running postgresql. my database is up and
>running... i want to use perl to access the postgres database and
>generate the resultset in html. how  can i use perl to do this? do i
>need dbd/dbi?

Use Pg.pm  

On my setup it's at  /usr/local/pgsql/interfaces/perl5/, along with
documentation.  But I compiled my own postgresql and don't know where it
is on the RedHat 5.1 standard install.

-- 
Hugh Lawson
Greensboro, North Carolina
hglawson@nr.infi.net



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

Date: Fri, 29 Oct 1999 15:08:25 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Q: digit-wise number comparisons ?
Message-Id: <38199C49.FED3975@ife.ee.ethz.ch>

M.J.T. Guy wrote:
> 

> Eh?    It's self evident that sets containing only multiples of 11
> are not uniformly distributed over the set of all possible sets.

Instead of taking only multiples of 11, you can of course offset them by
1-10. Only that going from 0-999999 gives one more key than with
offsets.
This way you get a complete set of distributions which joined give all
numbers in the range.

But you are correct, the cheksum method gives more values.

> Nope.   The obvious check digit coding does better, giving N/10 values.
> 
> E.g. take all numbers the sum of whose digits is 7 mod 10.

- Alex


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

Date: Fri, 29 Oct 1999 15:55:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: remove the html tag in the file
Message-Id: <5sjS3.6273$23.379468@typ11.nn.bcandid.com>

In article <slrn7v1uml.9kl.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
>Samuel Kilchenmann (skilchen@swissonline.ch) wrote on MMCCXIX September
>MCMXCIII in <URL:news:lK%H3.19563$m4.77238483@news.magma.ca>:
>-- HTML::Parser which is unusable for newbies without a working example
>-- which should be urgently added to perlfaq9.
>
>Parsing HTML shouldn't be done by newbies, because it's non-trivial.

I don't know many people who parse HTML correctly, newbies or
otherwise.  But my 7-year-old nephew has Netscape parse HTML for him
all the time.  Parsing HTML is something computers are better than
people at.

But Netscape doesn't provide as much data about the parse as one might
like.  It's good at rendering the HTML on screen or in ASCII -- better
than Lynx, in fact -- but it's not as useful for the kinds of things
some people want to do with HTML.

Clearly more usefulness requires some degree of greater difficulty in
general.  I don't think it requires impossibility for newbies to use.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Oct 28 1999
12 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 29 Oct 1999 15:59:33 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: remove the html tag in the file
Message-Id: <FvjS3.6279$23.364088@typ11.nn.bcandid.com>

In article <37F4281E.FB54FA8B@home.com>,
Kenneth Bandes  <kbandes@home.com> wrote:
>Abigail wrote:
>> Perl also has to offer:
>> 
>>      open (NSGMLS, "| /usr/local/bin/nsgmls")
>
>which is actually the right answer to the original question.  nsgmls
>is James Clark's SGML (and therefore HTML and XML) parser.

HTML is theoretically SGML.  But there are lots of HTML documents out
there that don't parse well, or at all, with SGML parsers but are,
nevertheless, rendered correctly by browsers.  (Here "correctly" means
"as the author intended.")  I think more than 90% of the HTML on the
Web is invalid.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Oct 28 1999
12 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 29 Oct 1999 16:00:15 GMT
From: SG <sg@midwal.ca>
Subject: Return value from a stored procedure.
Message-Id: <3819C26E.605CBA07@midwal.ca>

     Dear Experts!
 How can I receive in my perl script a value returned by a stored
procedure at Sybase?
  Regards,
        Serguei.



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

Date: Fri, 29 Oct 1999 15:30:33 GMT
From: rob watson <sloon@mindless.com>
Subject: Searching within web pages for text
Message-Id: <=bwZOA0bZvm7YX8b7c3mCYD63g+N@4ax.com>

Hi,

I am curious as to how I could search within "only" the content of web
pages for text. Ignoring the HTML tags, etc. and only searching for
the given phrase within the text that would normally be rendered on
the screen when the page is viewed in a browser.

Thank's so much
rob


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

Date: Fri, 29 Oct 1999 15:26:08 +0200
From: "Walter van den Berg" <wvandenbergNOSPAM@ttpdiskad.nl>
Subject: simplifying a script
Message-Id: <7vc7gk$vn$1@news1.xs4all.nl>

Hi group,

(not sure in wich group to post, so I cross-posted, if that's not ok, please
let me know)

I wrote my first script, and it works, but I need some help to make it a bit
shorter, clearer and easier to adjust to new situations. It's a script to
generate an html-file that will be used many times. You can see an example
at http://www.bobbwatches.com/cartier/index.html
(I know it's not a pretty site, and I doubt it will ever work...)
I want to know if you can make the handle (TDT1 to TDT11, see below) a
variable, and wether or not you can put a variable in a variable
($TableData1 to $TableData11, see below), to make the first part a whole lot
shorter and easier to adjust. And if you have any other remarks, please, i'm
listening.

Undoubtly my complete script will be laughable to you, but it's my first,
and I felt very excited when it worked. I have no former programming
experience, but I already know I'm in love with Perl. Do you remember your
first time? :-)


I zipped up the whole package (with database and the original htmlfiles) and
uploaded it here (so you can see the big picture):
http://www.vandenb.cistron.nl/rotzooi/MyFirstPerl.zip (it's only 4.74 kb).

Now here's my script (wrote it in windows, by the way - sorry):


#!/usr/bin/perl -w

#Goal: putting entries out of a database into a html file,
#you can see an example of the result
#at http://www.bobbwatches.com/cartier/index.html

#the database has ten fields from left to right
#and four from top to bottom and is tab-separated
#and consists of:

#$Name
#$Number
#$Material
#$Band
#$Movement
#$Ref
#$CaseCon
#$DialCon)
#$BoxPap)
#$CaseSize


#name of the database:
$TheFile = "database.txt";

#the file that Perl has to make:
$NewFile = '>bobb.html';

#opening both files
open(ORIG, $TheFile) or die "Can't open Database.\n";
open(NEW, $NewFile) or die "Can't open output.\n";

#This all my html-doodoo
#(I've put everything in different files because
#I do not yet know how to get complete lists out
#databases - and the html is looking disasterous...):

$TableData1  = 'bobbhtml/TableData1.txt';
$TableData2  = 'bobbhtml/TableData2.txt';
$TableData3  = 'bobbhtml/TableData3.txt';
$TableData4  = 'bobbhtml/TableData4.txt';
$TableData5  = 'bobbhtml/TableData5.txt';
$TableData6  = 'bobbhtml/TableData6.txt';
$TableData7  = 'bobbhtml/TableData7.txt';
$TableData8  = 'bobbhtml/TableData8.txt';
$TableData9  = 'bobbhtml/TableData9.txt';
$TableData10 = 'bobbhtml/TableData10.txt';
$TableData11 = 'bobbhtml/TableData11.txt';



#This tells Perl to open my html-doodoo and
#put all that's in it in a list:

open(TDT1, $TableData1) or die "Can't open html-files.\n";
                       @TableData1 = <TDT1>;
open(TDT2, $TableData2) or die "Can't open html-files.\n";
                       @TableData2 = <TDT2>;
open(TDT3, $TableData3) or die "Can't open html-files.\n";
                       @TableData3 = <TDT3>;
open(TDT4, $TableData4) or die "Can't open html-files.\n";
                       @TableData4 = <TDT4>;
open(TDT5, $TableData5) or die "Can't open html-files.\n";
                       @TableData5 = <TDT5>;
open(TDT6, $TableData6) or die "Can't open html-files.\n";
                       @TableData6 = <TDT6>;
open(TDT7, $TableData7) or die "Can't open html-files.\n";
                       @TableData7 = <TDT7>;
open(TDT8, $TableData8) or die "Can't open html-files.\n";
                       @TableData8 = <TDT8>;
open(TDT9, $TableData9) or die "Can't open html-files.\n";
                       @TableData9 = <TDT9>;
open(TDT10, $TableData10) or die "Can't open html-files.\n";
                       @TableData10 = <TDT10>;
open(TDT11, $TableData11) or die "Can't open html-files.\n";
                       @TableData11 = <TDT11>;



#This is the loop in wich perl takes all the entries out of
#my database and puts in the right order:

while(<ORIG>) {
 $TheLine = $_; #I'm not sure about this one,
                #but when I take it out, it's not working...


 #Here every entry gets named
        ($Number, $Name, $Material, $Band, $Movement,
         $Ref, $CaseCon, $DialCon, $BoxPap, $CaseSize) =
         split(/\t/, $TheLine);


   #This puts everything in the new file,
   #and in the right order.
   print (NEW @TableData1);
   print (NEW $Name);
   print (NEW @TableData2);
   print (NEW $Number);
   print (NEW @TableData3);
   print (NEW $Material);
   print (NEW @TableData4);
   print (NEW $Band);
   print (NEW @TableData5);
   print (NEW $Movement);
   print (NEW @TableData6);
   print (NEW $Ref);
   print (NEW @TableData7);
   print (NEW $CaseCon);
   print (NEW @TableData8);
   print (NEW $DialCon);
   print (NEW @TableData9);
   print (NEW $BoxPap);
   print (NEW @TableData10);
   print (NEW $CaseSize);
   print (NEW @TableData11);

}

print "You have a nice new html-file.\n";



##############################

When replying by email, please take NOSPAM out of my emailadress
--
Walter van den Berg

TTP/Disk'Ad bv
Context Provider
Orlyplein 147e,
1043 DV Amsterdam
Tel 020- 680 2929
Fax 020- 680 2920
www.ttpdiskad.nl




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

Date: 29 Oct 1999 15:02:10 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: simplifying a script
Message-Id: <7vccti$iua$1@info2.uah.edu>

In article <7vc7gk$vn$1@news1.xs4all.nl>,
	"Walter van den Berg" <wvandenbergNOSPAM@ttpdiskad.nl> writes:

: (not sure in wich group to post, so I cross-posted, if that's not ok, please
: let me know)

comp.lang.perl is long dead.  Stick to comp.lang.perl.misc.

Use arrays. :-)

    #! /usr/bin/perl -w

    use strict;

    my $in  = 'database.txt';
    my $out = 'bobb.html';

    open IN,  $in     or die "$0: open $in: $!\n";
    open OUT, ">$out" or die "$0: open >$out: $!\n";

    my @table_data = qw(
        bobbhtml/TableData1.txt
        bobbhtml/TableData2.txt
        bobbhtml/TableData3.txt
        bobbhtml/TableData4.txt
        bobbhtml/TableData5.txt
        bobbhtml/TableData6.txt
        bobbhtml/TableData7.txt
        bobbhtml/TableData8.txt
        bobbhtml/TableData9.txt
        bobbhtml/TableData10.txt
        bobbhtml/TableData11.txt
    );

    my @table;

    foreach my $file (@table_data) {
        local $/;
        open TD, $file or die "$0: open $file: $!";
        push @table, { file => $file, data => <TD> };
        close TD;
    }

    while (<IN>) {
        my @fields = split /\t/;

        my $data;
        for (@fields) {
            $data = shift @table;
            print OUT @{ $data->{data} }, $_;
        }

        while ($data = shift @table) {
            print OUT @{ $data->{data} };
        }
    }

    print "You have a nice new html-file.\n";

Enjoy,
Greg
-- 
Health is merely the slowest possible rate at which one can die.


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

Date: Fri, 29 Oct 1999 17:33:55 +0200
From: "Walter van den Berg" <wvandenbergNOSPAM@ttpdiskad.nl>
Subject: Re: simplifying a script
Message-Id: <7vcf0h$8fh$1@news1.xs4all.nl>


>Greg Bacon  wrote:

> Use arrays. :-)
>

>(and a whole bunch of code)

I will use arrays! Just have to read further in my Perl for Dummies-book...
Thank you for the code!

>
> Enjoy,
> Greg
> --
> Health is merely the slowest possible rate at which one can die.

Thanks,
Walter.




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

Date: Fri, 29 Oct 1999 17:45:35 +0200
From: "Walter van den Berg" <wvandenbergNOSPAM@ttpdiskad.nl>
Subject: Re: simplifying a script
Message-Id: <7vcfmd$94n$1@news1.xs4all.nl>


Greg Bacon writes:
>

(...)

>     my @table;
>
>     foreach my $file (@table_data) {
>         local $/;
>         open TD, $file or die "$0: open $file: $!";
>         push @table, { file => $file, data => <TD> };
>         close TD;
>     }
>

(...)

Hm, Greg? It doesn't work with me... I'm just a beginner, but I think it's
because the handle TD doesn't have a value yet. Could that be?
(I'm working with windows, but that doesn't make a difference, does it?)


> Enjoy,
> Greg
> --
> Health is merely the slowest possible rate at which one can die.

Bye,
Walter.




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

Date: 29 Oct 1999 15:53:54 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: simplifying a script
Message-Id: <7vcfui$jfr$1@info2.uah.edu>

In article <7vcfmd$94n$1@news1.xs4all.nl>,
	"Walter van den Berg" <wvandenbergNOSPAM@ttpdiskad.nl> writes:
: 
: Greg Bacon writes:
:
: >     my @table;
: >
: >     foreach my $file (@table_data) {
: >         local $/;
: >         open TD, $file or die "$0: open $file: $!";
: >         push @table, { file => $file, data => <TD> };
: >         close TD;
: >     }
: 
: Hm, Greg? It doesn't work with me...

Oh, crud.  Change the push line to

    push @table, { file => $file, data => [ <TD> ] };

Exercise for the reader: if possible, process the table files one at
a time instead of slurping each of them; otherwise, prove that it's
impossible.

Greg
-- 
Cop:     I can put you in Queens on the night of the hijacking.
Hockney: Really?  I live in Queens.  Did you put that together yourself?


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

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


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