[29237] in Perl-Users-Digest
Perl-Users Digest, Issue: 481 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 4 06:10:18 2007
Date: Mon, 4 Jun 2007 03:09:05 -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 Mon, 4 Jun 2007 Volume: 11 Number: 481
Today's topics:
Re: Deleting files <ts@dionic.net>
Re: Multiple Line Pattern Match problem <samuelzhng@gmail.com>
new CPAN modules on Mon Jun 4 2007 (Randal Schwartz)
Re: perl hash - data processing <rvtol+news@isolution.nl>
Re: perl hash - data processing <srigowrisn@hotmail.com>
Re: perl hash - data processing <joe@inwap.com>
Re: Processing a Computer List <veatchla@yahoo.com>
Re: Processing a Computer List <shmh@bigpond.net.au>
Simple commandline tool to aid reading the posts of thi <sumonsmailbox@gmail.com>
Re: Simple commandline tool to aid reading the posts of <sumonsmailbox@gmail.com>
Spawning other processes but continue script <shmh@bigpond.net.au>
Re: urgent:reading 2 files into 2 different $ variables <rvtol+news@isolution.nl>
Using foreach?? maybe.. <shmh@bigpond.net.au>
Re: Using foreach?? maybe.. <see.sig@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 03 Jun 2007 09:09:43 +0100
From: Tim S <ts@dionic.net>
Subject: Re: Deleting files
Message-Id: <46627747$0$648$5a6aecb4@news.aaisp.net.uk>
Bart Lateur wrote:
> Anders F wrote:
>
>>Is there a Perl subroutine for deleting files?
>
> There's a builtin. It's called "unlink".
>
> http://perldoc.perl.org/functions/unlink.html
>
> The reason for the odd name is because on Unix, there's no garantee that
> if you succesfully apply this function on a file, that it will indeed be
> deleted. There' something called a "hard link", so there can be multiple
> directory entries, possibly in more than one directory, for the same
> file. "unlink" will remove one such directory entry (called a "link").
>
> Only when all links are gone, will the file contents indeed be deleted.
And indeed, when the final handle to the file is closed:
eg:
open F, ">Somefile";
unlink "Somefile";
print F "Wibble\n"; # File data exists, but there is no way to re-open
# it as the directory entry has gone. However, F may be cloned or passed to
# a sub process via fork().
close F; # Now the file goes away
Cheers
Tim
------------------------------
Date: Mon, 04 Jun 2007 02:12:53 -0000
From: samuel <samuelzhng@gmail.com>
Subject: Re: Multiple Line Pattern Match problem
Message-Id: <1180923173.800754.263740@n15g2000prd.googlegroups.com>
On 6 2 , 12 27 , Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <1180675413.674067.327...@r19g2000prf.googlegroups.com>,
>
> samuel <samuelz...@gmail.com> wrote:
>
> > I want to print out all the contents(the lines with or w/o dma) of the
> > blocks containing the keyword dma. But for the blocks not including
> > dma at all, not print out.
>
> > So this is the distinction.
>
> Your requirements keep changing. Please read the guidelines for this
> newsgroup. It is time you wrote a short, complete Perl program that
> attempts to do what you want. It probably shouldn't be a one-liner.
> Include some test data (see the guidelines on how to use the <DATA>
> file handle for including test data in your program.) People should be
> able to cut-and-paste your program and run it on their own systems. If
> you do that, someone will surely help you.
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
Jim,
Thanks for the reminding.
I will read the guideline carefully next time before posting.
Brad/Aukjan/Skye,
Thanks for the help.
Samuel
------------------------------
Date: Mon, 4 Jun 2007 04:42:19 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jun 4 2007
Message-Id: <JJ3H2J.10vq@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Apache2-ASP-0.16
http://search.cpan.org/~johnd/Apache2-ASP-0.16/
ASP for a mod_perl2 environment.
----
Bundle-AI-0.01
http://search.cpan.org/~ski/Bundle-AI-0.01/
Perl extension to install AI modules and dependencies
----
CGI-Application-Plugin-RequireSSL-0.03
http://search.cpan.org/~dhorne/CGI-Application-Plugin-RequireSSL-0.03/
Force SSL in specified pages or modules
----
Catalyst-View-Email-0.01
http://search.cpan.org/~jshirley/Catalyst-View-Email-0.01/
Send Email from Catalyst
----
DBIx-Web-0.68
http://search.cpan.org/~makarow/DBIx-Web-0.68/
Active Web Database Layer
----
HTML-Tiny-0.7
http://search.cpan.org/~andya/HTML-Tiny-0.7/
Lightweight, dependency free HTML/XML generation
----
HTML-Tiny-0.8
http://search.cpan.org/~andya/HTML-Tiny-0.8/
Lightweight, dependency free HTML/XML generation
----
IO-Socket-SSL-1.06_1
http://search.cpan.org/~sullr/IO-Socket-SSL-1.06_1/
Nearly transparent SSL encapsulation for IO::Socket::INET.
----
Integer-Partition-0.02
http://search.cpan.org/~dland/Integer-Partition-0.02/
Generate all integer partitions of an integer
----
JSON-DWIW-0.13
http://search.cpan.org/~dowens/JSON-DWIW-0.13/
JSON converter that Does What I Want
----
Markaya-0.0.2
http://search.cpan.org/~gugod/Markaya-0.0.2/
Markup As YAML
----
Module-List-Pluggable-0.06
http://search.cpan.org/~doom/Module-List-Pluggable-0.06/
list or require sub-sets of modules
----
Object-Exercise-1.05
http://search.cpan.org/~lembark/Object-Exercise-1.05/
Generic execution & benchmark harness for method calls.
----
Perl-Critic-1.053
http://search.cpan.org/~thaljef/Perl-Critic-1.053/
Critique Perl source code for best-practices
----
Sepia-0.90_01
http://search.cpan.org/~seano/Sepia-0.90_01/
Simple Emacs-Perl Interface
----
TAP-Convert-TET-v0.1
http://search.cpan.org/~andya/TAP-Convert-TET-v0.1/
Convert TAP to TET
----
TAP-Convert-TET-v0.2
http://search.cpan.org/~andya/TAP-Convert-TET-v0.2/
Convert TAP to TET
----
Task-Perl-Critic-1.000
http://search.cpan.org/~elliotjs/Task-Perl-Critic-1.000/
Install everything Perl::Critic.
----
Text-CSV_XS-0.28
http://search.cpan.org/~hmbrand/Text-CSV_XS-0.28/
comma-separated values manipulation routines
----
Tree-Suffix-0.15
http://search.cpan.org/~gray/Tree-Suffix-0.15/
Perl interface to the libstree library.
----
WWW-Facebook-API-v0.3.0
http://search.cpan.org/~unobe/WWW-Facebook-API-v0.3.0/
Facebook API implementation
----
WWW-Facebook-API-v0.3.1
http://search.cpan.org/~unobe/WWW-Facebook-API-v0.3.1/
Facebook API implementation
----
WWW-Mixi-Scraper-0.01
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.01/
yet another mixi scraper
----
WWW-Search-2.494
http://search.cpan.org/~mthurn/WWW-Search-2.494/
Virtual base class for WWW searches
----
WebService-CIA-1.2
http://search.cpan.org/~imalpass/WebService-CIA-1.2/
Get information from the CIA World Factbook.
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 3 Jun 2007 14:52:45 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: perl hash - data processing
Message-Id: <f3ukne.c8.1@news.isolution.nl>
Paul Lalli schreef:
> On Jun 2, 8:09 pm, shree <srigowr...@hotmail.com> wrote:
>> I have a data set that looks like this. It basically shows members
>> added to an organization on a monthly basis.
>>
>> 2007-01|member1
>> 2007-01|member2
>> 2007-01|member3
>> 2007-02|member4
>> 2007-03|member5
>> 2007-03|member6
>>
>> I wrote the following script to get monthly counts.
>>
>> #!/usr/bin/perl
>> my %hash;
>> my $File_In = "Members.txt";
>> open (DATA, $File_In) or die "Cannot open File_In $!";
>> while( <DATA> ){
>> my($yyyy_mm, $member_name) = split /\|/;
>> $hash{$yyyy_mm}++;}
>>
>> print "yyyy-mm|members added\n";
>> foreach (sort keys %hash) {
>> print "$_|$hash{$_}\n";
>>
>> }
>>
>> yyyy-mm|members added
>> 2007-01|3
>> 2007-02|1
>> 2007-03|2
>>
>> Now I'm asked to add 2 more fields in the output. One is running
>> cumulative total and another is percentage increase over the
>> preceeding month. I'm not sure how to this and would appreciate any
>> tips. I have listed a mockup of the results - done in Excel for
>> illustration.
>>
>> yyyy-mm|members added|cumulative total|% increase over last month
>> 2007-01|3|3|-
>> 2007-02|1|4|33.33%
>> 2007-03|2|6|50.00%
Please be more efficient on the quoting next time.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 03 Jun 2007 19:27:46 -0700
From: shree <srigowrisn@hotmail.com>
Subject: Re: perl hash - data processing
Message-Id: <1180924066.901867.80910@k79g2000hse.googlegroups.com>
On Jun 3, 7:52 am, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
> Paul Lalli schreef:
>
>
>
>
>
> > On Jun 2, 8:09 pm, shree <srigowr...@hotmail.com> wrote:
> >> I have a data set that looks like this. It basically shows members
> >> added to an organization on a monthly basis.
>
> >> 2007-01|member1
> >> 2007-01|member2
> >> 2007-01|member3
> >> 2007-02|member4
> >> 2007-03|member5
> >> 2007-03|member6
>
> >> I wrote the following script to get monthly counts.
>
> >> #!/usr/bin/perl
> >> my %hash;
> >> my $File_In = "Members.txt";
> >> open (DATA, $File_In) or die "Cannot open File_In $!";
> >> while( <DATA> ){
> >> my($yyyy_mm, $member_name) = split /\|/;
> >> $hash{$yyyy_mm}++;}
>
> >> print "yyyy-mm|members added\n";
> >> foreach (sort keys %hash) {
> >> print "$_|$hash{$_}\n";
>
> >> }
>
> >> yyyy-mm|members added
> >> 2007-01|3
> >> 2007-02|1
> >> 2007-03|2
>
> >> Now I'm asked to add 2 more fields in the output. One is running
> >> cumulative total and another is percentage increase over the
> >> preceeding month. I'm not sure how to this and would appreciate any
> >> tips. I have listed a mockup of the results - done in Excel for
> >> illustration.
>
> >> yyyy-mm|members added|cumulative total|% increase over last month
> >> 2007-01|3|3|-
> >> 2007-02|1|4|33.33%
> >> 2007-03|2|6|50.00%
>
> Please be more efficient on the quoting next time.
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."- Hide quoted text -
>
> - Show quoted text -
Hello Dr.Ruud,
Can you show how to quote for future?
Thanks,
Shree
------------------------------
Date: Sun, 03 Jun 2007 21:55:02 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: perl hash - data processing
Message-Id: <zuudncFJ25m3Bv7bnZ2dnUVZ_sTinZ2d@comcast.com>
shree wrote:
> On Jun 3, 7:52 am, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
> Hello Dr.Ruud,
>
> Can you show how to quote for future?
>
> Thanks,
> Shree
Darn it, Shree, did you _HAVE_ to quote all 49 lines verbatim to
ask that question? Sheesh! You're supposed to delete lines until
only the relevant parts are left. Like I have just done.
It's just common sense.
-Joe
------------------------------
Date: Sun, 03 Jun 2007 09:50:00 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: Processing a Computer List
Message-Id: <1365l8n1e1cre22@news.supernews.com>
Bob Walton wrote:
> SimonH wrote:
>> Hi Len!
>>
>> Thanks for this...but Im really looking at a perl solution for this.
>> Thanks very much to you anyway. Appreciate it.
>
> Well then [untested]:
>
> perl -e "print `srvinfo.exe`"
>
> ...
>>> C:\>srvinfo.exe
>
That was my first thought and what I do when there is an existing tool
which gives me exactly what I want.
Simon - you may want to look at Win32::Process::Info.
--
Len
------------------------------
Date: Sun, 03 Jun 2007 15:45:39 GMT
From: "SimonH" <shmh@bigpond.net.au>
Subject: Re: Processing a Computer List
Message-Id: <DmB8i.8359$wH4.344@news-server.bigpond.net.au>
Thanks Bob....really appreciate it.
"l v" <veatchla@yahoo.com> wrote in message
news:1365l8n1e1cre22@news.supernews.com...
> Bob Walton wrote:
>> SimonH wrote:
>>> Hi Len!
>>>
>>> Thanks for this...but Im really looking at a perl solution for this.
>>> Thanks very much to you anyway. Appreciate it.
>>
>> Well then [untested]:
>>
>> perl -e "print `srvinfo.exe`"
>>
>> ...
>>>> C:\>srvinfo.exe
>>
>
> That was my first thought and what I do when there is an existing tool
> which gives me exactly what I want.
>
> Simon - you may want to look at Win32::Process::Info.
>
> --
>
> Len
------------------------------
Date: Sun, 03 Jun 2007 08:36:19 -0700
From: skywriter14 <sumonsmailbox@gmail.com>
Subject: Simple commandline tool to aid reading the posts of this or any group
Message-Id: <1180884979.261821.188310@w5g2000hsg.googlegroups.com>
This is a little commandline tool I wrote to help myself read the
posts in this group. It fetches the thread urls with the latest posts
and opens them in firefox. I use this from cygwin command prompt in my
windows machine. I hope someone else will be interested enough to
enhance it.
Why did I create it: I use a feed reader too to read the posts of the
groups i subscribed from google groups. I click on the the links on
summary/description of each post in my reader. Then I reach the page
with only one post, then I click on another link to reach to the
thread. I find do that fewtimes everyday really painful.
example useage:
browse.pl
browse.pl perl.beginners
browse.pl comp.unix.shell
(comp.lang.perl.misc is the default group)
------------------------------------------------------------------
#!/usr/bin/perl
#browse.pl
use strict;
use warnings;
use WWW::Mechanize;
my $browser_path = '/cygdrive/c/Program\ Files/Mozilla\ Firefox/
firefox.exe ';
my $group_name = 'comp.lang.perl.misc'; # default group. it will be
used if you don't provide one as parameter
$group_name = $ARGV[0] if @ARGV; # user specified group, from
commandline parameter
my $url = 'http://groups.google.com/group/'.$group_name.'/topics?
gvc=2';
my $limit = 10; # limit number of posts to open
print "Group: [$group_name]\n";
my $m = WWW::Mechanize->new();
print "Getting $limit links of threads...\n";
$m->get($url);
my $html = $m->content();
#print $html;
my @links = ($html =~ m{<td><a href="(/group/$group_name/browse_thread/
thread/[^/]+/[^/]+)#[^/]+">}igs);
if (@links) {
@links = map {'http://groups.google.com' . $_} @links;
my @links_limited = splice @links, 0, $limit;
my $url_string = sprintf (qq/"%s"/, join q/" "/, @links_limited);
#print $url_string."\n";
print "Opening browser...\n";
system ($browser_path . $url_string . ' &');
}else{
print "oooops! could not load main page\n";
}
exit 0;
------------------------------
So, anyone interested to enhance it?
Regards,
Sumon
------------------------------
Date: Sun, 03 Jun 2007 08:39:02 -0700
From: skywriter14 <sumonsmailbox@gmail.com>
Subject: Re: Simple commandline tool to aid reading the posts of this or any group
Message-Id: <1180885142.490528.178640@g4g2000hsf.googlegroups.com>
Group,
Sorry for the typos. :-s
Regards,
Sumon
------------------------------
Date: Mon, 04 Jun 2007 09:54:10 GMT
From: "SimonH" <shmh@bigpond.net.au>
Subject: Spawning other processes but continue script
Message-Id: <6jR8i.8639$wH4.943@news-server.bigpond.net.au>
Hi guys!
I have the following script which opens a machine.txt file, with format:
machine1
machine2
machine3
etc
====================================================
#!perl
open (INPUT,"machine.txt") or die "cant open machine.txt";
@computers = <INPUT>;
while (<INPUT>) {
chomp;
push @computers, $_;
}
foreach $a (@computers) {
if ($a eq "dell101\n") {
print "hi there simon\n";
print `notepad`;
}
else {
print "you are not my machine\n";
}
#print $a;
#
}
====================================================
What id like help with is the following....
If I comment out the line..
print `notepad`;
Execution proceeds as expected.
When I leave this in, it opens notepad, while the command prompt waits.
Is there any way to spawn other processes, but continue execution of your
original script?
Thanks guys.
Simon
------------------------------
Date: Sun, 3 Jun 2007 15:04:28 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: urgent:reading 2 files into 2 different $ variables
Message-Id: <f3ulac.1h4.1@news.isolution.nl>
geot schreef:
> i have intermediate knowledge in perl pls help me its urgent.
The "urgent" will most likely get you the opposite of what you aim for.
Read `perldoc -f index`.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 03 Jun 2007 16:30:32 GMT
From: "SimonH" <shmh@bigpond.net.au>
Subject: Using foreach?? maybe..
Message-Id: <I0C8i.8363$wH4.4725@news-server.bigpond.net.au>
Hi!
Im trying to change the following Ive worked on into using a list of
machines in a file called machine.txt
At the moment, Ive used an array of computer names im testing on. This
works, but Id like some direction on how to reference a file instead of
using an array. Any help greatly appreciated. Thank you.
I believe I might have to use a foreach statement and possibly a split
function on the machine.txt file, but not sure where to start with this.
The format of the machine.txt file is:
dell101
dell102
dell103
etc
#use diagnostics;
#use strict;
use Win32::OLE('in');
# Use the Win32_Process
my @requests = ('Win32_Process', );
# Computer list
my @computers = qw/dell101 dell102 dell103/; # having trouble
here....instead of listing, id like to reference a file called machine.txt
# Connect to each systems CimV2 repository in turn.
for my $computer( @computers ){
my $wmi_repos =
Win32::OLE->GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\$computer\\root\\CIMV2")
or die "WMI connection failed: ".Win32::OLE->LastError()."\n";
for my $request( @requests ){
my $wmi_collection = $wmi_repos->ExecQuery("SELECT * FROM $request", "WQL",
48 )
or die "WQL query failed: ".Win32::OLE->LastError()."\n";
for my $item (in $wmi_collection){
my @methods = join (", ", map {$_->{Name}}( in $item->{Methods_} ) );
my %properties = map { $_->{Name} => $_->{Value} }( in
$item->{Properties_} );
# Print results
print "\n$computer :: $request :: $properties{Name}\n", "\tMethods:
@methods\n\tProperties:\n";
for my $property( sort keys %properties ){
( $properties{$property} )
? print "\t\t$property = $properties{$property}\n"
: print "\t\t$property =\n";
} } } }
##################################################
------------------------------
Date: Sun, 03 Jun 2007 14:10:07 -0400
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: Using foreach?? maybe..
Message-Id: <466303ff$0$9900$4c368faf@roadrunner.com>
SimonH wrote:
...
> Im trying to change the following Ive worked on into using a list of
> machines in a file called machine.txt
> At the moment, Ive used an array of computer names im testing on. This
> works, but Id like some direction on how to reference a file instead of
> using an array. Any help greatly appreciated. Thank you.
> I believe I might have to use a foreach statement and possibly a split
> function on the machine.txt file, but not sure where to start with this.
>
> The format of the machine.txt file is:
>
> dell101
> dell102
> dell103
> etc
>
Try something like:
use warnings;
use strict;
my $fh;
my @computers;
open $fh,"<","machine.txt"
or die "Oops, couldn't open machine.txt for input, $!";
while(<$fh>){
chomp;
push @computers,$_;
}
close($fh);
#...
...
> # Computer list
> my @computers = qw/dell101 dell102 dell103/; # having trouble
> here....instead of listing, id like to reference a file called machine.txt
...
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 481
**************************************