[11442] in Perl-Users-Digest
Perl-Users Digest, Issue: 5042 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 3 06:07:23 1999
Date: Wed, 3 Mar 99 03:01:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 3 Mar 1999 Volume: 8 Number: 5042
Today's topics:
Newbie: Does anyone know the progID for Microsoft Word <khhuntley@capitalnet.com>
Re: Newbie: Does anyone know the progID for Microsoft (Sam Holden)
Re: next in a continue block restarts continue block, b (Ronald J Kimball)
Re: next in a continue block restarts continue block, b <zenin@bawdycaste.org>
Re: next in a continue block restarts continue block, b <bill@fccj.org>
Problems with File::Find and links <Dirk.Schumacher@depot147.dpd.de>
Re: Question about converting newlines to <br> tags <Philip.Newton@datenrevision.de>
Re: regexp <nanda_kumar@mentorg.com>
Regular Expressions <mario.schomburg@iname.com>
Re: Regular Expressions <Tony.Curtis+usenet@vcpc.univie.ac.at>
Tie::File::URL (was Re: URGENT help required!!) <dgris@moiraine.dimensional.com>
Re: Tom, where are the FAQ'lets ??? <mds-resource@mediaone.net>
Re: URGENT! Where Do You Hide The CGI Cards From The Sp (Abigail)
Re: Using Perl to resize image? (Benjamin Franz)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Mar 1999 04:29:58 GMT
From: "kris" <khhuntley@capitalnet.com>
Subject: Newbie: Does anyone know the progID for Microsoft WordPad?
Message-Id: <aV2D2.2606$8c4.13428035@news.magma.ca>
I am learning OLE automation and I would like to know what the program ID is
for Microsoft WordPad. I haven't been able to find it anywhere and I
figured this newsgroup could help.
Thanks,
Kris Hammel
------------------------------
Date: 3 Mar 1999 04:35:12 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Newbie: Does anyone know the progID for Microsoft WordPad?
Message-Id: <slrn7dpf00.bgl.sholden@pgrad.cs.usyd.edu.au>
On Wed, 03 Mar 1999 04:29:58 GMT, kris <khhuntley@capitalnet.com> wrote:
>I am learning OLE automation and I would like to know what the program ID is
>for Microsoft WordPad. I haven't been able to find it anywhere and I
>figured this newsgroup could help.
What on earth do you think this newsgroup has to do with OLE??????
What on earth do you think this newsgroup has to do with WordPad??????
Why don't you go and ask somewhere more microsofty...
In my wildest imagination I can't see how you could figure this newsgroup
could help...
--
Sam
You are bordering on ridiculous if you think you need to support your
premises. Such an argument is an infinite regression.
--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>
------------------------------
Date: Tue, 2 Mar 1999 23:18:01 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: next in a continue block restarts continue block, but...
Message-Id: <1do29ti.1auns841pxqd3eN@bay1-134.quincy.ziplink.net>
[posted and mailed]
Chris Sherman <sherman@unx.sas.com> wrote:
> If you execute a next in a continue block, it restarts the
> continue block. This seems to be the expected behavior.
>
> How do I do something like a next, but _not_ have it restart
> in the continue block since I'm already in it?
I guess I'm the only one who understands what you are asking. Allow me
to clarify for everyone else. :)
$i = 2;
while ($i--) { # loop start
print "while $i\n";
} continue { # continue start
print "continue $i\n";
}
__END__
while 1
continue 1
while 0
continue 0
Okay. Pretty clear.
$i = 2;
while ($i--) { # loop start
print "while $i\n";
next;
} continue { # continue start
print "continue $i\n";
}
__END__
while 1
continue 1
while 0
continue 0
As expected. 'next' is defined to jump to the end of the main body of
the loop, and execute the 'continue' block if there is one.
$i = 2;
while ($i--) { # loop start
print "while $i\n";
} continue { # continue start
print "next $i\n";
next;
}
__END__
while 1
continue 1
continue 1
continue 1
continue 1
.
.
.
Uh oh, an infinite loop. Note that 'next' is sort of doing the right
thing; it jumps to the end of the main body of the loop, and executes
the 'continue' block. Unfortunately, you were already in the 'continue'
block...
You want to jump from within the 'continue' block back to the beginning
of the loop. 'next' doesn't let you do that.
Ah, but you don't need to get back to the start. If you can just get to
the end of the 'continue' block, the natural iteration takes over and
you go back to the start automatically.
With that in mind:
$i = 2;
while ($i--) { # loop start
print "while $i\n";
} continue { # continue start
{
print "continue $i\n";
last;
}
}
__END__
while 1
continue 1
while 0
continue 0
Set up another block within the 'continue' block, and use 'last' to exit
that. Then you're at the end of the 'continue' block, and you go back
to the start.
Of course, you can use labels to make it clear what you're doing.
HTH!
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
perl -le 'print "Just another \u$^X hacker"'
------------------------------
Date: 03 Mar 1999 05:09:33 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: next in a continue block restarts continue block, but...
Message-Id: <920438033.634006@thrush.omix.com>
[posted & mailed]
Chris Sherman <sherman@unx.sas.com> wrote:
>snip<
: What I want to accomplish is to do a next inside a continue block that
: will go all the way back up to the top and do the while condition, and if
: true, do the while block.
FOO_BLOCK: while ($condition) {
...foo while stuff...
}
continue {
...foo continue stuff...
goto FOO_BLOCK;
}
Yes, it must be a goto as "next FOO_BLOCK" will start the
continue over, as you've noticed. :-)
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Tue, 02 Mar 1999 22:09:44 -0500
From: "Bill Jones" <bill@fccj.org>
Subject: Re: next in a continue block restarts continue block, but...
Message-Id: <36dca74b.0@usenet.fccj.cc.fl.us>
In article <36DC64DE.428B2307@mail.cor.epa.gov>, "David L. Cassell"
<cassell@mail.cor.epa.gov> wrote:
> Chris Sherman wrote:
>>
>> In <linberg-0203991236400001@ltl1.literacy.upenn.edu>
> linberg@literacy.upenn.edu (Steve Linberg) writes:
>>
>> >In article <F7z7DM.Fno@unx.sas.com>, sherman@unx.sas.com (Chris Sherman)
wrote:
>>
>> >> How do I do something like a next, but _not_ have it restart
>> >> in the continue block since I'm already in it?
>>
>> > I'm not clear what you're trying to accomplish.
>>
>> What I want to accomplish is to do a next inside a continue block
>> that will go all the way back up to the top and do the while
>> condition, and if true, do the while block.
>>
>> What it does instead is just restart the continue block _without_
>> re-evaluating the while condition.
>>
>> If I could change the definition of next slightly, I would make it
>> not automatically jump to the continue block if it is _already_ in
>> the continue block.
>
> Chris,
> I read your post twice, and I'm still not sure *exactly* what
> you want. Could you submit some code to demonstrate what you
> get, and what you want? I have a feeling that others are having
> the same problem here.
>
> [Note: the feeling comes from running the beta of Gisle's
> LWP::Psychic module I learned about today. :-) ]
PMFJI: But I believe the point is he wishes
to do a 'next' in a 'continue' block, which I
don't think can be done. See -
continue BLOCK
Actually a flow control statement rather than
a function. If there is a continue BLOCK attached
to a BLOCK (typically in a while or foreach), it is
always executed just before the conditional is about
to be evaluated again, just like the third part of a
for loop in C. Thus it can be used to increment a
loop variable, even when the loop has been continued
via the next statement (which is similar to the C
continue statement).
HTH,
-Sneex- :]
//______________________________
// Jacksonville Perl Mongers
// http://jacksonville.pm.org
// jax@jacksonville.pm.org
'Be not the first by whom the new are tried,
nor yet the last to lay the old aside...'
------------------------------
Date: Wed, 03 Mar 1999 08:46:38 +0100
From: Dirk Schumacher <Dirk.Schumacher@depot147.dpd.de>
Subject: Problems with File::Find and links
Message-Id: <36DCE8DE.8E4F9BF8@depot147.dpd.de>
Hi,
i use File:Find to read all directory into an array
It4s ok, if no links are used.
But if a directory are linked to a other Harddisk the programm didn4t
work.
Have anybody a idee ???
Thanks
Dirk
Here the sourcecode:
find(\&wanted, $verz_s);
sub wanted {
$test_pfad=$File::Find::dir;
$hit=0;
if ($start == 1){
foreach $wert (@verzeichnisse){
if ($wert eq $test_pfad){
$hit+=1;
} # if ($test_pfad...
} # foreach $wert
} # if($start == 1)
if ($hit == 0){
$verzeichnisse[$i]=$test_pfad;
$i++;
$start=1;
}
} # sub wanted
------------------------------
Date: Wed, 03 Mar 1999 11:37:07 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Question about converting newlines to <br> tags
Message-Id: <36DD10D3.A0D1748F@datenrevision.de>
Larry Rosler wrote:
>
> But I don't know why anyone really wants to remove newlines when adding
> '<br>'s. Some poor human may choose to view or download the HTML
> source, and having manageable line lengths is a great virtue. The
> browser couldn't care less, and the increase in file size is trivial.
Hear, hear! I hate pages which have endless lines in their HTML source
when I want to look at them, forcing me to scroll all over the place.
Cheers,
Philip
------------------------------
Date: Wed, 03 Mar 1999 15:49:40 +0000
From: "Nanda Kumar, Koyickal" <nanda_kumar@mentorg.com>
Subject: Re: regexp
Message-Id: <36DD5A14.6529AD10@mentorg.com>
"Mark P." wrote:
> What I have so far will return a long string of .txt.tx.tx.txt
> blah blah. So its getting rid ov everything instead of leaving the
> name of the document.
>
> $file = "$ENV{'HTTP_REFERER'}";
> $file =~ s/[http:\/\/]/\.html/ig;
> $file =~ s/.html/.txt/ig;
> $file =~ s/.shtml/.txt/ig;
> $file =~ s/.htm/.txt/ig;
> $file =~ s/.cgi/.txt/ig;
Try out this
$url="http://www.which.com/what/index.html#jump";
$url =~ s/.*?([^\/]*)#.*$/$1/;
$url =~ s/(html|htm|shtml)/txt/;
print "$url\n";
This works better as there no restriction for no. of '/'s in the path.
Cheers
Koyickal
------------------------------
Date: Wed, 03 Mar 1999 09:29:15 +0100
From: Mario Schomburg <mario.schomburg@iname.com>
Subject: Regular Expressions
Message-Id: <36DCF2DB.46FFE48B@iname.com>
Hi,
does anyone know a possibility to generate a regular expression
for a couple of strings?
I would like to provide these strings to a function which will
return a regular expression matching all these strings.
Mario Schomburg
------------------------------
Date: 03 Mar 1999 09:31:50 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Regular Expressions
Message-Id: <83u2w39dop.fsf@vcpc.univie.ac.at>
Re: Regular Expressions, Mario
<mario.schomburg@iname.com> said:
Mario> Hi, does anyone know a possibility to
Mario> generate a regular expression for a couple of
Mario> strings? I would like to provide these
Mario> strings to a function which will return a
Mario> regular expression matching all these
Mario> strings.
sub matchall { '.*'; }
Your question is rather vague, could you be a bit
more explicit about what you want? Is it a minimal
regexp to match the set of strings?
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: 03 Mar 1999 01:44:34 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Tie::File::URL (was Re: URGENT help required!!)
Message-Id: <m31zj73qtp.fsf_-_@moiraine.dimensional.com>
Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:
> That's a URL, not a file.
As far as I'm concerned, the distinction shouldn't matter
in the vast majority of cases. A `file' is simply some
resource that can be presented in a streamed format. A
URL certainly should qualify.
Unfortunately, there is no easy way to do this in perl.
I don't know of any way to override CORE::open so that it
will call my function instead. Tying filehandles solves
part of the problem, but not all.
Below is a module that handles tying filehandles to URLs. It
accepts a list of filenames that can contain both local
files and URLs. I have no idea what it would mean to write
to a URL, so I didn't implement that. The error checking and
exception handling should also be a great deal more robust. I'll
add that if I find the module useful in normal code.
This module requires LWP.
The small program that exercises the module is included first
and demonstrates the proper way to prepare the filhandles
for use.
Enjoy.
**Start tieurl**
#!/usr/local/bin/perl
#
# tieurl - testing an idea with tied filehandles
use strict;
use Tie::File::URL;
my @files = qw!http://moiraine.dimensional.com/~dgris/home.html
http://slashdot.org
/home/dgris/.bashrc!;
for (@files) {
open (F, 'nonesuch');
tie *F, 'Tie::File::URL', $_;
for (1..10) {
my $line = <F>;
print $line;
}
close F;
}
**End tieurl**
**Start Tie/File/URL.pm**
package Tie::File::URL;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
use LWP;
use LWP::UserAgent;
require Exporter;
@ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw( );
$VERSION = '0.01';
# Preloaded methods go here.
sub TIEHANDLE {
my $class = shift;
my $file = shift;
my $self = { content => undef,
offset => 0 };
if ($file =~ /^http:/) {
my $ua = LWP::UserAgent -> new();
my $req = HTTP::Request -> new (GET => $file);
my $res = $ua -> request ($req);
if ($res -> is_success()) {
$self -> {content} = $res -> content();
}
else {
warn "Couldn't open $file\n";
$self -> {content} = '';
}
}
else {
if (open (FH, $file)) {
local $/;
$self -> {content} = <FH>;
}
else {
warn "Couldn't open $file: $!";
$self -> {content} = '';
}
}
return bless $self, $class;
}
# called as read(FH, $buf, $len, $offset)
sub READ {
my $self = shift;
my $buf = \$_[0]; # modify $buf in place
$$buf = ''; # but clear it first
my (undef, $len, $offset) = @_;
$$buf = substr($self -> {content}, $offset, $len);
$self -> {offset} += length ($$buf);
return length $$buf;
}
# called by <FH>
sub READLINE {
my $self = shift;
my $offset = $self -> {offset};
$offset ||= 0;
if ( $self -> {content} =~ /.{$offset}([^\n]*\n)/s ) {
$self -> {offset} += length $1;
return $1;
}
return undef;
}
# called as getc(FH);
sub GETC {
my $self = shift;
my $offset = $self -> {offset};
my $char = substr ($self -> {content}, $offset, 1);
$offset++ if $char;
return $char;
}
sub CLOSE {
my $self = shift;
return;
}
sub DESTROY {
my $self = shift;
return;
}
# do nothing, i'm not sure what writing to a URL means
sub WRITE {
return undef;
}
sub PRINT {
return undef;
}
sub PRINTF {
return undef;
}
1;
__END__
# Below is the stub of documentation for your module. You better edit it!
=head1 NAME
Tie::File::URL - Perl extension for tying URLs to filehandles
=head1 SYNOPSIS
use Tie::File::URL;
open (FH, 'no_such_file'); # don't check the return, we want to fail
tie *FH, 'Tie::File::URL', $url
=head1 DESCRIPTION
A simple module to tie URLs to filehandles.
=head1 AUTHOR
dgris <dgris@moiraine.dimensional.com>
=head1 Copyright
Copyright 1999 Daniel Grisinger
This is free software.
It may be used, modified, or distributed under the terms of
the Artistic License (http://language.perl.com/misc/Artistic.html)
=head1 SEE ALSO
perl(1).
=cut
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Tue, 02 Mar 1999 23:15:37 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Tom, where are the FAQ'lets ???
Message-Id: <36DCC579.ACE8FBF7@mediaone.net>
How about one (1) a day? Vitamins are nutritious ;)
Jonathan Stowe wrote:
>
> On Mon, 01 Mar 1999 20:54:43 -0600 Michael D. Schleif wrote:
> > Why stop now? Simply, because some repeated?
>
> Nah, I think it was causing some peoples modems to overheat.
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: 3 Mar 1999 03:36:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: URGENT! Where Do You Hide The CGI Cards From The Spiders?
Message-Id: <7biao8$1qi$4@client2.news.psi.net>
tatabu@my-dejanews.com (tatabu@my-dejanews.com) wrote on MMIX September
MCMXCIII in <URL:news:7bhl07$god$1@nnrp1.dejanews.com>:
|| When we use a CGI script to create greeting cards for people,
|| we usually create the cards in a directory, say "cards", which can
|| be accessed by anybody. If this is the case, then the search engines
|| that spider our pages can actually suck in all the confidential
|| greeting cards that have been created. What do we do to
|| remedy this?
Get some spider eating birds.
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
------------------------------
Date: Wed, 03 Mar 1999 03:30:24 GMT
From: snowhare@devilbunnies.org (Benjamin Franz)
Subject: Re: Using Perl to resize image?
Message-Id: <k12D2.7001$8N5.72175@typhoon-sf.pbi.net>
In article <7bc3j3$dpt$1@news.onramp.net>,
John <john@terminalreality.com> wrote:
>Is there a way, using Perl or some UNIX program that I can execute through
>Perl that I could take a GIF or JPG image and make a thumbnail of it at a
>size that I specify?
>
>My system is a LINUX box running Apache and Perl 5 with MySQL and the DBI
>Perl module.
>
>If you reply to this message to the newsgroup could you please also email me
>at john@terminalreality.com
Check <URL:http://www.nihongo.org/snowhare/utilities/htmlthumbnail/> for
a script I wrote to do that and more.
--
Benjamin Franz
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5042
**************************************