[16825] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4236 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 6 14:14:15 2000

Date: Wed, 6 Sep 2000 11: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)
Message-Id: <968263517-v9-i4236@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4236

Today's topics:
        "dashed" params... schnurmann@my-deja.com
    Re: "dashed" params... <uri@sysarch.com>
    Re: "dashed" params... <franl-removethis@world.omitthis.std.com>
    Re: "dashed" params... <uri@sysarch.com>
    Re: $LIST_SEPARATOR bug?? <bart.lateur@skynet.be>
    Re: A question about sleep(). <christopher_j@uswest.net>
    Re: Backslash usage? <iltzu@sci.invalid>
    Re: Beating the perlcc dead horse again... vi_2000@hotmail.com
    Re: Beating the perlcc dead horse again... <anmcguire@ce.mediaone.net>
        calling a script without POST or GET <frabilod@lino.com>
    Re: calling a script without POST or GET <christopher_j@uswest.net>
    Re: calling a script without POST or GET (Rafael Garcia-Suarez)
    Re: CGI Script needed <seipher@my-deja.com>
    Re: CGI.pm: controlling Back & Reload nobull@mail.com
    Re: dmake of PERL-5.6.0 using MSVC60 compiler gens erro <rydz@erols.com>
        Generate Graphics by Perl <David.Hiskiyahu@alcatel.be>
    Re: Generate Graphics by Perl <sariq@texas.net>
    Re: Generate Graphics by Perl <David.Hiskiyahu@alcatel.be>
    Re: help with a hash? <christopher_j@uswest.net>
        Help with looping through code needed kevin@oldcommunications.com
    Re: Help with looping through code needed <christopher_j@uswest.net>
    Re: How to create a simple backup program? monkfunk@my-deja.com
    Re: How? Read a file from another server? <christopher_j@uswest.net>
    Re: HTML::parse bug <T.Cockle@staffs.ac.uk>
    Re: HTML::parse bug <T.Cockle@staffs.ac.uk>
    Re: intranet using perl cgi (Nobody)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 06 Sep 2000 17:30:58 GMT
From: schnurmann@my-deja.com
Subject: "dashed" params...
Message-Id: <8p5v0j$vv2$1@nnrp1.deja.com>

Where can I find information on how to support calls like this to my
subroutines?

$my_obj->a_routine(-param1 => 'value', -param2 => 'another value', -
something_else => 10);



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


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

Date: Wed, 06 Sep 2000 17:51:15 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: "dashed" params...
Message-Id: <x78zt5l88c.fsf@home.sysarch.com>

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

  s> Where can I find information on how to support calls like this to my
  s> subroutines?

  s> $my_obj->a_routine(-param1 => 'value', -param2 => 'another value', -
  s> something_else => 10);

just assign all the args to a hash and deal with them then.

sub a_routine {

	my( $self, %args ) = @_ ;

	$foo_arg = $args{'-foo'} || $default_foo ;

that works unless you want to be able to pass in a false value to
$foo_arg. then use:

	$foo_arg = exists $args{'-foo'} ? $args{'-foo'} : $default_foo ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 6 Sep 2000 18:00:11 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
To: schnurmann@my-deja.com
Subject: Re: "dashed" params...
Message-Id: <m3wvgpv1sk.fsf@franl.andover.net>

schnurmann@my-deja.com writes:

> Where can I find information on how to support calls like this to my
> subroutines?
> 
> $my_obj->a_routine(-param1 => 'value', -param2 => 'another value', -
> something_else => 10);

The => is just a fat comma.  The above syntax simply passes a list of
strings to the function.  In the above case, the strings are:

	'-param1'
	'value'
	'-param2'
	'another value'
	'-something_else'
	'10'

The called function then takes @_ (the argument list) and initializes a
hash with it, like this:

	my %args = @_;

So that the named args can be accessed like this:

	$args{-param2}

Hope this helps.
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.


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

Date: Wed, 06 Sep 2000 18:04:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: "dashed" params...
Message-Id: <x71yyxl7lo.fsf@home.sysarch.com>

>>>>> "FL" == Francis Litterio <franl-removethis@world.omitthis.std.com> writes:

  FL> schnurmann@my-deja.com writes:
  >> Where can I find information on how to support calls like this to my
  >> subroutines?
  >> 
  >> $my_obj->a_routine(-param1 => 'value', -param2 => 'another value', -
     ^^^^^^^^^
  >> something_else => 10);

  FL> The called function then takes @_ (the argument list) and initializes a
  FL> hash with it, like this:

  FL> 	my %args = @_;

he was using a method call (see marked code above). you forgot to get
the object first. see my post for a correct reply.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 06 Sep 2000 15:22:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <c7ocrschjtl5eqchu5le5c7dv551vrt276@4ax.com>

jason wrote:

>I thought 
>that because there was such a thing as &quot; that a bare " was not 
>strict HTML .. but I've never checked

It is. Here is an example of what it's for:

	<input name=size value="1.1/4&quot;">

which defines the value attribute as '1.1/4"'.

-- 
	Bart.


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

Date: Wed, 6 Sep 2000 08:45:49 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: A question about sleep().
Message-Id: <GEtt5.1813$Xq2.132893@news.uswest.net>


"Ben Ben" <idleisidle@usa.net> wrote:
> Can anyone tell me how function sleep() works?

Sleep works fine, sleep x sleeps for x seconds.

> I use Active Perl on Win9X.
> I have a perl program, and when I run it, it just likes dead rather than
> sleep.
> Could someone explain it for me?
[snip]
> while ($I>0)
  ^^^^^^^^^^^^
There's your problem right there you've got an infinite loop.




The problem is that your program never exits, which _means_ that
your I/O buffer is never getting flushed.  I've seen it a thousand
times.  A lot of times when you create a program that never exits
you'll never get any output (especially if it is caught in a tight
loop).

Now, without passing judgement as to _why_ you want to have an
endless loop (creating a webpage no less!), here's a better
version of that prog.


#!/usr/local/bin/perl

# flush STD OUT buffers automatically
select STDOUT; $| = 1;

print "Content-type:text/html\n\n";

print "<html>\n";
print "<head><title></title></head>\n";
print "<BODY BGCOLOR=\"#EEEEEE\">\n";

$I=1; $K=1;

# btw, why do you need $I and $K?

while ($I>0)
    {
    print "$K<br>";
    sleep 100;
    $K++;
    }

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




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

Date: 6 Sep 2000 15:18:39 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Backslash usage?
Message-Id: <968253172.19439@itz.pp.sci.fi>

In article <8ovj37$asa$1@orpheus.gellyfish.com>, Jonathan Stowe wrote:
>
>my $foo = {blah => 1,
>           zub  => 2};
>
>my %gh;
>
>\%gh = $foo;

I don't think that does what you think it does.

Hint:  It's exactly equivalent to  () = {'blah', 1, 'zub', 2};

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: Wed, 06 Sep 2000 15:45:50 GMT
From: vi_2000@hotmail.com
Subject: Re: Beating the perlcc dead horse again...
Message-Id: <8p5or6$o59$1@nnrp1.deja.com>


>
> > How can I perlcc and include my Net::FTP etc.  Modules???
>                                ^^^^^^^^^^^
> 							   ^^
> MY Net::FTP has a copyright notice:
>
> # perldoc Net::FTP
> [snip]
> COPYRIGHT
>        Copyright (c) 1995-1998 Graham Barr.
> [snip]
>
> You are making a joke, aren't you? Please tell me you are! Please???
> Pretty please... My trust in human nature is low enough as it is.
>




By stating "my Net::FTP", I was simply stating that I installed the
module and used it in a program.  This was odviously a mistake.

Perl must suck since the three posts to my question offer nothing of
value except criticism which in itself is totally worthless when I am
trying to build a useful program!

So Long Perl humpers.  I'm going back to C++ where I can get real work
done!


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


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

Date: Wed, 6 Sep 2000 12:35:27 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Beating the perlcc dead horse again...
Message-Id: <Pine.LNX.4.21.0009061232470.3948-100000@hawk.ce.mediaone.net>

On Wed, 6 Sep 2000, vi_2000@hotmail.com quoth:

~~ Date: Wed, 06 Sep 2000 15:45:50 GMT
~~ From: vi_2000@hotmail.com
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: Beating the perlcc dead horse again...
~~ 
~~ 
~~ >
~~ > > How can I perlcc and include my Net::FTP etc.  Modules???
~~ >                                ^^^^^^^^^^^
~~ > 							   ^^
~~ > MY Net::FTP has a copyright notice:
~~ >
~~ > # perldoc Net::FTP
~~ > [snip]
~~ > COPYRIGHT
~~ >        Copyright (c) 1995-1998 Graham Barr.
~~ > [snip]
~~ >
~~ > You are making a joke, aren't you? Please tell me you are! Please???
~~ > Pretty please... My trust in human nature is low enough as it is.
~~ >
~~ 
~~ 
~~ 
~~ 
~~ By stating "my Net::FTP", I was simply stating that I installed the
~~ module and used it in a program.  This was odviously a mistake.
~~ 
~~ Perl must suck since the three posts to my question offer nothing of
~~ value except criticism which in itself is totally worthless when I am
~~ trying to build a useful program!

Pizza must suck because the guy at the pizza parlor keeps telling
me my fly is down.  I am going back to hamburgers, because they
have mustard.

anm
-- 
Andrew N. McGuire
anmcguire@ce.mediaone.net
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'



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

Date: Wed, 06 Sep 2000 15:59:55 GMT
From: Francois Bilodeau <frabilod@lino.com>
Subject: calling a script without POST or GET
Message-Id: <39B66A5A.92E8F699@lino.com>

If I call a PERL script with a POST action on a form I can easily access
all the form's content by using:
$query = <STDIN>

But if I call this same script by a URL in a browser:
http://myserver.com/cgi-bin/myscript.pl?myvariable=1234&var2=whatever
the script is call OK but $ENV{'CONTENT_LENGTH'} = 0 and STDIN is empty!

How can I access the parameter? What is wrong? The way to pass the
parameter or the way to acces them or both?
Thanks for any suggestions
===============================
Francois Bilodeau, informaticien
mailto:frabilod@lino.com
http://www.lino.com/~frabilod
===============================
WEB, GIS, data base, 3-D graphic
===============================




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

Date: Wed, 6 Sep 2000 09:10:36 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: calling a script without POST or GET
Message-Id: <%%tt5.1879$Xq2.143033@news.uswest.net>


"Francois Bilodeau" <frabilod@lino.com> wrote:
> If I call a PERL script with a POST action on a form I can easily access
> all the form's content by using:
> $query = <STDIN>
>
> But if I call this same script by a URL in a browser:
> http://myserver.com/cgi-bin/myscript.pl?myvariable=1234&var2=whatever
> the script is call OK but $ENV{'CONTENT_LENGTH'} = 0 and STDIN is empty!
>
> How can I access the parameter? What is wrong? The way to pass the
> parameter or the way to acces them or both?

Nothing is wrong, you're just doing more work than is
necessary.  Of _course_ STDIN is empty, why wouldn't it be?
You're not posting to the script are you?  If you want to
get the query string from a GET, you _could_ use

$query = $ENV{'QUERY_STRING'};

But, unless you want to get the whole query string all in one
big blob (which it doesn't seem like that's what you want it from
the example you gave) you want to use cgi-lib.pl (or somesuch).
Like so:


require 'cgi-lib.pl';

ReadParse();

$myvariable = $in{'myvariable'};
$var2 = $in{'var2'};

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

If you haven't guessed, cgi-lib.pl and ReadParse() take all the
parameters passed to your script (from a post or a get) and put
them into a hash name %in (i.e. var=value -> $in{'var'} = "value"; ).

cgi-lib.pl is really a must have for any serious cgi program.




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

Date: Wed, 06 Sep 2000 16:10:57 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: calling a script without POST or GET
Message-Id: <slrn8rcrg3.2ks.rgarciasuarez@rafael.kazibao.net>

Francois Bilodeau wrote in comp.lang.perl.misc:
>If I call a PERL script with a POST action on a form I can easily access
>all the form's content by using:
>$query = <STDIN>
>
>But if I call this same script by a URL in a browser:
>http://myserver.com/cgi-bin/myscript.pl?myvariable=1234&var2=whatever
>the script is call OK but $ENV{'CONTENT_LENGTH'} = 0 and STDIN is empty!

Normal -- by a URL, you're using the GET method. Your parameters are in
the QUERY_STRING environment variable.

>How can I access the parameter? What is wrong? The way to pass the
>parameter or the way to acces them or both?

You should use a module, e.g. CGI.pm, to parse the CGI parameters for
you. This can be tricky. CGI.pm (probably already included in your perl
installation) does all the dirty work behind the scenes. At the prompt,
enter 'perldoc CGI'.

-- 
Rafael Garcia-Suarez | http://rgarciasuarez.free.fr/


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

Date: Wed, 06 Sep 2000 15:32:36 GMT
From: Sabretooth <seipher@my-deja.com>
Subject: Re: CGI Script needed
Message-Id: <8p5o2k$mv6$1@nnrp1.deja.com>



> Um, .. like what are you paying ??
> No seriously, this is pretty advanced in the sense that to write a
secure
> script (so that no one can exploit holes and the like) is a lot more
than
> just an evenings work.
>
> Mark
>
I've been looking around and I could get a basic script for free - but
obviously the security isn't there. One good script was available for
about £60.

The problem is, I can't afford to fork out much, as we don't charge for
any of our services and are gradually building the site up to be a
large UK online magazine where bands can have their own pages dedicated
to them. We have a number of projects in development which will bring
in revenue, but these can't really start until the site is fully
finished.

Let me know if you know where I can get some help

Thanks


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


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

Date: 06 Sep 2000 17:53:14 +0100
From: nobull@mail.com
Subject: Re: CGI.pm: controlling Back & Reload
Message-Id: <u9r96x31j9.fsf@wcl-l.bham.ac.uk>

kj0 <kj0@mailcity.com> writes:

> I'm using CGI.pm to write a CGI application that causes new records to
> be entered in a database.  The structure of the site is
> 
>                   [ok]            [submit]
>   Data Entry page  --> Review page   --> Confirmation page
> 
> All pages are generated by the same perl script.  I would like to
> arrange things such that, if the user is at the Confirmation page,
> hitting the "Back" button will send him/her to the page visited before
> the Data Entry page.  (Currently, hitting the "Back" button while
> visiting the Confirmation page sends the user to the Review page.)
> 
> Is there a way to do this?

The back button functionality is usually implemented entirely
client-side.  If there is any way to do it it will involve
reporgramming the client with client-side scripts or whatever.

> Or else, is there any way to tell if a page has been reached via the
> Back button?

Not server-side there isn't, because no message passes from the client
to the server when the back button is clicked.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 6 Sep 2000 12:08:37 -0400
From: "Stan Rydz" <rydz@erols.com>
Subject: Re: dmake of PERL-5.6.0 using MSVC60 compiler gens error C2061 in ..\iperlsys.h and ..\proto.h
Message-Id: <8p5q6n$jae$1@bob.news.rcn.net>

Thanks again Randy,

I tried nmake as you suggested and got the same errors. I think you're
right.  I must have something configured incorrectly, otherwise others would
have had this problem.

I'll keep plugging. I'll post an answer if I find one.

Regards,
Stan

"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
news:8p3coe$nf0$1@canopus.cc.umanitoba.ca...
>
> I work with Win98 as well, yet nmake worked fine for me in
> compiling perl.
>
> best regards,
> randy kobes




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

Date: Wed, 06 Sep 2000 18:13:16 +0200
From: David Hiskiyahu <David.Hiskiyahu@alcatel.be>
Subject: Generate Graphics by Perl
Message-Id: <39B66D1C.B6070F61@alcatel.be>

I have a Perl script, called via a CGI form.

The script reads user input from the CGI parameter list, scans 
some data on the server and generates a table as a result, a 
rather classical use of Perl with CGI.

In addition to the table, I would like to present a bar-chart.

Does someone have an example of Perl doing such graphics?
Lines, bars, text - that's what I need to have in he chart.

I could hack something primitive in *.ppm format, which is just
a file with a list of pixel values in it, but there should be 
solutions that will make a gif or jpeg file, right?

Kind regards,

David.



-- 
***   David Hiskiyahu, Alcatel SRD, 1 Fr.Wellesplein,  Antwerp  ***
***    Phone/Fax: +32 3 240 7965/9820, private +32 3 290 0912   ***

Man's mind stretched to a new idea never goes back to its original dimensions.
- Oliver Wendell Holmes


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

Date: Wed, 06 Sep 2000 11:26:03 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Generate Graphics by Perl
Message-Id: <39B6701B.60038F09@texas.net>

David Hiskiyahu wrote:
> 
> I have a Perl script, called via a CGI form.
> 
> The script reads user input from the CGI parameter list, scans
> some data on the server and generates a table as a result, a
> rather classical use of Perl with CGI.
> 
> In addition to the table, I would like to present a bar-chart.
> 
> Does someone have an example of Perl doing such graphics?
> Lines, bars, text - that's what I need to have in he chart.

http://search.cpan.org/search?mode=module&query=graph

Next time, kindly do the legwork yourself.

- Tom


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

Date: Wed, 06 Sep 2000 19:34:24 +0200
From: David Hiskiyahu <David.Hiskiyahu@alcatel.be>
Subject: Re: Generate Graphics by Perl
Message-Id: <39B68020.38E1062F@alcatel.be>

Tom Briles wrote:
 ...
> http://search.cpan.org/search?mode=module&query=graph
> 
> Next time, kindly do the legwork yourself.

Thanks Tom, I probably deserved an answer like this ...
Meanwhile I did find something really good - there is a
module called GD, and I can already use it:

http://stein.cshl.org/WWW/software/GD/GD.html

Hope your legs don't hurt!

David.



Tom Briles wrote:
> 
> David Hiskiyahu wrote:
> >
> > I have a Perl script, called via a CGI form.
> >
> > The script reads user input from the CGI parameter list, scans
> > some data on the server and generates a table as a result, a
> > rather classical use of Perl with CGI.
> >
> > In addition to the table, I would like to present a bar-chart.
> >
> > Does someone have an example of Perl doing such graphics?
> > Lines, bars, text - that's what I need to have in he chart.
> 
> http://search.cpan.org/search?mode=module&query=graph
> 
> Next time, kindly do the legwork yourself.
> 
> - Tom

-- 
***   David Hiskiyahu, Alcatel SRD, 1 Fr.Wellesplein,  Antwerp  ***
***    Phone/Fax: +32 3 240 7965/9820, private +32 3 290 0912   ***

Man's mind stretched to a new idea never goes back to its original dimensions.
- Oliver Wendell Holmes


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

Date: Wed, 6 Sep 2000 10:21:04 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: help with a hash?
Message-Id: <_1vt5.2129$Xq2.172545@news.uswest.net>


<ptomsic@my-deja.com> wrote:
> I want to rip a string apart, finding the HREF and the Text that's
> associated w/ the HREF, and place this into a HASH, i.e.
> $link{this.html} = "Click Here";
>
> for all the links on a page.  How could I do this using a function call
> to return the HASH?
>
> So, I want to make a call to a function (getHREFS) and have it return
> a HASH, w/ Key's as HREFS and VALUES as the text.
>
> Could someone assist (with the function returning part) as I've got the
> HREF and the text part down using TokeParser.

Well, since everyone else gave you the easy ways I might as
well give you the hard (well not really, but by comparison
maybe) way.

# assume $file contains the file
%link = ();
while ($file =~ s{<a.*?href\s*\=\s*\"(.*?)\"\.*?>(.*?)</a>}{}si)
    { $link{$1} = $2; }


That should do the trick, however, if you want to be more agressive
at capturing the urls, you might want to use this regexp instead:

=~
s{<a.*?href\s*\=\s*(?:\")?([\w\.\%/\@\:\?\&\+\-\=]+?)(?:\")?\.*?>(.*?)</a>}{
}si

Which will capture url's without "'s.  Forexample, url's like
<a href=http://someplace.com>someplace</a>
or
<a
href=http://username@pass:www.someplace.com:8080/blah_something%202.cgi?page
=page2&some-option=on target=newwindow>someplace else</a>






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

Date: Wed, 06 Sep 2000 15:50:03 GMT
From: kevin@oldcommunications.com
Subject: Help with looping through code needed
Message-Id: <8p5p31$o89$1@nnrp1.deja.com>

Hello,

In the following code, I need to get the text from between both sets of
<type></type> tags.  I thought maybe a while loop looking for the
newline character would do it, but that was just a shot in the dark.
The output should probably look something like:

String: COOL Kevin
String: COOL Kevin2

This is just a test for a bigger script I'm writing and basically I am
reading in a file and everything is in one line and I can't separate it
into lines.  I need to parse through it and pull out the data between
the XML tags.  That is going fine, but only for the first set of tags.
I need it to be recursive.

Any ideas?


#/usr/local/bin/perl

$String = 'This is a <type>COOL Kevin</type> <type>COOL
Kevin2</type>string!';

while ($line != \n)
{
$String =~ s/^.*?<type>//isg;
$String =~ s/<\/type>.*?$//isg;

print "String: $String\n";
}

Kevin
kevin@oldcommunications.com


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


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

Date: Wed, 6 Sep 2000 09:29:03 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Help with looping through code needed
Message-Id: <lhut5.1886$Xq2.151410@news.uswest.net>

#/usr/local/bin/perl

$String = 'This is a <type>COOL Kevin</type> <type>COOL
Kevin2</type>string!';

while ( $String =~ s{<type>(.*?)</type>}{}is )
  { print "String: $1\n"; }

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

Now the explanation.

The regex in the while loop will replace any <type>...</type>
section with nothing (btw, if you need to keep $String for
some other purpose, you might want to make a copy of it and
use that).  If $String no longer contains a pattern of that
sort, then the while loop will exit.  However, when the
regular expression does successfully match the pattern it
will store the text between <type> and </type> in $1.

Here's a breakdown of the regexp:

s{        # search and replace, using the {} instead of // as a pattern
delim.
<type>    # search for <type>
(         # parenthesis mean "remember the value that was matched for this
sub-pattern"
          #  it will be stored as $1
 .*?       # search for any string of characters but, only the shortest
string that
)         #
          #  allows you to match up to...
</type>   # </type>
}         # end of search expression
{}        # replace expression (which is empty, so replace with nothing)
i         # case Insensitive search
s         # treat as Single line, newlines are not boundaries


What this does is search for the smallest string between one <type> and
another </type>, store that value in $1, and replace the whole thing
(including the <type> and </type> text) with nothing.  That means, that
the next time the while loops processes the string, it will have one
less possible match, and thus, it will eventually remove all the matches
(printing out info along the way) and exit like a good little program.




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

Date: Wed, 06 Sep 2000 14:57:47 GMT
From: monkfunk@my-deja.com
Subject: Re: How to create a simple backup program?
Message-Id: <8p5m0t$kaf$1@nnrp1.deja.com>

I really am forcing the perl thing I know.  I'm trying to learn it.  I
like it's string manipulation strengths.  I'm going to wrap the script
up with perl2exe.

Perl mostly because of the ease of prompting, the learning thing and I
need to be platform independant.  Although VB would be an alternative,
I'm practicing Perl.

Thanks to all who replied.

In article <8of7ia$suj$0@216.39.131.146>,
  homer.simpson@springfield.nul (Homer Simpson) wrote:
> -- Well first you wouldn't use Perl.
> Windows still includes the old standby batch language and xcopy which
was
> written to do just what you describe.
>
> from a command prompt type xcopy /? for help.
>
> Alternatively you can use the backup program that comes with Windows
9x to do
> the same...
>
>


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


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

Date: Wed, 6 Sep 2000 11:00:02 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: How? Read a file from another server?
Message-Id: <vCvt5.2299$Xq2.189453@news.uswest.net>

#!/usr/local/bin/perl

use LWP;
require HTTP::Headers;

$user_agent = "Mozilla/4.0 (compatible; The UnBrowser 1.0; Not Windows)";

# new virtual user agent
$browser = LWP::UserAgent->new();
$browser->agent($user_agent);

my $h = HTTP::Headers->new;

# most of this is completely unnecessary BTW
$h->header('ACCEPT_LANGUAGE' => 'en',
'ACCEPT' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png,
*/*',
'ACCEPT_CHARSET' => 'iso-8859-1,*,utf-8',
'ACCEPT_ENCODING' => 'gzip',
'CONNECTION' => 'Keep-Alive');


$url = "http://www.somedomain.com/dir/somefile.ext";

# create new request
$request = new HTTP::Request(GET=>$url, $h);

# perform request
$result = $browser->request($request);

unless ($result->is_success)
    { die "HTTP GET failed!\n"; }

$resultpage = $result->content;

# yadda yadda yadda, then use your $resultpage as you will
#  to use FTP, simply use an FTP url
#  (i.e.
"ftp://username:password@ftp.server.com/dir/anotherdir/filename.ext")




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

Date: Wed, 06 Sep 2000 17:55:02 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
To: Gisle Aas <gisle@ActiveState.com>
Subject: Re: HTML::parse bug
Message-Id: <39B676E6.424EB324@staffs.ac.uk>

Hi,

Good point!
Yes I can, I have just tried it. :)

I shall try to reduce the code a little more before sending it however as it is
still a little verbose for use as an illustration.

Thanks for your help,

Tim

Gisle Aas wrote:

> Tim Cockle <T.Cockle@staffs.ac.uk> writes:
>
> > I don't use it directly there is a reference from HTML::TokeParser.
> >
> > But I have looked at the TokeParser (get_token) and the failure occurs in the
> > HTML::Parse code.
>
> How does it crash?  Are you able to reduce it to a little test program
> that you can share?
>
> > jason wrote:
> >
> > > Tim Cockle <T.Cockle@staffs.ac.uk> wrote ..
> > > >I have found a bug somwwhere in HTML::parse. I have written a simple
> > > >server wich works fine. However if I convert it into a forking server it
> > > >crashes out.
> > > >
> > > >Does this sound fermular to anyone?
> > > >
> > > >If no one has seen this problem don't worry. I going to restart my
> > > >investigation into the bug so will be able to proved a much better
> > > >description shortly.
> > >
> > > before you start .. you should be aware that HTML::Parse is deprecated
> > > .. you should be using HTML::Parser
>
> --
> Gisle Aas

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mr. T. P. Cockle M.Sc. B.Sc. (hons) Pg.D.                 Ph.D. Representative

Research (Distributed Computer Systems)
School of Computing,
Staffordshire University,
Stafford ST18 0DG.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




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

Date: Wed, 06 Sep 2000 18:51:42 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
To: Gisle Aas <gisle@ActiveState.com>
Subject: Re: HTML::parse bug
Message-Id: <39B6842E.B440E263@staffs.ac.uk>

Here is some test code:

use diagnostics;
use IO::Socket;
use HTML::TokeParser;
use IO::File;
use POSIX qw(:sys_wait_h);


my $i = 1;

while  ($i < 5) {

   $SIG{CHLD} = \&REAPER;
   next if $pid = fork;
   die "fork: $!" unless defined $pid;

   &DO_STUFF($i);

   exit();

} continue {

   $i++;

}


sub DO_STUFF {

   my $num = shift;
   my %found;
   my $token;
   my $fileName = "menu$num.html";

   open($FILE, $fileName) || die "Couldn't open $fileName\n";



   my $p = HTML::TokeParser->new($FILE);


   while ($token = $p->get_tag("a")) {

      my $url = $token->[3] || "";

      if ( (exists $token->[1]{href}) and ($token->[1]{href} !~ /^mailto/i)) {
         if ( 1 ) {
            $text = "\<img border=\"0\"
src=\"http://www.soc.staffs.ac.uk/~cmrtc/tick.gif\"\>";
            $text .= $url;
            unless (exists ($found{$url}) ) {$found{$url} = $text;};
         }
      }
   }

   close($FILE) || die "I can't close $fileName";
   print "done $fileName\n";
}



sub REAPER {
    1 until (-1 == waitpid (-1, WNOHANG) );
    $SIG{CHLD} = \&REAPER;
}

I use NT by the way so this may be a platform dependence issue.

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

Copyright 1987-2000, Larry Wall

Binary build 613 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 12:36:25 Mar 24 2000

Hope you can help!

Tim

Gisle Aas wrote:

> Tim Cockle <T.Cockle@staffs.ac.uk> writes:
>
> > I don't use it directly there is a reference from HTML::TokeParser.
> >
> > But I have looked at the TokeParser (get_token) and the failure occurs in the
> > HTML::Parse code.
>
> How does it crash?  Are you able to reduce it to a little test program
> that you can share?
>
> > jason wrote:
> >
> > > Tim Cockle <T.Cockle@staffs.ac.uk> wrote ..
> > > >I have found a bug somwwhere in HTML::parse. I have written a simple
> > > >server wich works fine. However if I convert it into a forking server it
> > > >crashes out.
> > > >
> > > >Does this sound fermular to anyone?
> > > >
> > > >If no one has seen this problem don't worry. I going to restart my
> > > >investigation into the bug so will be able to proved a much better
> > > >description shortly.
> > >
> > > before you start .. you should be aware that HTML::Parse is deprecated
> > > .. you should be using HTML::Parser
>
> --
> Gisle Aas

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mr. T. P. Cockle M.Sc. B.Sc. (hons) Pg.D.                 Ph.D. Representative

Research (Distributed Computer Systems)
School of Computing,
Staffordshire University,
Stafford ST18 0DG.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




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

Date: 6 Sep 2000 17:15:37 GMT
From: nobody@contract.East.Sun.COM (Nobody)
Subject: Re: intranet using perl cgi
Message-Id: <8p5u3p$7ql$1@eastnews1.east.sun.com>

In article <39b3cc51.836450191@news.ionet.net>, Maggert <mag@ionet.net> wrote:
>On Mon, 04 Sep 2000 11:07:36 GMT, richard_dobson@my-deja.com wrote:
>
>>Please could someone give me some ideas? I have to come up with some
>>good ideas for a research companies intranet. They would like it to
>>become a vital information resource for the workers, and an invaluable
>>forum for information interchange. All I can think of really is using
>>a bulletin board or chatgroup/newsgroup kind of setup.
>>Are there any perl cgi scripts around for this, or does anyone have any
>>impressive ideas for an intranet, using perl maybe?
>>

Sure.  Implement a database of employee contact info, etc. MySQL is fine, 
unless it's a large organization.  I have built one that has pages for 
employees to reserve conference rooms, schedule vacation time, report
problems to the appropriate respondant, register for classes (with info
automatically reported to their supervisors), etc.  They can also access 
company policies, HR info and benefits, ISO procedures/documents, engineering
specs and documentation, statistics and metrics (for the bean counters :-),
and lots of other odds and ends.  Heck, they can even look up the cafeteria
menu.  But, just remember that someone has to take responsibility for entering
info and keeping it updated or else it becomes useless.  For example, I had to
build some separate web applications for the HR people to enter the employee
info and keep it up to date.  Stuff like that has to be protected, else some
wiseguy will decide that Mickey Mouse is the newest company CEO :-)  So, 
security is another concern.  The possibilities are there, you just need to
know how (or if) your audience will use this and design it appropriately.

Anita





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

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


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