[21747] in Perl-Users-Digest
Perl-Users Digest, Issue: 3951 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 10 18:10:46 2002
Date: Thu, 10 Oct 2002 15:10:16 -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 Thu, 10 Oct 2002 Volume: 10 Number: 3951
Today's topics:
POP3 Client <osoeder@gmx.de>
Re: POP3 Client <tony_curtis32@yahoo.com>
Re: regular expression to extract a string between 2 ot (Red Ogden)
Re: Strongger paragraph mode record separator (Malcolm Dew-Jones)
Re: Strongger paragraph mode record separator <skuo@mtwhitney.nsc.com>
Re: Switch.pm not threadsafe? <rgarciasuarez@free.fr>
Re: The Perl Journal needs help (David Combs)
Re: The Perl Journal needs help <comdog@panix.com>
Re: Win32::OLE with IIS metabase <asimmons@mitre.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Oct 2002 21:36:48 +0200
From: Oliver =?iso-8859-1?Q?S=F6der?= <osoeder@gmx.de>
Subject: POP3 Client
Message-Id: <3DA5D6D0.7E91816A@gmx.de>
#!/usr/bin/perl
open(POP,"telnet pop3.arcor.de 110 |");
print POP "USER username\n";
print POP "PASS password\n";
Hello,
I want to write a simple POP3 Client, you can see I am far away from my
goal.
My first question: how can I see if the program has successfull
connected to the pop host?
How can I make the current state viewable on my screen, too?
Regards
Oliver Söder
------------------------------
Date: Thu, 10 Oct 2002 14:55:39 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: POP3 Client
Message-Id: <87ofa283wk.fsf@limey.hpcc.uh.edu>
>> On Thu, 10 Oct 2002 21:36:48 +0200,
>> Oliver Söder <osoeder@gmx.de> said:
> I want to write a simple POP3 Client, you can see I am
> far away from my goal. My first question: how can I see
> if the program has successfull connected to the pop
> host? How can I make the current state viewable on my
> screen, too?
http://search.cpan.org/author/SDOWD/POP3Client-2.12/POP3Client.pm
would be a good place to start looking. If you want to
really do all the dirty work, start with Net::Cmd and
IO::Socket::INET.
hth
t
------------------------------
Date: 10 Oct 2002 14:11:46 -0700
From: redog6@hotmail.com (Red Ogden)
Subject: Re: regular expression to extract a string between 2 other strings
Message-Id: <22768f84.0210101311.6d4867aa@posting.google.com>
Thanks very much Bernard and Jay - I really appreciate your help.
Redge.
tiltonj@erols.com (Jay Tilton) wrote in message news:<3da5424d.209654540@news.erols.com>...
> redog6@hotmail.com (Red Ogden) wrote:
>
> | I want to extract a string from a file which is always surrounded by
> | the same text, eg.:
> | example.txt contains:
> | ====================================================
> | lots of text
> |
> | This is the identifier (STRING) lots of other text"
> | ====================================================
> |
> | I would like to extract STRING from example.txt. In all files like
> | example.txt STRING is always directly preceded by "This is the
> | identifier (" and directly followed by ")".
>
> Use \Q...\E to escape whatever regex metachars are in the
> leader/follower strings.
>
> #!perl
> use warnings;
> use strict;
> my $lead = 'This is the identifier (';
> my $follow = ')';
> my $rx = qr/\Q$lead\E(.+?)\Q$follow\E/;
> my $string = 'This is the identifier (STRING) lots of other text';
> print $1 if $string =~ /$rx/;
------------------------------
Date: 10 Oct 2002 11:06:45 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Strongger paragraph mode record separator
Message-Id: <3da5c1b5@news.victoria.tc.ca>
* Tong * (sun_tong_001@yahoo.com) wrote:
: * Tong * wrote:
: > How can I read texts from a filehandle in paragraph mode?
: Now, a tougher question,
: I want my script to be able to handle all those seem-to-be empty lines.
: Trying to issue $/="\n\s*\n" won't help.
: Has anybody work on this before? Thanks
This, according to one of the perl docs, is the one thing that awk does
better than perl.
You can't do this directly in perl.
One solution is to slurp and split (untested, just to explain what I mean)
{ # scope of $/
local $/=undef;
$whole_file=<FILE_HANDLE>;
}
@lines = split(/\n\s*\n/,$whole_file);
------------------------------
Date: Thu, 10 Oct 2002 12:54:57 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Strongger paragraph mode record separator
Message-Id: <Pine.GSO.4.21.0210101250060.27243-100000@mtwhitney.nsc.com>
On Thu, 10 Oct 2002, * Tong * wrote:
>
> > How can I read texts from a filehandle in paragraph mode?
>
> Now, a tougher question,
>
> I want my script to be able to handle all those seem-to-be empty lines.
> Trying to issue $/="\n\s*\n" won't help.
> ...
You might consider a line-buffer :
local $/ = "\n";
my @lines;
my $buffer;
while (<>) {
if (/\S+/ .. /^\s*$/) {
if (/^\s*$/) {
push @lines, $buffer;
$buffer = '';
} else {
$buffer .= $_;
}
}
}
push @lines, $buffer if ($buffer);
This likely uses less memory than slurping in the entire file.
--
Regards,
Steven
------------------------------
Date: 10 Oct 2002 21:36:32 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: Switch.pm not threadsafe?
Message-Id: <slrnaqbt0u.j00.rgarciasuarez@rafael.example.com>
Marc Shapiro wrote in comp.lang.perl.misc :
> I just upgraded to Perl 5.8 so that I could use threads and switch
> statements. Unfortunately, they don't seem to be compatible with each
> other. This minimal program:
>
> #!/usr/bin/perl
> use threads;
> use Switch;
> threads->new(sub{})->join;
>
> generates the error:
>
> Scalars leaked: 1
>
> Note that there isn't even a switch statement. I take this to mean
> that Switch.pm is not threadsafe. I did look at the code in
> Switch.pm, but it's way beyond me.
Not really. In my opinion, this uncovers a bug in the internals (a memory
leak -- this message is documented in perldiag, you can look it up
there.) There were other reports of memory leaks with perl 5.8 and
threads.
You should use the perlbug utility to report this behaviour.
--
If your head has exploded, you should avoid sausage factories.
-- Larry Wall in perl6-language
------------------------------
Date: Thu, 10 Oct 2002 19:42:43 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: The Perl Journal needs help
Message-Id: <ao4l7j$jjd$1@reader1.panix.com>
In article <a4ip9.8$Or2.182017@uab.ericsson.se>,
neanti <jojje@coolmail.org> wrote:
>Hello all Perl hackers,
>
>You might be interested to know about the current predicament that the Perl Journal is in.
>
>Please help saving a great publication!
>
>This is from http://use.perl.org/article.pl?sid=02/10/08/1835219:
>rochlin <http://www.nw-apts.com> writes "Looks like The Perl Journal might not make it up for air after all.
>This blurb is on their website. <http://www.tpj.com/> 'Time is running short and we need your help if The
>Perl Journal is to get another chance at being the real deal. As of a couple of minutes ago, we only have
>881 subscriptions and the deadline is fast approaching. Please subscribe now. It only costs 3 cents per
>day to get the best Perl coverage anywhere.'" They need 3,000 subscribers to move forward.
>
>JAPH,
>neanti
>
Four times a year is all.
I just looked at the June 2002 issue of SysAdmin, and
counted the pages *of text* -- ie I subtracted off
the quarter and half pages of ads -- and came up
with 12 3/4 pages of perl-material.
Four times a year is (maybe wrong) therefore 45 pages
of perl material.
The COST for that is $39.00!
Like one dollar per page.
At that rate, PP3rd would be something like $900!
And with just as much (more?) content per page.
---
OK, if you are a sysadmin of a 500 computer network,
fine, you need the rest of the magazine, so it's
worth it.
But, suppose you are using perl on M$ (no, not me,
but nor am I a sysadmin of more than ONE machine (sun)) --
for those people, the rest of the magazine is worth
ZERO dollars!
---
SUGGESTION: Put a perl journal into EVERY issue of
sysadmin, and you might get some subscriptions
coming in.
What's the market?
Ask Larry how many PP3rd he's sold, and that's the
market. HUGE, probably.
There are surely more perl users than there are
sysadmins of biggish systems (big enough to need
the magazine).
---
RSVP, please, to the newsgroup.
David Combs
PS: Just as I logged on and ran newsreader, I had
the subscription letter right in front of me,
knowing full well that wife would not let me
spend $39 on yet another magazine/journal.
Yesterday I tried to call the editorial office
of sysadmin (at 785-841-1631, the subscription
people told me when I called them to ask
why sysadmin was no longer for "free", and
they told me I was getting it because of
old unexpired perl journal subscription).
Left recording, no call back yet. I was
going to ask him/her if there was enough
material available, enough writers available,
to do 6 or 8 or (best!) 12 issues.
You get that, and you've got me!
Just make it worth while!
Thanks!
------------------------------
Date: Thu, 10 Oct 2002 15:35:13 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: The Perl Journal needs help
Message-Id: <101020021535139945%comdog@panix.com>
In article <ao4l7j$jjd$1@reader1.panix.com>, David Combs <dkcombs@panix.com> wrote:
> Four times a year is all.
The current TPJ proposes a monthly publication
> I just looked at the June 2002 issue of SysAdmin, and
> counted the pages *of text* -- ie I subtracted off
> the quarter and half pages of ads -- and came up
> with 12 3/4 pages of perl-material.
> Four times a year is (maybe wrong) therefore 45 pages
> of perl material.
that has nothing to do with the new venture though. SysAdmin in irrelevant
now because TPJ is no longer part of it. June was June, now is now. different
times with differet siutations.
> The COST for that is $39.00!
that's for a year of SysAdmin. the current TPJ proposes
$12 for 12 issues. SysAdmin in irrelevant now because
TPJ is no longer part of it.
> Like one dollar per page.
you left out all of the other pages of content in SysAdmin. please don't
scare people with this sort of FUD. SysAdmin in irrelevant now because
TPJ is no longer part of it.
> At that rate, PP3rd would be something like $900!
Programming Perl is a book---a different beast. it costs what it
costs regardless of what TPJ costs.
> And with just as much (more?) content per page.
unlikely. a magazine page usually contains more words per page
than an O'Reilly book.
> But, suppose you are using perl on M$ (no, not me,
> but nor am I a sysadmin of more than ONE machine (sun)) --
> for those people, the rest of the magazine is worth
> ZERO dollars!
value is an individual thing. someone might see a single advertisement
that leads them to a solution that saves them a lot of money. the value
to that person could be very high.
> SUGGESTION: Put a perl journal into EVERY issue of
> sysadmin, and you might get some subscriptions
> coming in.
that's not going to happen though. it isn't even going to be quarterly.
SysAdmin in irrelevant now because TPJ is no longer part of it.
> What's the market?
>
> Ask Larry how many PP3rd he's sold, and that's the
> market. HUGE, probably.
Larry hasn't sold any. O'Reilly, however, has sold some :)
and it's not the same market though. O'Reilly doesn't publish a
new Programming Perl every month (or quarter).
--
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl
<http://www.theperlreview.com>
------------------------------
Date: Thu, 10 Oct 2002 16:13:58 -0400
From: "Aaron Simmons" <asimmons@mitre.org>
Subject: Re: Win32::OLE with IIS metabase
Message-Id: <ao4n15$g22$1@newslocal.mitre.org>
Hello!
I had difficulties with this at first too. Here's a summary of working code
that adds virtual roots and changes different properties:
############################################################################
#
# I"m not sure if you need to use both of these modules, but my code does
for some unknown reason
use Win32::OLE;
use OLE;
use Sys::Hostname;
$computer = hostname();
##########
# BEGIN block of code to add virtual roots
##########
# Get Default Web Site Object
$websvc = Win32::OLE->GetObject("IIS://$computer/W3svc/1") || die "Could not
create web service object: $!";
# Get root of Default Web Site
$vRoot = $websvc->GetObject("IIsWebVirtualDir", "Root") || die "Could not
create root of Default Web Site object: $!";
# Define %vroots as such:
%vroots = (
'vroot1' => {READ => 1,EXECUTE => 1, PATH => 'Web'},
'vroot2' => {READ => 0,EXECUTE => 1, PATH => 'Webbin'},
);
foreach $root (sort keys %vroots) {
# Delete it in case it is already there!
$vDir = $vRoot->Delete("IIsWebVirtualDir", $root);
$vDir = $vRoot->Create("IIsWebVirtualDir", $root) || next;
# Assign parameters
$vDir->{Path}="$basedir\\$vroots{$root}->{PATH}";
$vDir->{AccessRead}=$vroots{$root}->{READ};
$vDir->{AccessExecute}=$vroots{$root}->{EXECUTE};
$vDir->SetInfo;
}
##########
# END block of code to add virtual roots
##########
##########
# BEGIN block of code to change various properties
##########
$w3svc = Win32::OLE->GetObject("IIS://$computer/W3svc")|| die "Could not get
object: $!";
$w3svc->{AnonymousPasswordSync} = 0;
$w3svc->{AnonymousUserName} = $AnonymousUser;
$w3svc->{AnonymousUserPass} = $AnonymousPass;
$w3svc->{CGITimeout} = 86400;
$w3svc->{CreateProcessAsUser} = 1;
$w3svc->SetInfo;
$w3svc = Win32::OLE->GetObject("IIS://$computer/W3svc/1")|| die "Could not
get object: $!";
$w3svc->{CGITimeout} = 86400;
$w3svc->SetInfo;
##########
# END block of code to change properties
##########
# Some items in the metabase are more complex then simple scalars like the
above
##########
# BEGIN block of code to change mimemap--please excuse the
"not-as-elegant-as-it-could-be" code
##########
$mimemap = Win32::OLE->GetObject("IIS://$computer/MimeMap") || die "Could
not create mimemap object: $!";;
$amimemap = $mimemap->GetEx("MimeMap") || die "Could not retrieve mappings:
$!";
$alreadyThere = 0;
# Add an entry in the mime map for PNG
for ($i=0; $i<@{$amimemap}; $i++) {
($alreadyThere = 1, last) if (lc($amimemap->[$i]->{Extension}) eq
'.png');
}
if (!$alreadyThere) {
$newmimemap = CreateObject OLE "MimeMap" || die "Could not do this: $!";
$newmimemap->{Extension} = '.png';
$newmimemap->{MimeType} = 'image/png';
push @{$amimemap}, $newmimemap;
# must use PutEx Method to set the value
$mimemap->PutEx(2, "MimeMap", $amimemap);
$mimemap->SetInfo;
}
##########
# END block of code to change mimemap
##########
############################################################################
#
Good luck!
-------------
Aaron Simmons
G066-Software Systems Eng, Lead
(703) 883-3394
AaronSimm1 (AIM)
"add" <add@nrcan.gc.ca> wrote in message
news:3DA442FE.76E091A1@nrcan.gc.ca...
> Hi everyone,
>
> from CPAN documentation, I read you can use Win32::OLE to control many
> Win32 applications from Perl scripts, and I read on the Microsoft site
> that it's possible to see data in the IIS metabase with the same method.
>
> Here's the code:
>
> #######################
> use Win32;
> use Win32::OLE;
>
> $vdirObj=Win32::OLE->GetObject("IIS://LocalHost/W3SVC/3/Root") or die
> "can't open metabase\n";
>
> print "Content-type: text/html\n\n";
> print $vdirObj->("Path");
>
> exit;
> #######################
>
> For an unknown reason, it's not working. There is effectively a "Path"
> property in IIS://LocalHost/W3SVC/3/Root (in the metabase), but the
> script dies because it can't open the metabase.
>
> Please note I also tried IIS:\\\\LocalHost\\W3SVC\\3\\Root with the same
> result...
>
> Someone knows something about that method?
>
> Thanks!
>
> Christian
>
------------------------------
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 3951
***************************************