[22961] in Perl-Users-Digest
Perl-Users Digest, Issue: 5181 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 5 00:06:09 2003
Date: Fri, 4 Jul 2003 21:05:08 -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 Fri, 4 Jul 2003 Volume: 10 Number: 5181
Today's topics:
Re: [Q] all installed modules (Joe Smith)
Re: Alternative to use vars (Tad McClellan)
Re: Alternative to use vars <mgjv@tradingpost.com.au>
Re: Call parent method indirectly <grazz@pobox.com>
Re: Delete trailing garbage chars from a set of files? <Patrick_member@newsguy.com>
Re: Delete trailing garbage chars from a set of files? <Patrick_member@newsguy.com>
Re: Delete trailing garbage chars from a set of files? (Tad McClellan)
Re: Delete trailing garbage chars from a set of files? (Tad McClellan)
Re: detecting links (Joe Smith)
Re: From floating point to fraction (Mark Jason Dominus)
Re: Getting the size of files from a list? (Joe Smith)
Re: HTTP Headers (Joe Smith)
Open URL from email message <levalt@rogers.com>
Re: Open URL from email message <spam@thecouch.homeip.net>
Re: Open URL from email message <levalt@rogers.com>
Re: Open URL from email message <grazz@pobox.com>
Re: Open URL from email message <levalt@rogers.com>
Re: Pre-forking SOAP servers <julian@avbrief.com>
Re: Regexp constructed from command line arguments. (Tad McClellan)
Re: renaming badly named files... <tim@vegeta.ath.cx>
Re: renaming badly named files... <tim@vegeta.ath.cx>
Re: STDIO problem <REMOVEsdnCAPS@comcast.net>
TAP pager <roach@kronic.net>
Re: using pipe & perl's ARGV filehandle ? (Joe Smith)
Re: Win32 hidden Perl program <noemail@replytogroup.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 05 Jul 2003 03:39:06 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: [Q] all installed modules
Message-Id: <uLrNa.221$603.12107@iad-read.news.verio.net>
In article <zMLMa.1063$7y2.23763@tornado.fastwebnet.it>,
Mattia <mattia.c@libero.it> wrote:
>Does anyone know how to get a list of all intelled modules that are
>available to be USEd?
>I work with a provider and would like to know this info.
A properly installed perl setup will allow you to run
cpan -a
from the command line. For all the modules currently installed,
it will list the version of what is currently installed and the
version of what is available at the CPAN archives.
If that does not work, you could do this:
perl -e '@a = grep /perl/,@INC; system "ls -lR @a"'
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Fri, 4 Jul 2003 17:34:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Alternative to use vars
Message-Id: <slrnbgc081.54g.tadmc@magna.augustmail.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> perl -Mstrict -wlne 'our $c++ if /\bfoo$/; END{print $c}' file
>
> However, while the "less typing" issue has been discussed here,
> another aspect has not been touched yet: the psychological/aesthetical
> one.
Warnings and strictures are basically just good Software Engineering.
Good SE hardly makes sense for a one-line program.
Precious few programmers use them on one-liners, the payback is not there.
> Of course when
> it comes to software maintenance, as mentioned by another poster, it's
> another matter!
Maintenance schmaintenance when it comes to dirty ol' one-liners,
they disappear as soon was you execute them, so there is no maintenance.
If you had wanted it Done Right, you would have put the code in a file!
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 5 Jul 2003 10:26:54 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Alternative to use vars
Message-Id: <slrnbgc6qe.rlm.mgjv@martien.heliotrope.home>
On Fri, 04 Jul 2003 15:01:33 +0200,
Paul van Eldijk <rev_1318@hotmail.com> wrote:
> On Fri, 04 Jul 2003 08:29:58 +0000 Bart Lateur wrote:
>
>> Martien Verbruggen wrote:
>>
>>>> You are not the only one trying to grasp that. The concept of lexically
>>>> scoped global (that is, dynamic) variables truely escapes me. The only
>>>> advantage I see is that you can introduce new global variables
>>>> everywhere easily like so:
>>>
>>>You can limit (with our) where that global variable is accessible:
>>
>> The part that makes no sense to me, is how use of these var now crosses
>> package boundaries...
>>
>> $Bar::x = 123;
>> package Foo;
>> our $x = "abc";
>> package Bar;
>> print $x;
[note that this is strict-safe]
>> Guess what that'll print?
It'll print whatever is in the second $x, because that's where the scope
of that $x extends to. While this is also an effect of C<our>, I don't
like this bit of it. I (very rarely) use our to control the scope of a
global in the other direction, but I've never used it to extend the
scope like this.
> However, if you change it to
> $Bar::x = 123;
> package Foo;
> use vars qw($x);
> $x = "abc";
> package Bar;
> print $x;
[note that this is not strict-safe]
> you get the expected result. I guess I´m confued too....
This is what the difference between C<our> and C<use vars> is. C<our>
works on lexical scopes, and C<use vars> works on package scope.
C<our> and C<use vars> do not work in the same way. However, for almost
all of the cases of C<use vars> I have ever seen [1], C<our> can be used
instead. In fact, I don't think that there is any strict-safe historical
code, where C<use vars> cannot be simply replaced with C<our>. I can
think of many non-strict safe examples, like the above, but that's
unlikely to ever occur in real code, since C<use vars> wouldn't have
been needed without C<use strict 'vars'>.
So, unless someone can come up with an example with C<use strict> and
C<use vars>, that behaves differently when C<use vars> is replaced with
C<our>, I'd say that C<our> does a good job at replacing C<use vars>, as
it was used, and adds some new scoping rules, that shouldn't present you
with any surprises in code that used to work.
The only time you'll get surprises is in the case of the above-quoted
code example, which requires strictures to not be in force in the
historical version. C<use vars> was always intended to be used with
C<use strict 'vars'> in place, because it circumvents one of the
requirements that C<use strict 'vars'> imposes.
Martien
[1] All cases in real code. The cases that I've seen where a straight
replacement does not work are all in postings to Usenet.
--
|
Martien Verbruggen | Since light travels faster than sound, isn't
| that why some people appear bright until you
| hear them speak?
------------------------------
Date: Fri, 04 Jul 2003 23:06:08 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Call parent method indirectly
Message-Id: <ALnNa.2443$19.1461@nwrdny03.gnilink.net>
Bart Lateur <bart.lateur@pandora.be> wrote:
> Steve Grazzini wrote:
> >
> > $self->can("SUPER::$method")->(@args);
>
> You forgot to pass along the object itself.
>
> $self->can("SUPER::$method")->($self, @args);
>
> I was wondering if there wasn't another way, something like
>
> $self->SUPER->can($method)
>
> but I guess not... :)
Yeah -- the first silly thing I tried was
$self->SUPER::can($method)->
:-)
--
Steve
------------------------------
Date: 4 Jul 2003 10:44:21 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <be4edl0sjc@drn.newsguy.com>
Bernard,
Haven't done perl in a while, and I did try what you suggest. I believe this
works on Unix, however *.lis (again, surprisingly) doesn't seem to work on
Windows.
pat
In article <Xns93AE61FDFDF16elhber1lidotechnet@62.89.127.66>, "Bernard says...
>
>Patrick Flaherty wrote:
>
>> Hi,
>>
>> When I copy a text file from VMS to Windows (via PATHworks) there are
>> often (depending on the length of the file) trailing garbage
>> characters. I've determined these to be byte value x1a (that it, hex
>> 1a).
>>
>> I can delete these from a single file with:
>>
>> perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis
>>
>> What happens when I copy over a whole bunch of *.lis, many of which
>> might have this problem?
>
>
>[...]
>
>
>> Doubtless I'm doing something daft here. Hope someone can help me
>> out.
>
>
>Just change:
>
>
> perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis
>
>
>into:
>
>
> perl -p0777 -i.bu -e 's/\x1a+$//g' *.lis
>
>
>--
>Cheers,
>Bernard
>--
>echo 42|perl -pe '$#="Just another Perl hacker,"'
>
------------------------------
Date: 4 Jul 2003 10:45:41 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <be4eg50srd@drn.newsguy.com>
Thanx to everyone that replied.
This is what worked for me. Like a charm. Thanx Tad.
Was I just hallucinating (I don't think so) or why does feeding *.lis to a
cmd-line invocation of perl _on Windows_ not work?
pat
In article <slrnbgb73l.4l9.tadmc@magna.augustmail.com>, tadmc@augustmail.com
says...
>
>Patrick Flaherty <Patrick_member@newsguy.com> wrote:
>
>> perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis
>>
>>What happens when I copy over a whole bunch of *.lis, many of which might have
>> this problem?
>
>
>> This doesn't work (not surprising):
>>
>> @list = glob("*.lis");
>> foreach $name (@list) {
>> s/\x1a+$//g $name;
>> }
>
>
>But this works (surprisingly!):
>
> # untested
> local $^I = '.bu'; # enable inplace editing
> local @ARGV = glob '*.lis'; # load up the filenames
> while ( <> ) {
> s/\x1a+$//g;
> print;
> }
>
>
>In-place editing works on whatever is in @ARGV. It does not care
>how the stuff got into @ARGV, it will just be expecting that they
>are all names of files to edit.
>
>
>--
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Fri, 4 Jul 2003 17:20:57 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <slrnbgbve9.54g.tadmc@magna.augustmail.com>
Patrick Flaherty <Patrick_member@newsguy.com> wrote:
> works on Unix, however *.lis (again, surprisingly) doesn't seem to work on
> Windows.
Being disappointed by Windows is not at all surprising. :-(
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 4 Jul 2003 17:23:28 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <slrnbgbvj0.54g.tadmc@magna.augustmail.com>
Patrick Flaherty <Patrick_member@newsguy.com> wrote:
> This is what worked for me. Like a charm. Thanx Tad.
You can pay me back by learning to quote your followups properly.
Please do not post in backwards-time fashion.
[ snip TOFU ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 05 Jul 2003 02:09:32 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: detecting links
Message-Id: <wrqNa.217$603.12105@iad-read.news.verio.net>
In article <be1uub$9dj$1@lore.csc.com>, <jsowers@csc.com> wrote:
>Thanks, but not quite the answer. readlink will return the name of the
>directory/file which
>the link points to. I need something equivalent to the '-d' to determine
>if an item is a directory.
>Basically, I want to avoid following the link when walking a directory
>tree.
I see that you're aware that using -d() on a symlink to a directory
returns true. Are you aware that it also returns true for the -l() test?
Simply test for symlink _before_ testing for directoryness.
if (-l $item) {
(-d _) and print "Symlink to a directory\n";
(-f _) and print "Symlink to a file\n";
(-e _) or print "Broken symlink; target does not exist\n";
} else {
(-d _) and print "Directory\n";
(-f _) and print "Plain file\n";
}
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Fri, 4 Jul 2003 18:53:33 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: From floating point to fraction
Message-Id: <be4ifd$ial$1@plover.com>
In article <be3h74$3tj$1@news.gu.se>, jon rogers <jon.rogers@tv.tu> wrote:
>I'd like to, from inside my Perl script, go from a floating point number,
>like 0.33333333333333333, to a fraction, in this case 1/3. Is that
>possible? And if so, how?
I think the simplest approach is to use 'continued fractions'. Here's
some code:
sub number_to_fraction {
my $d = shift;
my $c = Convergents->new;
sub {
return unless defined $d;
my $int = int($d);
my $frac = $d - $int;
$d = $frac ? 1/$frac : undef;
$c->input($int);
my ($num, $den) = ($c->nth(-1));
wantarray ? ($num, $den) : $num/$den;
};
}
my $X = shift || 0.3333333333333;
my $fractions = number_to_fraction($X);
for (1..7) {
my ($n, $d) = $fractions->();
print "$n / $d\n";
}
package Convergents;
sub new {
my ($class) = @_;
bless {n=>[0, 1], d=>[1, 0]} => $class;
}
sub input {
my ($self, $n) = @_;
push @{$self->{n}}, $self->{n}[-1] * $n + $self->{n}[-2];
push @{$self->{d}}, $self->{d}[-1] * $n + $self->{d}[-2];
$self;
}
sub nth {
my ($self, $n) = @_;
($self->{n}[$n], $self->{d}[$n])
}
The function 'number_to_fraction' takes a number and returns an object
which generates fractions that are close to that number. The initial
fractions are simple but inaccurate; the later ones are more accurate
but more complicated. You need to arrange your program to decide
which one it wants to use. That's a policy matter that I can't really
help with.
For your example of 0.33333333333333333, the function generates
0 / 1
1 / 3
and then stops, which I think is just what you would want.
For 3.141592654, it generates
3 / 1 = 3.000000000000
22 / 7 = 3.142857142857
333 / 106 = 3.141509433962
355 / 113 = 3.141592920354
104348 / 33215 = 3.141592653921
1148183 / 365478 = 3.141592654004
1252531 / 398693 = 3.141592653997
2400714 / 764171 = 3.141592654000
18057529 / 5747890 = 3.141592654000
38515772 / 12259951 = 3.141592654000
Which as you can see includes the famous 22/7 approximation to pi, as
well as the slightly less famous 355/113 approximation. The 355/113
approximation is very close to the corect answer, which is why the
next value out of the object (10438/33215) has such a large denominator.
In general, the object wil never generate a fraction with a larger
denominator as long as there is a more accurate fraction with a
smaller denominator. That is, it generates the simplest and most
accurate fractions possible.
Hope this helps.
This code is in the public domain; feel free to use it in your
program.
------------------------------
Date: Sat, 05 Jul 2003 02:38:20 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: Getting the size of files from a list?
Message-Id: <wSqNa.218$603.11936@iad-read.news.verio.net>
In article <a2b8188a.0307040214.3ff633c4@posting.google.com>,
Math55 <magelord@t-online.de> wrote:
>>
>> sub to_unit {
>> my $size = shift;
>>
>> if ($size > 1024 * 1024) {
>> $size = sprintf "%.1fM", $size / (1024*1024);
>> }
>> elsif ($size > 1024) {
>> $size = sprintf "%.1fk", $size / 1024;
>> }
>> $size;
>> }
>
>directory has a size near 1mb i get a size like 1020.4 for example.
>how can i make this a bit more accurate?
It's already too accurate. If you want to avoid having four digits
before the decimal point, just change the threshold. For example:
:: if ($size > 999.949 * 1024) {
That way the next number after "999.9k" will be "1.0M".
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Sat, 05 Jul 2003 03:55:57 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: HTTP Headers
Message-Id: <h%rNa.223$603.12107@iad-read.news.verio.net>
In article <970676ed.0307021651.27a2e575@posting.google.com>,
Jeff Mott <mjeff1@twcny.rr.com> wrote:
>How would an HTTP request sent with Perl return the *full* set of HTTP
>headers? In fact I'm not even interested in the content.
You have to operate the User Agent yourself.
$req = HTTP::Request->new(HEAD => $url);
$res = $ua->request($req);
print $res->headers();
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Fri, 04 Jul 2003 23:19:24 GMT
From: "Lev Altshuler" <levalt@rogers.com>
Subject: Open URL from email message
Message-Id: <0YnNa.66979$2ay.29668@news01.bloor.is.net.cable.rogers.com>
Hi,
When reading from email message using Net::POP3 (or other means),
I need my perl program to open URLs incuded into the message. In other
words, I need the program to click links in the message.
So far I have not found the solution for that either in Net::POP3 or
anywhere else.
Does anyone have an idea how to do that?
Thanks, Lev
------------------------------
Date: Fri, 04 Jul 2003 20:14:44 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Open URL from email message
Message-Id: <XLoNa.63680$0B.1038336@wagner.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Lev Altshuler wrote:
> Hi,
>
> When reading from email message using Net::POP3 (or other means),
> I need my perl program to open URLs incuded into the message. In other
> words, I need the program to click links in the message.
> So far I have not found the solution for that either in Net::POP3 or
> anywhere else.
> Does anyone have an idea how to do that?
>
> Thanks, Lev
Net::POP3 handles, obviously, the POP3 protocol. In other words, "download this chunk of text, it
should resemble something parse-able by an email client as an email message".
That's all there is to it, a chunk of text in an agreed-on format.
Anything beyond that, you have to do yourself. If you expect that chunk of message to have URLs
that you are interested in, then you need to extract these URLs. For simple text emails, you can
probably get away with using a simple regular expression to collect the URLs. For HTML-encoded
emails, you can probably use HTML::TokeParser to cleanly extract links.
Once you have the URLs (still, chunks of text) in a variable somewhere, you want to simulate a
"click". In other words, you want to launch a web browser that visits these URLs.
Fortunately, perl comes with what you need. Look into any of the LWP* family of modules. For simple
GET requests with no further interaction, LWP::Simple might be what you're looking for.
Best of luck.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/Bhh3eS99pGMif6wRAvX6AJ9SgfwHu7BoyeKvW2QXrYkr2Us7oACglhRw
CZqJOuOT4wA+yt2t866cBic=
=Vz0g
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 05 Jul 2003 01:51:12 GMT
From: "Lev Altshuler" <levalt@rogers.com>
Subject: Re: Open URL from email message
Message-Id: <kaqNa.58008$a51.46642@news02.bloor.is.net.cable.rogers.com>
Internet Explorer can be launched with the following system call:
system("start $url");
where $url is a variable where we stored URL read by Net::POP3.
But the task is to emulate a click on the link from email message. Launching
the browser is not
an issue here. I am not certain that launching the browser as I described
above will emulate
a click on the link from email message.
"Mina Naguib" <spam@thecouch.homeip.net> wrote in message
news:XLoNa.63680$0B.1038336@wagner.videotron.net...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> Lev Altshuler wrote:
> > Hi,
> >
> > When reading from email message using Net::POP3 (or other means),
> > I need my perl program to open URLs incuded into the message. In other
> > words, I need the program to click links in the message.
> > So far I have not found the solution for that either in Net::POP3 or
> > anywhere else.
> > Does anyone have an idea how to do that?
> >
> > Thanks, Lev
>
> Net::POP3 handles, obviously, the POP3 protocol. In other words,
"download this chunk of text, it
> should resemble something parse-able by an email client as an email
message".
>
> That's all there is to it, a chunk of text in an agreed-on format.
>
> Anything beyond that, you have to do yourself. If you expect that chunk
of message to have URLs
> that you are interested in, then you need to extract these URLs. For
simple text emails, you can
> probably get away with using a simple regular expression to collect the
URLs. For HTML-encoded
> emails, you can probably use HTML::TokeParser to cleanly extract links.
>
> Once you have the URLs (still, chunks of text) in a variable somewhere,
you want to simulate a
> "click". In other words, you want to launch a web browser that visits
these URLs.
>
> Fortunately, perl comes with what you need. Look into any of the LWP*
family of modules. For simple
> GET requests with no further interaction, LWP::Simple might be what you're
looking for.
>
> Best of luck.
> -----BEGIN xxx SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQE/Bhh3eS99pGMif6wRAvX6AJ9SgfwHu7BoyeKvW2QXrYkr2Us7oACglhRw
> CZqJOuOT4wA+yt2t866cBic=
> =Vz0g
> -----END PGP SIGNATURE-----
>
------------------------------
Date: Sat, 05 Jul 2003 02:10:34 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Open URL from email message
Message-Id: <usqNa.18158$U23.29@nwrdny01.gnilink.net>
Lev Altshuler <levalt@rogers.com> wrote:
[ dejeopardized, follow-ups set to clpmisc ]
> "Mina Naguib" <spam@thecouch.homeip.net> wrote:
>> Lev Altshuler wrote:
>>> I need my perl program to open URLs incuded into the message. In other
>>> words, I need the program to click links in the message.
>>
>> LWP::Simple might be what you're looking for.
>>
> Internet Explorer can be launched with the following system call:
> system("start $url");
> where $url is a variable where we stored URL read by Net::POP3.
> But the task is to emulate a click on the link from email message.
^^^^^^^^
Isn't it a little summery for homework?
> Launching the browser is not an issue here. I am not certain that
> launching the browser as I described above will emulate a click on
> the link from email message.
You can emulate a *click* on the link using return().
sub click {
my $thing = shift;
return;
}
This is approximately what mutt does when you click on anything,
and I think it's correct behavior.
HTH
--
Steve
------------------------------
Date: Sat, 05 Jul 2003 02:49:42 GMT
From: "Lev Altshuler" <levalt@rogers.com>
Subject: Re: Open URL from email message
Message-Id: <a1rNa.68326$2ay.35402@news01.bloor.is.net.cable.rogers.com>
Thank you, Steve.
Could you please explain how click() function calls $url ?
Say, $url is a variable where URL is stored.
"Steve Grazzini" <grazz@pobox.com> wrote in message
news:usqNa.18158$U23.29@nwrdny01.gnilink.net...
> Lev Altshuler <levalt@rogers.com> wrote:
>
> [ dejeopardized, follow-ups set to clpmisc ]
>
> > "Mina Naguib" <spam@thecouch.homeip.net> wrote:
> >> Lev Altshuler wrote:
> >>> I need my perl program to open URLs incuded into the message. In other
> >>> words, I need the program to click links in the message.
> >>
> >> LWP::Simple might be what you're looking for.
> >>
> > Internet Explorer can be launched with the following system call:
> > system("start $url");
> > where $url is a variable where we stored URL read by Net::POP3.
> > But the task is to emulate a click on the link from email message.
> ^^^^^^^^
>
> Isn't it a little summery for homework?
>
> > Launching the browser is not an issue here. I am not certain that
> > launching the browser as I described above will emulate a click on
> > the link from email message.
>
> You can emulate a *click* on the link using return().
>
> sub click {
> my $thing = shift;
> return;
> }
>
> This is approximately what mutt does when you click on anything,
> and I think it's correct behavior.
>
> HTH
> --
> Steve
------------------------------
Date: Fri, 4 Jul 2003 20:34:04 +0100
From: "Julian Scarfe" <julian@avbrief.com>
Subject: Re: Pre-forking SOAP servers
Message-Id: <KEkNa.2528$ju6.37727@newsfep4-glfd.server.ntli.net>
"James Lavery" <james@microsec.co.uk> wrote in message
news:b966b3b3.0307040842.6046d68@posting.google.com...
> What I need to do is implement a pre-forking server - i.e. one which
> forks of, say, 4 processes all listening on the same port.
>
> I've already got this working for our own (in-house) tcp/ip non-SOAP
> server processes (i.e. several listening on a port, and the first
> picks up a request and processes it while the others continue to
> listen), but we need to extend this so that they can handle SOAP
> requests also/instead.
>
> Any pointers would be greatly appreciated!
Have you read Lincoln Stein's "Network Programming with Perl"? Although his
examples of pre-forking servers (Chapter 15) are HTTP not SOAP, the
principles may well be easily adaptable.
Julian Scarfe
------------------------------
Date: Fri, 4 Jul 2003 17:18:36 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regexp constructed from command line arguments.
Message-Id: <slrnbgbv9s.54g.tadmc@magna.augustmail.com>
ddtl <this.is.invalid@yahoo.com> wrote:
> you
> pass it a directory name to use, regexp to search for
> 3) if ($entry[2] eq "") {next;}
I like to say that like this:
next unless length $entry[2];
'cause excessive punctuation can get in the way of reading it.
> 4) $name_before[$n] = "$entry[1]" . "$entry[0]" . "$entry[2]";
See the Perl FAQ:
What's wrong with always quoting "$vars"?
and join my anti-excessive-punctuation crusade :-)
$name_before[$n] = "$entry[1]$entry[0]$entry[2]";
or, perhaps better:
$name_before[$n] = join '', @entry[1, 0, 2];
> 5) $entry[0] =~ s/\Q$opts{'s'}\E/\Q$opts{'r'}\E/g;
^^
^^
Why did you put that there?
What were you hoping that would do for you?
Do you _want_ to insert extra backslash charcters into
the replacement string?
> 7) $n++;
You should probably be letting Perl do the indexing for you by
using push() instead of doing your own indexing into @entry.
push @entry, "$entry[1]$entry[0]$entry[2]"; # Look Ma! No $n needed!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Jul 2003 12:01:48 -0700
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: renaming badly named files...
Message-Id: <slrnbgbjnk.42f.tim@vegeta.ath.cx>
Bart Lateur graced us by uttering:
> Tim Hammerquist wrote:
>> rename.pl 's/\.MP3$/mp3/;' *.MP3
>
> That doesn't sound like an actual imporvement.... Where's the
> dot?
rename.pl 's/\.MP3$/.mp3/;' *.MP3
Oh, that was rhetorical. Silly me. It was just a typo, like
your imporvement above. ;)
Tim Hammerquist
--
You can lead a boss to a decision, but you can't make him think.
-- Simon, BOFH
------------------------------
Date: 4 Jul 2003 12:11:01 -0700
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: renaming badly named files...
Message-Id: <slrnbgbk8u.42f.tim@vegeta.ath.cx>
Naran Hirani graced us by uttering:
> Tim Hammerquist wrote:
> > You can find the rename.pl utility here:
> >
> > http://borkware.com/quickies/files/rename.pl
>
> Thanks for your suggestion. It sounds quite promising to me,
> but will it handle the following scenario:
>
> I/have a badly named sub_dir/with some more badly named files
> here.txt
>
> I.e. will it deal with sub dirs in the path as well as the
> final files under the sub dirs?
>
> Of course, I am thinking of using rename in conjunction with
> the unix find util.
rename.pl 's/\.jpeg$/.jpg/i;' `find img/ -name '*.jpg' -type f`
It works with the find(1) command. But as others have pointed
out, it's not going to be near as flexible as an actual perl
script using File::Find. Specifically, your desire to alter
badly named dirs as well as files contained therein is likely to
trip up something as simple as rename.pl, but since you
originally asked for a utility or script...
If I were you, though, I'd go read Randal's column.
Cheers,
Tim Hammerquist
--
scanf() is evil.
------------------------------
Date: Fri, 04 Jul 2003 13:28:16 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: STDIO problem
Message-Id: <Xns93AE933BDAB7Asdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
jan_buys@hotmail.com (Jan) wrote in
news:11971c2c.0307040546.700d307b@posting.google.com:
> Hi,
>
> I think my perl knowledge must have shrunk to the size of a neutron...
> *sigh*.
> I'm trying to do some STD I/O on a cmd console from within a script
> called by another script. I narrowed down the problem to the smallest
> full scripts I could. test.pl is the main script, calling test2.pl in
> which the problems with the IO exist.
>
> Code of the 2 scripts :
>
> #!c:\perl\bin\perl.exe # Activeperl 5.6.1 - win32 build 633
> # script : test.pl
>
> print `cqperl -w test2.pl`;
>
> #!c:\program files\Rational\clearquest\cqperl.exe
> # Cqperl, derived from Activeperl 5.6.0, win32
> # script : test2.pl
>
> $| = 1 ;
> print "Hello there\n" ;
> chomp($answer = <STDIN>);
> print "$answer to you too...\n";
>
>
> The problem is the STDOUT msgs only are flushed to screen once the
> input is entered...
Because the second script is executed within the first script's
backticks, its output does NOT go to STDOUT. Well, it does, but its
STDOUT is tied to a buffer in the first script, not to the console.
Setting $|=1 makes perl flush the buffer after each print, but that just
means that the output gets to the first script's buffer sooner. Nothing
gets printed until the first script's print statement, which happens
after the second script has finished executing and the user has already
entered an answer.
You might want to send the user prompts to STDERR, or find some other way
of communicating between scripts.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPwXHRmPeouIeTNHoEQIGNACg7NmQdkTy2lvZHCbLbvoR9EepglIAn3Y5
n/YnAYER/pSvSN9h8Hy6KWfH
=Z7G8
-----END PGP SIGNATURE-----
------------------------------
Date: Fri, 04 Jul 2003 22:55:01 GMT
From: "roach_01" <roach@kronic.net>
Subject: TAP pager
Message-Id: <9BnNa.20055$ic1.375614@twister.tampabay.rr.com>
Has anyone written a script that can connect and send messages via TAP?
I'm trying to write a script using device::serialport for this. I can
connect to the service; but I just cant get the right sequence down to
successfully create and send the page.
This is metrocall's service and I get as far as the "ID=", that's it. heh.
I guess i'm looking for more of the sequence to send the page, than the code
itself; but if anybody can help it would be greatly appreciated! thanks
-r
------------------------------
Date: Sat, 05 Jul 2003 03:27:34 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: using pipe & perl's ARGV filehandle ?
Message-Id: <GArNa.220$603.12107@iad-read.news.verio.net>
In article <d7dd90b0.0307031656.45dad85@posting.google.com>,
stu7 <stuseven@hotmail.com> wrote:
>Uri and Tad seemed frustrated when I asked about...
>
>> perl first.pl | perl second.pl something, something ARGV fh ?
>
> I didn't specify what first.pl or second.pl contain, BE-cause,
> according to what I was told, PERL's built-in function...
> ... the ARGV filehandle... will automatically contain the
> content and/or arguments from the first script in this kind of
> piping situation.
No, it will not. Somebody did a poor job of explaining how
the diamond operator works. The contents of @ARGV are command-line
arguments, which in some cases can be interpreted as a list of
files to be read.
> I was told, with no exception, this kind of script-to-script
> data is automatically available via the built-in ARGV function,
> sort-of like a @_
Yes, reading a line-at-a-time is automatic. But those are lines
from a file or a pipe, not variables.
> Can anybody show me an example of this working ?
perl prog1.pl file1 file2 file3 | perl prog2.pl
In this case prog1.pl reads the input a line-at-a-time using the <>
operator and prints to STDOUT. The prog2.pl program will receive
as its input all the lines that were created by prog1.pl.
If file1 has 10 lines, file2 has 10 lines, and file3 has 5, then
prog1.pl will act as if it had a single input file that was 25
lines long. Depending on what exactly prog1.pl does, prog2.pl
may see all 25 lines as its input.
But prog2.pl does NOT see any arguments from prog1's command line
and does not see any variables from prog1. It just sees a bunch
of input lines.
You could write prog1.pl in such a way that it writes the names
and values of its variables intermixed with the data. For instance:
$filename='file1'
=First line
=Second line
$count=2
$filename='file2'
=...
$count=1
Then prog2.pl could be written to recognize any line starting with
an equal sign to be data and any line starting with a dollar sign
to be a variable name and value.
> For the sake of discussion, first.pl could be:
>
> $a = 4 ; $b = 5 ; $c = ($a + $b) ;
That does not match the criteria for using <> and ARGV.
It is not reading from the input file(s) a line at a time nor
is it writing anything to the output.
> ...in second.pl, I would want to print $c... or even $a and $b...
>
> print <> ; ### ?
> print <ARGV> ; ### ?
Perl does not work that way. Pipes do not work that way.
> Sorry... I'm clueless as to how it might work... I could have
> been lied to, but this is how it was suggested.
I would not say you've been lied to; you've merely misinterpreted
what has been told to you.
> ... the ARGV filehandle... will automatically contain the
> content and/or arguments from the first script in this kind of
The special array @ARGV will contain the command-line arguments.
(These may or may not be filename arguments, depending on how
the program is written.)
The special file handle ARGV can be used to read from the file(s)
whose names are stored in @ARGV.
If @ARGV = (), then <> will read from the program's STDIN.
If @ARGV = ("filename"), then <> will read from the specified
file one line at a time until the end of the file.
If @ARGV has more than one filename, <> will automatically
switch to reading the next file upon EOF.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Fri, 04 Jul 2003 23:07:53 GMT
From: "David A" <noemail@replytogroup.com>
Subject: Re: Win32 hidden Perl program
Message-Id: <dNnNa.631$s_5.3496@news-server.bigpond.net.au>
"Andrew Harton" <andrew_harton@agilent.com> wrote in message
news:1057329618.736735@cswreg.cos.agilent.com...
> David A wrote:
> > I want to write a program in Win32 Perl (ActiveState v5.6) that will
> > run as a hidden window (or otherwise in the background on a user's
> > machine). Every 5 minutes it will perform some tasks and if certain
> > conditions are true I want it to make a non-modal pop-up or balloon
> > appear to inform the user (or perhaps fire the user's web browser
> > with a given html page on it). Then it will go back to sleep for 5
> > minutes. There shouldn't be any icons showing in the toolbar and it
> > shouldn't put any heavy load on the user's machine while 'asleep'.
> >
> > I know how to do this is Win32 C, but can't find anything on it in my
> > books or searches on how to do it in Perl.
> >
> > The two specific things are:-
> >
> > 1. How to make a perl program run as hidden process on a Win32 machine
> > 2. How to make a non-modal pop-up window appear that won't interfere
> > with the user's current task.
> >
> > Any suggestions would be appreciated.
> >
> > David A.
>
> This'll do almost what you want :
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Win32;
>
> while(1)
> {
> my $test = Win32::MsgBox("Hello World" , 1 , "Box Test");
> last if $test == 2;
> sleep 300;
> }
>
> Check the Win32 section of ActiveState's documentation for more details.
>
> To run it without a console window, you need to run it with wperl.exe,
> either
> from the Start->Run menu, or through a shortcut.
>
> The only thing is that it does pop up over whatever else you're doing.
>
> Hope that helps.
>
> Andrew
>
> --
> $s="acehJklnoPrstu ";$_="4dbce078c32ae92a6e30152a";
> split//;for(0..$#_){print substr($s,hex $_[$_],1);}
>
>
Andrew,
Using wperl.exe is brilliant. Another well-hidden facet of using ActiveState
Perl.
If I can't figure out how to create a non-modal window from Win32 Perl, I'll
probably just fire up the user's default browser with a suitable web page.
Still not ideal, but less intrusive than a MessageBox.
Many thanks. BTW, loved your signature.
Any other hints on creating a non-modal pop-up window would be appreciated.
David A.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 5181
***************************************