[29243] in Perl-Users-Digest
Perl-Users Digest, Issue: 487 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 6 09:10:00 2007
Date: Wed, 6 Jun 2007 06:09:07 -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 Wed, 6 Jun 2007 Volume: 11 Number: 487
Today's topics:
Re: /e option in the s/// command sharma__r@hotmail.com
Re: Computer List (Pls hlp!) <kevinsproule@hotmail.com>
Re: Editor <kevinsproule@hotmail.com>
Re: How to verify a usnername and password? nightcats@gmail.com
Re: How to verify a usnername and password? nightcats@gmail.com
new CPAN modules on Wed Jun 6 2007 (Randal Schwartz)
Obtain Filename and Lineno of the Function Caller <ilias@lazaridis.com>
Re: Obtain Filename and Lineno of the Function Caller <noreply@gunnar.cc>
Re: Obtain Filename and Lineno of the Function Caller <mritty@gmail.com>
Search and Replace with perl <mailursubbu@gmail.com>
Re: simple regex <jeevan.ingale@gmail.com>
Re: simple regex <mritty@gmail.com>
Re: simple regex <jeevan.ingale@gmail.com>
string matching inside file and save in a variable <nitindutt2005@gmail.com>
Re: string matching inside file and save in a variable <noreply@gunnar.cc>
Re: system call hendedav@gmail.com
Re: system call <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Jun 2007 00:43:27 -0700
From: sharma__r@hotmail.com
Subject: Re: /e option in the s/// command
Message-Id: <1181115807.447636.72740@n4g2000hsb.googlegroups.com>
On Jun 5, 3:46 pm, Paul Lalli <mri...@gmail.com> wrote:
> On Jun 5, 6:34 am, sharma...@hotmail.com wrote:
>
>
>
> > #############################
> > use strict;
> > use warnings;
>
> > my $var = "''''''''''''";
>
> > my $p_pulse = q{./\\};
> > my $n_pulse = q{'\\/};
>
> > my $knt = 1;
>
> > print $var;
> > $var =~ s/^((...){$knt}).../$1 . (($1 =~ m{'}) ? $n_pulse : $p_pulse)/
> > e; ## <---- offending line
> > print $var;
> > ##########################
>
> > when I run the above piece of perl code i get the following warnings:
> > Use of uninitialized value in concatenation (.) or string at
> > line 12.
> > And when i change the $var to "..........." it works fine.
>
> > what could be the problem here?
>
> The $1, $2, $3 <etc> variables are set after every successful pattern
> match. In your replacement, you are doing a pattern match. That
> pattern match succeedes, because the current value of $1 does indeed
> match m{'}. That successful match causes $1 to be set to undef,
> because that pattern match doesn't have any capturing parentheses. So
> it is the first $1 listed in your replacement - the one that's
> concatenated to the result of the ?: operator - that's undefined.
>
> It worked fine when you changed $var to all periods because then the
> inner pattern match was not successful and so $1 wasn't changed.
>
> You can fix this by saving off the value of $1 in your replacement, as
> follows:
>
> $var =~ s/^((...){$knt}).../my $save = $1; $save . (($save =~ m{'}) ?
> $n_pulse : $p_pulse)/e;
>
> Hope this helps,
> Paul Lalli
Thanks a lot Paul for your explanation!
Your suggested fix runs perfect.
Best regards,
-rakesh.
------------------------------
Date: Tue, 5 Jun 2007 21:19:08 -0700
From: "Kevin Sproule" <kevinsproule@hotmail.com>
Subject: Re: Computer List (Pls hlp!)
Message-Id: <5Bq9i.450069$6P2.307481@newsfe16.phx>
"SimonH" <shmh@bigpond.net.au> wrote in message
news:st88i.7674$wH4.5892@news-server.bigpond.net.au...
> Hi guys hope you can help me with a perl script.
>
> We are running multiple platforms - NT and XP.
> I have a computer list in computers.txt
> Each system has a local administrator account, let's say it is
> <computername>\administrator, with password 'password'.
>
> What I need to do is to:
> 1) Determine if the system is NT or XP
> 2) If it is NT, then connect by <computername>\administrator, with
> password
> 'password', then write a line to an output file called output.txt the
> status
> of the browser service. So the format of the output.txt would be something
> like:
> <computername>, operatingsystem, servicename, status
> 3) If it is XP, then connect by <domain1>\simon, with password 'simtest',
> then write a line to an output file called output.txt with the same 4
> columns as 2).
> 4) While the script is running, a status of 'connecting to <computername>
> would be great.
>
> Any help greatly appreciated.
>
> Simon
>
Simon,
This may get you started:
#!/perl/bin/perl.exe -w
use Win32::Service;
my ($hostName, $serviceName, %status);
my %statusCode = (1 => 'STOPPED', 2 => 'START_PENDING',
3 => 'STOP_PENDING', 4 => 'RUNNING',
5 => 'CONTINUE_PENDING',6 => 'PAUSE_PENDING',
7 => 'PAUSED', 8 => 'ERROR');
$hostName = 't23-kevin'; # server name or IP address
$serviceName = 'w3svc'; # short name of service
Win32::Service::GetStatus($hostName, $serviceName, \%status);
print $statusCode{$status{"CurrentState"}}, "\n";
Test:
C:\pl>perl webcheck.pl
STOPPED
C:\pl>net start w3svc
The World Wide Web Publishing service is starting.
The World Wide Web Publishing service was started successfully.
C:\pl>perl webcheck.pl
RUNNING
C:\pl>
Kevin Sproule
------------------------------
Date: Tue, 5 Jun 2007 21:45:28 -0700
From: "Kevin Sproule" <kevinsproule@hotmail.com>
Subject: Re: Editor
Message-Id: <SZq9i.450138$6P2.332364@newsfe16.phx>
"tyjb" <tyjbxx@yahoo.com> wrote in message
news:1181048720.607380.47180@g4g2000hsf.googlegroups.com...
> I'd like to display the contents of a file to users giving them the
> opportunity to search or scroll, but not allow them to change or
> save. I can't use the "type" command because the files are too
> large. Any suggestions?
>
> This is what I'm currently doing, but need another method.
>
> $myfile = $sortedarray[$input];
> $mypath = '\\\\tlrntfs1\\IT_Common\\output\\';
> $myprogram = '"C:\\Windows\\notepad.exe"';
> $mycommand = $myprogram.' "'.$mypath.$myfile ;
> system($mycommand);
>
If you can put the html tag <PRE> at the start of the text file and </PRE>
at the end of the file then you can start a browser to display the data. I
will leave the Perl code to you.
Kevin Sproule
------------------------------
Date: Tue, 05 Jun 2007 21:45:08 -0700
From: nightcats@gmail.com
Subject: Re: How to verify a usnername and password?
Message-Id: <1181105108.374697.233830@a26g2000pre.googlegroups.com>
On 6 6 , 11 11 , Bob Walton <see....@rochester.rr.com> wrote:
> nightc...@gmail.com wrote:
>
> ...
>
> > I hold an old version of discussion board writen in Perl.
> > Recently, a guy from China violently spams my discussion board to
> > cause it even malfunctioned.
> > My intention is to add two columns,"username"and"password". When
> > Vistior post a message, the perl script verify the combination first.
> > Only the one with the right combination can succesfully post it. And I
> > intent to get every friends of mine different set of combination.
>
> One place to start is:
>
> perldoc -f crypt
>
> which will provide the capability to store encrypted passwords so that
> if your system is compromised to the point where someone gets the
> password file, they still won't be able to determine the passwords of
> your users. You would start by defining a password for your friends and
> storing the crypt'ed version of it in a file. Then let your friends
> know the password, and arrange the software so they have to change the
> password the first time through. You should arrange a couple of simple
> checks so your friends can't use easily-cracked passwords like '' or 'a'
> or 'abcde', etc -- if their passwords are easily cracked, you are no
> better off than you were before.
>
> Depending upon your software, you may need to lock access to the
> password file so multiple instances of your program can't access it
> simultaneously, at least not when one or more instances need to write to
> it. See:
>
> perldoc -q lock
>
> Regarding the type of file to use: If you have only a few users, you
> can probably get away with a plain text file of a form such as:
>
> userID encodedpassword
>
> If you have lots of users, you should consider a DBM-type file tied to a
> Perl hash. See:
>
> perldoc DB_File
>
> (you might need to download the DB_File module first).
>
> Note that userID and password administration can be a chore -- users
> will forget their userID's and/or passwords, etc.
>
> Question: Is your discussion board web-based, or something else?
>
Yes, it's a web-based discussion board. It is an old WWWboard Board,
written by a guy Matt from Matt's Script website long tme ago. It's
so simple that I even have to add up a few advanced function myself(of
course, with a lot of help). The main struction is the main page of
board, a wwwboard.pl to process the posting, a message directory to
store posted messages, that's all.
I know it's too easy for spamers but I just love the seasiness of it.
after check out what you said, I crrently host my sebsite in a
commercial hosting company. I seem to have such write to all that you
suggest. I'll contact my hosting to see if they can do it for me.
THanks a lot.
(frankly, before you tell me this, I didn't think about the file
security.)
By the way, can you tell me how to write the Verifying Process of my
usernames and passwords?
He is again spaming now. Gosh, I hate this kind of spammer!!!
>
>
>
>
>
>
> > I roughly know that the process could be first define a password file:
> > $passwd_file = "path/to/my_password_file";
>
> > Then get the variable,
> > &check_passwd;
>
> > Then define the variable. but I just don't know how to make it happen.
> > Can anybody PLEASE help me so that I can stop this guy from paralizing
> > my discussion board. T_T
>
> > By the way, there is a short script in my Perl file to keep track of
> > every aticle:
> > $tolog = "Post $num|";
> > $tolog .= "$ENV{'REMOTE_ADDR'}|"; ### IP
> > $tolog .= "$date";
> > $tolog .= "\n";
> > open(LOG,">>$testfile");
> > print LOG $tolog;
> > close(LOG);
>
> > After I put on the password verifying process, how to also record the
> > "username" information of evrey article?
>
> Looks to me like a simple addition of:
>
> $tolog .= "$userID|";
>
> at an appropriate place should do it, assuming variable $userID hold the
> user's userID.
> --
> Bob Walton
> Email:http://bwalton.com/cgi-bin/emailbob.pl- -
>
> - -
------------------------------
Date: Tue, 05 Jun 2007 21:59:12 -0700
From: nightcats@gmail.com
Subject: Re: How to verify a usnername and password?
Message-Id: <1181105952.742501.263610@i13g2000prf.googlegroups.com>
> Depending upon your software, you may need to lock access to the
> password file so multiple instances of your program can't access it
> simultaneously, at least not when one or more instances need to write to
> it. See:
>
> perldoc -q lock
>
By the way, I'll decide the passwoard for everybody (which is about 40
of them). They just have to use the password I choose. There is no
written job for visitors. so, do I still need to do this? thanks.
(I know thess questions could look stupid..........)
------------------------------
Date: Wed, 6 Jun 2007 04:42:12 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Jun 6 2007
Message-Id: <JJ76EC.1DtA@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.
AI-NeuralNet-SOM-0.01
http://search.cpan.org/~drrho/AI-NeuralNet-SOM-0.01/
Perl extension for Kohonen Maps
----
App-Build-0.66
http://search.cpan.org/~mbarbon/App-Build-0.66/
extends Module::Build to build/install/configure entire applications (i.e. web applications), not just modules and programs
----
CORBA-Python-0.38
http://search.cpan.org/~perrad/CORBA-Python-0.38/
----
Catalyst-Plugin-Unicode-0.3
http://search.cpan.org/~mramberg/Catalyst-Plugin-Unicode-0.3/
Unicode aware Catalyst
----
Config-Hierarchical-0.07
http://search.cpan.org/~nkh/Config-Hierarchical-0.07/
Hierarchical configuration container
----
Config-Loader-1.02
http://search.cpan.org/~drtech/Config-Loader-1.02/
load a configuration directory tree containing YAML, JSON, XML, Perl, INI or Config::General files
----
Google-Checkout-1.0.6
http://search.cpan.org/~dzhuo/Google-Checkout-1.0.6/
----
HTML-StripScripts-1.00
http://search.cpan.org/~drtech/HTML-StripScripts-1.00/
Strip scripting constructs out of HTML
----
HTML-StripScripts-Parser-1.00
http://search.cpan.org/~drtech/HTML-StripScripts-Parser-1.00/
XSS filter using HTML::Parser
----
IPC-Messaging-0.01_04
http://search.cpan.org/~gruber/IPC-Messaging-0.01_04/
process handling and message passing, Erlang style
----
Image-Magick-Thumbnail-PDF-1.07
http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.07/
make thumbnail of a page in a pdf document
----
Image-Magick-Thumbnail-PDF-1.08
http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-PDF-1.08/
make thumbnail of a page in a pdf document
----
Lingua-HE-MacHebrew-0.05
http://search.cpan.org/~sadahiro/Lingua-HE-MacHebrew-0.05/
transcoding between Mac OS Hebrew encoding and Unicode
----
Lingua-JA-MacJapanese-0.04
http://search.cpan.org/~sadahiro/Lingua-JA-MacJapanese-0.04/
transcoding between Mac OS Japanese encoding and Unicode
----
Lingua-KO-Hangul-Util-0.23
http://search.cpan.org/~sadahiro/Lingua-KO-Hangul-Util-0.23/
utility functions for Hangul in Unicode
----
Lingua-KO-MacKorean-0.04
http://search.cpan.org/~sadahiro/Lingua-KO-MacKorean-0.04/
transcoding between Mac OS Korean encoding and Unicode
----
Lingua-ZH-MacChinese-Simplified-0.04
http://search.cpan.org/~sadahiro/Lingua-ZH-MacChinese-Simplified-0.04/
transcoding between Mac OS Chinese Simplified encoding and Unicode
----
Lingua-ZH-MacChinese-Traditional-0.04
http://search.cpan.org/~sadahiro/Lingua-ZH-MacChinese-Traditional-0.04/
transcoding between Mac OS Chinese Traditional encoding and Unicode
----
Log-Handler-0.35
http://search.cpan.org/~bloonix/Log-Handler-0.35/
A simple handler to log messages to log files.
----
Net-Analysis-0.4.0
http://search.cpan.org/~worrall/Net-Analysis-0.4.0/
Modules for analysing network traffic
----
POD-Tested-0.03
http://search.cpan.org/~nkh/POD-Tested-0.03/
Test the code in your POD and generates POD.
----
POE-Component-Client-MPD-0.7.1
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.7.1/
a full-blown mpd client library
----
POE-Component-IRC-5.31_04
http://search.cpan.org/~bingos/POE-Component-IRC-5.31_04/
a fully event-driven IRC client module.
----
SOAP-WSDL-1.23
http://search.cpan.org/~mkutter/SOAP-WSDL-1.23/
SOAP with WSDL support
----
Sepia-0.90
http://search.cpan.org/~seano/Sepia-0.90/
Simple Emacs-Perl Interface
----
Socialtext-Wikrad-0.05
http://search.cpan.org/~lukec/Socialtext-Wikrad-0.05/
efficient wiki browsing and editing
----
Sort-Key-Radix-0.10
http://search.cpan.org/~salva/Sort-Key-Radix-0.10/
Radix sort implementation in XS
----
Test-Cookbook-0.02
http://search.cpan.org/~nkh/Test-Cookbook-0.02/
Write your tests as cookbooks
----
Test-Resub-1.02
http://search.cpan.org/~airwave/Test-Resub-1.02/
Lexically scoped subroutine replacement for testing
----
Test.php-0.01
http://search.cpan.org/~avar/Test.php-0.01/
TAP test framework for PHP with a Test::More-like interface
----
Unicode-Normalize-1.02
http://search.cpan.org/~sadahiro/Unicode-Normalize-1.02/
Unicode Normalization Forms
----
Win32-TestServerManager-0.02
http://search.cpan.org/~ishigaki/Win32-TestServerManager-0.02/
manage simple test servers on Win32
----
YAML-Tiny-1.11
http://search.cpan.org/~adamk/YAML-Tiny-1.11/
Read/Write YAML files with as little code as possible
----
YAML-Tiny-1.12
http://search.cpan.org/~adamk/YAML-Tiny-1.12/
Read/Write YAML files with as little code as possible
----
ack-1.63_01
http://search.cpan.org/~petdance/ack-1.63_01/
grep-like text finder
----
encoding-warnings-0.11
http://search.cpan.org/~audreyt/encoding-warnings-0.11/
Warn on implicit encoding conversions
----
sapnwrfc-0.12
http://search.cpan.org/~piers/sapnwrfc-0.12/
SAP Netweaver RFC support for Perl
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: Wed, 06 Jun 2007 09:42:18 -0000
From: Ilias Lazaridis <ilias@lazaridis.com>
Subject: Obtain Filename and Lineno of the Function Caller
Message-Id: <1181122938.880343.175090@w5g2000hsg.googlegroups.com>
sub title { my ($text) = @_;
print
"\n---------------------------------------------------------------------
\n";
warn "\===== DEMO: $text =====";
print
"---------------------------------------------------------------------
\n";
}
The above function simply prints a title with some formatting.
I 'abuse' the "warn" statement to print the filename and the line-
number.
problem: the line number and the file containing the 'sub title" is
printed.
need: I would need to print out the line number and filenname of the
function which CALLS "title".
can I achieve this in an automated way (e.g. no need to pass the
information to the "title" function)?
.
--
http://dev.lazaridis.com/lang/wiki/Perl
------------------------------
Date: Wed, 06 Jun 2007 12:19:33 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Obtain Filename and Lineno of the Function Caller
Message-Id: <5cng6nF2ve3b0U1@mid.individual.net>
Ilias Lazaridis wrote:
> sub title { my ($text) = @_;
> print
> "\n---------------------------------------------------------------------
> \n";
> warn "\===== DEMO: $text =====";
> print
> "---------------------------------------------------------------------
> \n";
> }
>
> The above function simply prints a title with some formatting.
>
> I 'abuse' the "warn" statement to print the filename and the line-
> number.
>
> problem: the line number and the file containing the 'sub title" is
> printed.
>
> need: I would need to print out the line number and filenname of the
> function which CALLS "title".
>
> can I achieve this in an automated way (e.g. no need to pass the
> information to the "title" function)?
Try replacing
warn "\===== DEMO: $text =====";
with
my ($file, $line) = (caller)[1..2];
print "===== DEMO: $text ===== at $file line $line.\n";
perldoc -f caller
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 06 Jun 2007 10:35:20 -0000
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Obtain Filename and Lineno of the Function Caller
Message-Id: <1181126120.452817.301010@q75g2000hsh.googlegroups.com>
On Jun 6, 5:42 am, Ilias Lazaridis <i...@lazaridis.com> wrote:
> sub title { my ($text) = @_;
> print
> "\n---------------------------------------------------------------------
> \n";
> warn "\===== DEMO: $text =====";
> print
> "---------------------------------------------------------------------
> \n";
>
> }
>
> The above function simply prints a title with some formatting.
>
> I 'abuse' the "warn" statement to print the filename and the line-
> number.
No need to abuse warn for that. You do realize that warn() prints to
STDERR while print() prints to STDOUT, right?
print "DEMO: $text. File " . __FILE__ . ", line: " . __LINE__;
> problem: the line number and the file containing the 'sub title" is
> printed.
>
> need: I would need to print out the line number and filenname of
> the function which CALLS "title".
Oooh, *so* close to a SAQ. :-) Anyway, like Gunnar said, perldoc -f
caller.
However, if you later decide in a different program that you do want
this sort of statement to go to STDERR like your warn() does above,
see:
perldoc Carp
Paul Lalli
------------------------------
Date: Wed, 06 Jun 2007 05:55:39 -0700
From: Subra <mailursubbu@gmail.com>
Subject: Search and Replace with perl
Message-Id: <1181134539.470120.313260@a26g2000pre.googlegroups.com>
Hi,
I have a file with entries like
=======================================
_RWSTD_VALUE_ALLOC(test1,
test5);
_RWSTD_VALUE_ALLOC(test1,snm);
_RWSTD_VALUE_ALLOC(xyz,
789);
_RWSTD_VALUE_ALLOC(test1,sbk);
_RWSTD_VALUE_ALLOC(abc,
123);
:
===============================
I want to put 2nd argument to _RWSTD_VALUE_ALLOC as *this .
So my resultant file should be
=======================================
_RWSTD_VALUE_ALLOC(test1,*this,
test5);
_RWSTD_VALUE_ALLOC(test1,snm);
_RWSTD_VALUE_ALLOC(xyz,*this,
789);
_RWSTD_VALUE_ALLOC(test1,sbk);
_RWSTD_VALUE_ALLOC(abc,*this,
123);
:
===============================
Please help me to write this script....
------------------------------
Date: Tue, 05 Jun 2007 23:11:53 -0700
From: jeevs <jeevan.ingale@gmail.com>
Subject: Re: simple regex
Message-Id: <1181110313.039701.112220@q19g2000prn.googlegroups.com>
well paul i tested this on windows n works fine... So is it really
related to multiple paranthesis?.
So I think, the input has to be checked. But r3gis please follow
Paul's advice as I may be wrong being a newbie
#!/usr/bin/perl
use strict;
use warnings;
my @arr = ('http://www.kanazawa-gu.ac.jp/~hayashiy/cgi-bin/log/
env.cgi', 'http://www.bsnoop.de/cgi-bin/jenv.cgi','asdadada');
foreach (@arr) {
if ($_=~m!((http://[a-z-\/\.~]+\.(php|cgi|pl)))!g) {
print $_;
}
}
------------------------------
Date: Wed, 06 Jun 2007 10:38:08 -0000
From: Paul Lalli <mritty@gmail.com>
Subject: Re: simple regex
Message-Id: <1181126288.833067.294610@w5g2000hsg.googlegroups.com>
On Jun 6, 2:11 am, jeevs <jeevan.ing...@gmail.com> wrote:
> well paul i tested this on windows n works fine... So is it really
> related to multiple paranthesis?.
You tested *what* on Windows? The code that r3gis posted, or the code
that you posted? The code that r3gis posted is incomplete, so I'd
like to see the actual program you used. The code that you posted has
nothing at all to do with the original problem.
Confused,
Paul Lalli
------------------------------
Date: Wed, 06 Jun 2007 05:51:50 -0700
From: jeevs <jeevan.ingale@gmail.com>
Subject: Re: simple regex
Message-Id: <1181134310.445807.31070@d30g2000prg.googlegroups.com>
On Jun 6, 3:38 pm, Paul Lalli <mri...@gmail.com> wrote:
> On Jun 6, 2:11 am, jeevs <jeevan.ing...@gmail.com> wrote:
>
> > well paul i tested this on windows n works fine... So is it really
> > related to multiple paranthesis?.
> You tested *what* on Windows? The code that r3gis posted, or the code
> that you posted?
Sorry for my irrelevant post ... I meant the code posted by me which I
accept was not at all related to the original problem and I apologize
for taking your and others time into this.
r3gis as suggested by Paul you can replace the following line in your
code
foreach $judge( $res->content=~m#((http://[a-z-\/\.~]+\.(php|cgi|
pl)))#g)
by
foreach $judge( $res->content=~m!(http://[a-z-\/\.~]+\.(?:php|cgi|pl))!
g)
Thanks Paul. I will be carefull next time.
------------------------------
Date: Wed, 06 Jun 2007 09:16:41 -0000
From: andy <nitindutt2005@gmail.com>
Subject: string matching inside file and save in a variable
Message-Id: <1181121401.175234.170160@q75g2000hsh.googlegroups.com>
i have a file containing the below contents.
===========================================
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/bash
daemon:x:2:2:Daemon:/sbin:/bin/bash
lp:x:4:7:Printing daemon:/var/spool/lpd:/bin/bash
mail:x:8:12:Mailer daemon:/var/spool/clientmqueue:/bin/false
news:x:9:13:News system:/etc/news:/bin/bash
uucp:x:10:14:Unix-to-Unix CoPy system:/etc/uucp:/bin/bash
games:x:12:100:Games account:/var/games:/bin/bash
man:x:13:62:Manual pages viewer:/var/cache/man:/bin/bash
at:x:25:25:Batch jobs daemon:/var/spool/atjobs:/bin/bash
wwwrun:x:30:8:WWW daemon apache:/var/lib/wwwrun:/bin/false
ftp:x:40:49:FTP account:/srv/ftp:/bin/bash
postfix:x:51:51:Postfix Daemon:/var/spool/postfix:/bin/false
sshd:x:71:65:SSH daemon:/var/lib/sshd:/bin/false
========================================================
I want the fourth coulmn that is after 3rd semicolon value to be
stored in a variable for each row .
I am not getting the exact regular expression for this.
Thanks
------------------------------
Date: Wed, 06 Jun 2007 12:05:38 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: string matching inside file and save in a variable
Message-Id: <5cnfckF31nsi6U1@mid.individual.net>
andy wrote:
> i have a file containing the below contents.
> ===========================================
> root:x:0:0:root:/root:/bin/bash
> bin:x:1:1:bin:/bin:/bin/bash
> daemon:x:2:2:Daemon:/sbin:/bin/bash
> lp:x:4:7:Printing daemon:/var/spool/lpd:/bin/bash
> mail:x:8:12:Mailer daemon:/var/spool/clientmqueue:/bin/false
> news:x:9:13:News system:/etc/news:/bin/bash
> uucp:x:10:14:Unix-to-Unix CoPy system:/etc/uucp:/bin/bash
> games:x:12:100:Games account:/var/games:/bin/bash
> man:x:13:62:Manual pages viewer:/var/cache/man:/bin/bash
> at:x:25:25:Batch jobs daemon:/var/spool/atjobs:/bin/bash
> wwwrun:x:30:8:WWW daemon apache:/var/lib/wwwrun:/bin/false
> ftp:x:40:49:FTP account:/srv/ftp:/bin/bash
> postfix:x:51:51:Postfix Daemon:/var/spool/postfix:/bin/false
> sshd:x:71:65:SSH daemon:/var/lib/sshd:/bin/false
> ========================================================
> I want the fourth coulmn that is after 3rd semicolon value to be
> stored in a variable for each row .
> I am not getting the exact regular expression for this.
I would have used the split() function:
( split /:/, $row )[3]
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 06 Jun 2007 05:30:53 -0700
From: hendedav@gmail.com
Subject: Re: system call
Message-Id: <1181133053.478239.34480@m36g2000hse.googlegroups.com>
On Jun 5, 3:11 pm, hende...@gmail.com wrote:
> On Jun 5, 2:57 pm, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
>
>
>
> > In article <1181066594.594834.6...@g4g2000hsf.googlegroups.com>,
>
> > <hende...@gmail.com> wrote:
> > > Gang,
>
> > > I am using a cgi to call a pl script and then pass xml back to
> > > the web browser (code listed below). The problem I am having is that
> > > the code in the cgi executes promptly and as it should, but the return
> > > values, for some reason, don't get sent to the browser until the pl
> > > script is completed. Currently the pl script accepts two parameters
> > > (but does nothing with the first one currently) and just uses a while
> > > loop that counts to the 2nd passed value. If anyone can help with
> > > this (or knows a better way to get the pid, please let me know.
>
> > > Dave
>
> > > $_ = param('runnow'); # passed variable value
> > > if (system("./backup.pl \"$_\" 30 \&") == 0) {
> > > $_ = `ps aux|grep "backup.pl $_" 2>&1`; # finds the pid of the
> > > pl
> > > my ($pid) = /(\d{3,})/; # isolates the pid only
> > > chomp($pid);
>
> > Unnecessary, as $pid will contain only decimal digits.
>
> > > my @info = stat("/tmp/buj$pid"); # this file is created by the pl
> > > script
>
> > > print "Content-type: text/xml\n\n\n";
> > > print "<info pid=\"". $pid ."\" date=\"". scalar(localtime) ."\" /
> > > >";
> > > }
>
> > Where is the while loop you described? Are you describing one program
> > and posting another?
>
> > In any case, what happens after your Perl program emits output is up to
> > your web server and the client's browser. It is not under Perl's
> > control. However, you can maybe help things to move along more quickly
> > by flushing the output. See 'perldoc -q flush' for details.
>
> > Posted Via Usenet.com Premium Usenet Newsgroup Services
> > ----------------------------------------------------------
> > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> > ----------------------------------------------------------
> > http://www.usenet.com
>
> Thanks for the reply. The while loop is stored in the pl file (listed
> below). But if perl sends the xml listed above and exists immediately
> after, why would the browser not process it? Since the system call
> has an appended & at the end to indicate to run as a seperate process,
> the browser shouldn't be waiting on perl to finish that additional
> script call, right?
>
> entire contents of the test.pl script:
> ----------------------------------------
> #!/usr/bin/perl -w
>
> my $test = $ARGV[0];
> my $duration = $ARGV[1];
>
> $_ = `ps aux|grep "test.pl $test" 2>&1`;
> my ($pid) = /(\d{3,})/;
> chomp($pid);
> open(TMP, ">/tmp/buj$pid") || die "Can't create: $!\n";
> close(TMP);
>
> my $i=0;
> while ($i<$duration) {
> sleep(1);
> $i++;}
>
> unlink "/tmp/buj$pid"; # erase the /tmp/bujPID file
Can anyone else offer any advice or solutions to this problem? Or
does anyone know a better way to find the pid of a running perl
program?
Thanks,
Dave
------------------------------
Date: Wed, 06 Jun 2007 12:58:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: system call
Message-Id: <dcy9i.2004$NZ4.1124@trndny04>
hendedav@gmail.com wrote:
> Or
> does anyone know a better way to find the pid of a running perl
> program?
perldoc perlvar:
$$ The process number of the Perl running this script. You should
consider this variable read-only, although it will be altered
across fork() calls. (Mnemonic: same as shells.)
jue
------------------------------
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 487
**************************************