[31094] in Perl-Users-Digest
Perl-Users Digest, Issue: 2339 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 15 03:09:44 2009
Date: Wed, 15 Apr 2009 00: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, 15 Apr 2009 Volume: 11 Number: 2339
Today's topics:
changing directory inside perldb session in emacs <freesoft12@gmail.com>
F<utf8.pm> is evil (was: XML::LibXML UTF-8 toString() - <whynot@pozharski.name>
new CPAN modules on Wed Apr 15 2009 (Randal Schwartz)
Re: Pipe Between Programs <nick@maproom.co.uk>
Re: Regex question. Oh I so cannot do regular expressio <someone@example.com>
Re: Regex question. Oh I so cannot do regular expressio <cdalten@gmail.com>
Re: Regex question. Oh I so cannot do regular expressio <uri@stemsystems.com>
Re: Regex question. Oh I so cannot do regular expressio <cdalten@gmail.com>
Re: Regex question. Oh I so cannot do regular expressio <uri@stemsystems.com>
Re: Regex question. Oh I so cannot do regular expressio <cdalten@gmail.com>
Re: Regex question. Oh I so cannot do regular expressio <uri@stemsystems.com>
Re: Regex question. Oh I so cannot do regular expressio <jurgenex@hotmail.com>
Re: Regex question. Oh I so cannot do regular expressio <jurgenex@hotmail.com>
UPDATE ON FREE UNIX ROOT ACCOUNT ON SOLARIS 10 SPARC <kartik.vashishta@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 14 Apr 2009 22:05:10 -0700 (PDT)
From: John <freesoft12@gmail.com>
Subject: changing directory inside perldb session in emacs
Message-Id: <672744bc-ebbe-4ab9-a6a8-0dadf321fd8f@f19g2000yqo.googlegroups.com>
I am using Emacs version 21.3.1. When I typed
M-x perldb <enter> perl /a/b/c.pl
perldb sets the directory to where the perl script resides, in this
case '/a/b'. I want to set the debugging session to run at another
directory, say '/c/d'. How can I set it?
Regards
John
------------------------------
Date: Wed, 15 Apr 2009 02:45:51 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: F<utf8.pm> is evil (was: XML::LibXML UTF-8 toString() -vs- nodeValue())
Message-Id: <slrngua82p.113.whynot@orphan.zombinet>
On 2009-04-12, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> On 2009-04-12 14:14, Eric Pozharski <whynot@pozharski.name> wrote:
*SKIP*
>> On 2009-04-11, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>> On 2009-04-11 11:59, Eric Pozharski <whynot@pozharski.name> wrote:
I've thought a lot. I should admit, whenever I see C<use 'utf8';>
instead of C<use encoding 'utf8';> I'm going nuts. Look at what we've
got here
*SKIP*
> Let's compare 4 programs, which are all essentially the same:
>
*SKIP*
> The differences are in the encoding of the source file (UTF-8 vs.
> ISO-8859-7) and the line marked "use XXX ###" above.
>
> 1) encoded in UTF-8, contains "use utf8;"
> prints:
>
> char[14]: 0x39a 0x3b1 0x3bb 0x3b7 0x3bc 0x3ad 0x3c1 0x3b1 0x20 0x3ba
> 0x3cc 0x3c3 0x3bc 0x3b5
>
*SKIP*
> 3) encoded in ISO-8859-7, contains "use encoding 'ISO-8859-1';"
> prints:
>
> char[14]: 0x39a 0x3b1 0x3bb 0x3b7 0x3bc 0x3ad 0x3c1 0x3b1 0x20 0x3ba
> 0x3cc 0x3c3 0x3bc 0x3b5
>
*SKIP*
And with C<use encoding 'utf8';> you'll get the same character string,
and lots of other useful stuff. (I just can't get why anyone would need
implicit upgrade of scalars into characters and yet then maintain wide
IO.) But my point isn't that F<encoding.pm> outperforms F<utf8.pm>.
I'm scared. I consider F<utf8.pm> kind of Pandora box. Read this, if
you can
проц запросить {
мое ($имяфайла) = @_;
если (существует $ЗАГАЛ{$имяфайла}) {
вернуть 1 если $ЗАГАЛ{$имяфайла};
прекратить "Сбой компиляции в запросить";
}
мое ($настоящийфайл,$результат);
ИТЕР: {
длякаждого $префикс (@ЗАГАЛ) {
$настоящийфайл = "$префикс/$имяфайла";
если (-ф $настоящийфайл) {
$ЗАГАЛ{$имяфайла} = $настоящийфайл;
$результат = делать $настоящийфайл;
последний ИТЕР;
}
}
прекратить "$имяфайла не найдено в \@ЗАГАЛ";
}
если ($@) {
$ЗАГАЛ{$имяфайла} = неопред;
прекратить $@;
} другое (!$результат) {
удалить $ЗАГАЛ{$имяфайла};
прекратить "не ИСТИНА возвращена из $имяфайла";
} иначе {
вернуть $результат;
}
}
I admit, it's imposible to write this with F<utf8.pm> alone
(F<overload.pm> comes to mind, however I can't comment on this I haven't
used it). I looked for simple yet rich code, and then found this piece
more showing. I bet you've seen this before, you use it constantly.
Yet can you name it?
Someone could say "Who the heck would need that stupidity?" Idiots. It
still surprises me how many idiots are around. They would scream:
"Look! What a cool stuff! I have to learn nothing!"
You can say: "Eric, what a strange stuff you smoke? That's
impossible." I think you're wrong. I've come to conclusion
(overoptimistic?) that idiots around you are the same that around me.
So they would scream. (BTW, I don't smoke, I pipe "Prima optima
light".)
[ Lots of irrelevant stuff below, can easily be skipped ]
*SKIP*
>> My understanding is based on this -- C<perldoc perlunicode>
>>
>> "use encoding" needed to upgrade non-Latin-1 byte strings
>> By default, there is a fundamental asymmetry in Perl's Unicode
>> model: implicit upgrading from byte strings to Unicode strings
>> assumes that they were encoded in ISO 8859-1 (Latin-1), but
>> Unicode strings are downgraded with UTF-8 encoding.
>
> This paragraph is confusing. I have a vague idea what the author wanted
> to say but even then it's not quite correct. I doubt somebody can
> understand this paragraph unless they already exactly understood the
> problems before.
>
>
>> This happens because the first 256 codepoints in Unicode happens
>> to agree with Latin-1.
>>
>> If encoding is unknown, it's treated as latin1, even if it's not.
>
> This has nothing to do with "use utf8" and "use encoding". The
> "implicit upgrading" which is mentioned here happens (for example) when
> you concatenate a byte string to a character string. But then the result
> *is* a character string, not a byte string.
BTW, F<encoding.pm> says exactly what you've said. What F<utf8.pm>
mangles. Thanks, now I feel much better.
> Byte strings are *not* implicitely assumed to be ISO-8859-1, as you can
> easily check by matching against a character class:
>
> % perl -le '$_ = "\x{FC}"; print /\w/ ? "yes" : "no"'
> no
> % perl -le '$_ = "\x{FC}"; utf8::upgrade($_); print /\w/ ? "yes" : "no"'
> yes
For those unaware what happened
perl -MDevel::Peek -wle '
$_ = "\x{FC}";
Dump $_;
utf8::upgrade($_);
Dump $_;
print' | recode latin1..utf8
SV = PV(0x92556d0) at 0x9280470
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x926ca60 "\374"\0
CUR = 1
LEN = 4
SV = PV(0x92556d0) at 0x9280470
REFCNT = 1
FLAGS = (POK,pPOK,UTF8)
PV = 0x9269068 "\303\274"\0 [UTF8 "\x{fc}"]
CUR = 2
LEN = 3
ü
*SKIP*
>>>> In case there would be C<use utf8> or C<use encoding 'utf8'>,
>>>
>>> then the compiler would complain about a malformed UTF-8 character if
>>> the source file was actually in ISO-8859-7.
>>
>> But it didn't.
>
> It does for me. If I change "use encoding 'ISO-8859-7'" to "use utf8"
> in my ISO-8859-7 encoded file, I get a lot of warnings.
Yes, it does. Since I've typed examples on command-line I'd gone with
those hex-escapes. They don't warn. If B<perl> finds *bytes* with high
bit set (so they aren't valid utf8) while being in any way utf8 encoding
mode then it really complains (and complains a lot).
*SKIP*
>> Do not use this pragma for anything else than telling Perl that your
>> script is written in UTF-8. The utility functions described below
>> are directly usable without "use utf8;".
>
> I believe I already said that once or twice in this thread.
>
>
>> My understanding of "script" is a program text outside of any quotes in
>> it.
>
> Bullshit. A script is the complete program text, including any string
> constants, numeric constants, comments, the __DATA__ stream, if any.
> Why would a string constant in a script not be part of it?
Yes, I should agree that "script" in general means this. That's my
understanding of what was said (or meant) here by this word.
*SKIP*
> You mean:
>
> {3415:30} [0:0]$ perl -Mencoding=ucs2 -wle 'print "\x{4404}\x{4b04}\x{3204}\x{3004}"'
> Can't locate object method "cat_decode" via package "Encode::Unicode" at
> -e line 1.
>
> That doesn't fix the endianness, and it behaves completely differently.
> "perl -Mencoding=ucs2" can't work, as I already explained to sln.
This fixes endianness?
{56061:37} [0:0]$ perl -Mencoding=ucs2 -wle 'print "\x{0444}\x{044b}\x{0432}\x{0430}"'
Can't locate object method "cat_decode" via package "Encode::Unicode" at
-e line 1.
However, since I don't understand why it "can't work", I won't complain
why it can't "locate object method".
[ Lots of irrelevant stuff above, can easily be skipped ]
However, in spite of confessing being scared of F<utf8.pm> features, I
promise to rant anytime I'll find C<use utf8;> instead of
C<use encoding 'utf8';>
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Wed, 15 Apr 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Apr 15 2009
Message-Id: <KI4L2r.1sLB@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.
Algorithm-Dependency-1.110
http://search.cpan.org/~adamk/Algorithm-Dependency-1.110/
Base class for implementing various dependency trees
----
Algorithm-Dependency-MapReduce-0.03
http://search.cpan.org/~adamk/Algorithm-Dependency-MapReduce-0.03/
A Map/Reduce implementation for Alg:Dep graphs
----
Apache2-Imager-Resize-0.10
http://search.cpan.org/~kalex/Apache2-Imager-Resize-0.10/
Fixup handler that resizes and crops images on the fly, caching the results, and doesn't require ImageMagick.
----
Apache2-WURFLFilter-1.53
http://search.cpan.org/~ifuschini/Apache2-WURFLFilter-1.53/
is a Apache Mobile Filter that manage content (text & image) to the correct mobile device
----
App-Hachero-0.06
http://search.cpan.org/~danjou/App-Hachero-0.06/
a plaggable log analyzing framework
----
Business-OnlinePayment-PayflowPro-0.07
http://search.cpan.org/~plobbes/Business-OnlinePayment-PayflowPro-0.07/
Payflow Pro backend for Business::OnlinePayment
----
CPAN-FindDependencies-2.2
http://search.cpan.org/~dcantrell/CPAN-FindDependencies-2.2/
find dependencies for modules on the CPAN
----
CPAN-Test-Dummy-Perl5-Make-Features-1.05
http://search.cpan.org/~andk/CPAN-Test-Dummy-Perl5-Make-Features-1.05/
CPAN Test Dummy
----
CPANPLUS-Dist-Build-0.22
http://search.cpan.org/~bingos/CPANPLUS-Dist-Build-0.22/
CPANPLUS plugin to install packages that use Build.PL
----
Catalyst-Model-Data-Localize-0.00004
http://search.cpan.org/~dmaki/Catalyst-Model-Data-Localize-0.00004/
Catalyst Model Over Data::Localize
----
DBD-SQLite-1.22_05
http://search.cpan.org/~adamk/DBD-SQLite-1.22_05/
Self-contained RDBMS in a DBI Driver
----
Data-Localize-0.00006
http://search.cpan.org/~dmaki/Data-Localize-0.00006/
Alternate Data Localization API
----
Data-Localize-0.00007
http://search.cpan.org/~dmaki/Data-Localize-0.00007/
Alternate Data Localization API
----
Data-NDS-3.10
http://search.cpan.org/~sbeck/Data-NDS-3.10/
routines to work with a perl nested data structure
----
Data-NDS-Multiele-3.10
http://search.cpan.org/~sbeck/Data-NDS-Multiele-3.10/
A set of data structures with the same structure
----
Data-NDS-Multifile-3.10
http://search.cpan.org/~sbeck/Data-NDS-Multifile-3.10/
A multi-file version of Data::NDS::Multiele
----
Devel-CheckOS-1.51
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.51/
check what OS we're running on
----
Drupal-Admin-0.04
http://search.cpan.org/~durist/Drupal-Admin-0.04/
screen scraping Perl API to some Drupal admin functions
----
Elive-0.03
http://search.cpan.org/~warringd/Elive-0.03/
Elluminate Live (c) client library
----
ExtUtils-MakeMaker-6.51_02
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.51_02/
Create a module Makefile
----
Finance-IIF-0.21_02
http://search.cpan.org/~plobbes/Finance-IIF-0.21_02/
Parse and create IIF files for QuickBooks
----
IPTables-libiptc-0.12
http://search.cpan.org/~hawk/IPTables-libiptc-0.12/
Perl extension for iptables libiptc
----
Lingua-Han-PinYin-0.12.1
http://search.cpan.org/~suntong/Lingua-Han-PinYin-0.12.1/
Retrieve the Mandarin(PinYin) of Chinese character(HanZi).
----
Lingua-Han-PinYin-0.13
http://search.cpan.org/~suntong/Lingua-Han-PinYin-0.13/
Retrieve the Mandarin(PinYin) of Chinese character(HanZi).
----
Module-Build-0.32_01
http://search.cpan.org/~ewilhelm/Module-Build-0.32_01/
Build and install Perl modules
----
Module-Changes-ADAMK-0.10
http://search.cpan.org/~adamk/Module-Changes-ADAMK-0.10/
Parse a traditional Changes file (as ADAMK interpretes it)
----
Module-Install-0.83
http://search.cpan.org/~adamk/Module-Install-0.83/
Standalone, extensible Perl module installer
----
Module-Install-0.84
http://search.cpan.org/~adamk/Module-Install-0.84/
Standalone, extensible Perl module installer
----
Net-Google-Spreadsheets-0.04
http://search.cpan.org/~danjou/Net-Google-Spreadsheets-0.04/
A Perl module for using Google Spreadsheets API.
----
Net-Interface-1.011
http://search.cpan.org/~miker/Net-Interface-1.011/
Perl extension to access network interfaces
----
ORDB-CPANTesters-0.07
http://search.cpan.org/~adamk/ORDB-CPANTesters-0.07/
An ORM for the published CPAN Testers SQLite database
----
PHP-Serialization-0.31
http://search.cpan.org/~bobtfish/PHP-Serialization-0.31/
simple flexible means of converting the output of PHP's serialize() into the equivalent Perl memory structure, and vice versa.
----
POE-API-Peek-1.34
http://search.cpan.org/~sungo/POE-API-Peek-1.34/
Peek into the internals of a running POE environment
----
POE-Session-Multiplex-0.0401
http://search.cpan.org/~gwyn/POE-Session-Multiplex-0.0401/
POE session with object multiplexing
----
Package-Subroutine-0.16_1
http://search.cpan.org/~sknpp/Package-Subroutine-0.16_1/
minimalistic import/export and other util methods
----
Parse-Dia-SQL-0.08
http://search.cpan.org/~aff/Parse-Dia-SQL-0.08/
Convert Dia class diagrams into SQL.
----
Path-Extended-0.11
http://search.cpan.org/~ishigaki/Path-Extended-0.11/
yet another Path class
----
Process-0.26
http://search.cpan.org/~adamk/Process-0.26/
Objects that represent generic computational processes
----
Provision-Unix-0.52
http://search.cpan.org/~msimerson/Provision-Unix-0.52/
provision accounts on unix systems
----
Set-ArrayAlt-1.00
http://search.cpan.org/~sbeck/Set-ArrayAlt-1.00/
arrays as objects with list/set operations
----
Software-License-0.010
http://search.cpan.org/~rjbs/Software-License-0.010/
packages that provide templated software licenses
----
Template-Plugin-ListOps-2.00
http://search.cpan.org/~sbeck/Template-Plugin-ListOps-2.00/
Plugin interface to list operations
----
Test-Builder-Mock-Class-0.01
http://search.cpan.org/~dexter/Test-Builder-Mock-Class-0.01/
Simulating other classes with Test::Builder
----
Test-Mock-Class-0.01
http://search.cpan.org/~dexter/Test-Mock-Class-0.01/
Simulating other classes
----
Test-Regexp-2009041401
http://search.cpan.org/~abigail/Test-Regexp-2009041401/
Test your regular expressions
----
Test-Valgrind-1.01
http://search.cpan.org/~vpit/Test-Valgrind-1.01/
Test Perl code through valgrind.
----
WWW-Curl-Simple-0.01
http://search.cpan.org/~andremar/WWW-Curl-Simple-0.01/
A simpler interface to WWW::Curl
----
WWW-Lengthen-0.07
http://search.cpan.org/~ishigaki/WWW-Lengthen-0.07/
lengthen 'shortened' urls
----
WWW-Shorten-Digg-0.01
http://search.cpan.org/~broerse/WWW-Shorten-Digg-0.01/
Perl interface to digg.com
----
WWW-Shorten-Qurl-2.01
http://search.cpan.org/~davecross/WWW-Shorten-Qurl-2.01/
Perl interface to qurl.com
----
WebService-Yandex-Suggest-1.00
http://search.cpan.org/~stealthy/WebService-Yandex-Suggest-1.00/
Yandex Suggest as an API
----
Win32-Process-Critical-v0.2
http://search.cpan.org/~rootkwok/Win32-Process-Critical-v0.2/
Prevent interrupting by setting it as a Critical process
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/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Tue, 14 Apr 2009 21:12:22 +0100
From: Nick Wedd <nick@maproom.co.uk>
Subject: Re: Pipe Between Programs
Message-Id: <B8I$CV3m4O5JFAFk@maproom.demon.co.uk>
In message <86myanm0wy.fsf@mithril.chromatico.net>, Charlton Wilbur
<cwilbur@chromatico.net> writes
>>>>>> "EDG" == E D G <edgrsprj@ix.netcom.com> writes:
>
> EDG> Perhaps there needs to be another Perl Newsgroup. It would be
> EDG> one where people could discuss what they wished without tying
> EDG> up the time and energy of the Perl experts. The experts could
> EDG> continue to answer questions posted to this Newsgroup.
>
>The value of the newsgroup is directly proportional to the participation
>of experts. If you let non-experts discuss whatever they like with
>non-experts, you will get the blind leading the blind, in a great
>assortment of anti-help.
I think E.D.G. is being diplomatic when he writes "experts". He is
referring to people who may well know a lot about Perl, but prefer
scoring points off those who questions to actually saying anything
useful. This is harmless in itself, such experts can be killfiled; the
snag is that their presence deters responses from those who might have
given helpful answers.
If this group could be abandoned to those experts, and a new one set up
where people could get helpful answers, it wouldn't really help. The
experts would soon realise that there was a new supply of victims for
them to torment.
Nick
--
Nick Wedd nick@maproom.co.uk
------------------------------
Date: Tue, 14 Apr 2009 11:12:59 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <Pm4Fl.36258$qO1.33217@newsfe13.iad>
grocery_stocker wrote:
> On Apr 14, 9:47 am, Uri Guttman <u...@stemsystems.com> wrote:
>>>>>>> "gs" == grocery stocker <cdal...@gmail.com> writes:
>> gs> On Apr 14, 9:27 am, ddun...@taos.com (Darren Dunham) wrote:
>> >>
>> >> Why are you quoting $test?
>> >>
>>
>> gs> Because in the full size script, $test is actually...
>>
>> gs> $test = `w | grep cdalten | grep party`;
>>
>> so?? perl isn't the shell so it doesn't need quoting around single
>> scalars even if they have blanks in them.
>>
>
> Actually, the script borks when I try to use backticks.
>
> [cdalten@localhost oakland]$ more match.pl
> #!/usr/bin/perl
> use warnings;
>
> #$string = `w | grep cdalten | grep telnet`;
>
> $test = `w | grep cdalten | grep telnet`;
>
> print $test;
>
> if ($test =~/(\bchad\b)/ && $test =~/(\btelnet\b)/ ) {
> print "true \n";
> }
> [cdalten@localhost oakland]$ ./match.pl
> cdalten pts/7 :0.0 Mon12 14:55 0.62s 0.24s telnet
> [cdalten@localhost oakland]$
>
> Ides why?
Yes, the string 'chad' cannot be found in the string 'cdalten pts/7
:0.0 Mon12 14:55 0.62s 0.24s telnet'.
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
------------------------------
Date: Tue, 14 Apr 2009 11:37:22 -0700 (PDT)
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <d89fe2b5-0fa9-4f98-a693-50415144657b@s22g2000prg.googlegroups.com>
On Apr 14, 11:07 am, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "gs" == grocery stocker <cdal...@gmail.com> writes:
>
> gs> Actually, the script borks when I try to use backticks.
>
> gs> [cdalten@localhost oakland]$ more match.pl
> gs> #!/usr/bin/perl
> gs> use warnings;
>
> use strict too.
>
> gs> $test = `w | grep cdalten | grep telnet`;
>
> perl can do the grep for you and faster than forking two external greps.
>
Could I write it with one call to perl grep() or would I have use two
calls to grep()?
------------------------------
Date: Tue, 14 Apr 2009 14:51:37 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <x7y6u35arq.fsf@mail.sysarch.com>
>>>>> "gs" == grocery stocker <cdalten@gmail.com> writes:
gs> On Apr 14, 11:07 am, Uri Guttman <u...@stemsystems.com> wrote:
>> >>>>> "gs" == grocery stocker <cdal...@gmail.com> writes:
>>
gs> Actually, the script borks when I try to use backticks.
>>
gs> [cdalten@localhost oakland]$ more match.pl
gs> #!/usr/bin/perl
gs> use warnings;
>>
>> use strict too.
>>
gs> $test = `w | grep cdalten | grep telnet`;
>>
>> perl can do the grep for you and faster than forking two external greps.
>>
gs> Could I write it with one call to perl grep() or would I have use two
gs> calls to grep()?
either way depending on the regex you use. it is the same problem you
have been working on with your if statement.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Tue, 14 Apr 2009 11:53:29 -0700 (PDT)
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <f2002199-8cb8-4836-97dc-69b6348a7452@y33g2000prg.googlegroups.com>
On Apr 14, 11:37 am, grocery_stocker <cdal...@gmail.com> wrote:
> On Apr 14, 11:07 am, Uri Guttman <u...@stemsystems.com> wrote:
>
> > >>>>> "gs" == grocery stocker <cdal...@gmail.com> writes:
>
> > gs> Actually, the script borks when I try to use backticks.
>
> > gs> [cdalten@localhost oakland]$ more match.pl
> > gs> #!/usr/bin/perl
> > gs> use warnings;
>
> > use strict too.
>
> > gs> $test = `w | grep cdalten | grep telnet`;
>
> > perl can do the grep for you and faster than forking two external greps.
>
> Could I write it with one call to perl grep() or would I have use two
> calls to grep()?
And here is what I get when I try to use one call to grep().
[cdalten@localhost oakland]$ more match3.pl
#!/usr/bin/perl
use warnings;
use strict;
my @this = grep("cdalten" && "telnet", `w`);
print @this, "\n";
[cdalten@localhost oakland]$ ./match3.pl
11:48:46 up 9 days, 4:51, 5 users, load average: 0.98, 0.74, 0.70
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
cdalten pts/1 :0.0 05Apr09 9days 0.36s 0.36s bash
cdalten pts/2 :0.0 05Apr09 8days 3.28s 2.92s python
cdalten pts/3 :0.0 Mon18 10:04 0.93s 0.56s /usr/
bin/perl /
cdalten pts/5 :0.0 11:17 0.00s 0.77s 0.05s /usr/
bin/perl .
cdalten pts/7 :0.0 Mon12 15:11 0.63s 0.25s telnet
[cdalten@localhost oakland]$
------------------------------
Date: Tue, 14 Apr 2009 15:00:19 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <x7ljq35ad8.fsf@mail.sysarch.com>
>>>>> "gs" == grocery stocker <cdalten@gmail.com> writes:
gs> my @this = grep("cdalten" && "telnet", `w`);
what do you think that is doing? the first arg to grep is an
expression. period. so what do you think this does:
$x = "cdalten" && "telnet" ?
do you see any regex code there?
please learn some more basic perl. what you are trying to do is not
difficult but you are guessing and thrashing and not programming. if you
don't know how grep works, the run perldoc -f grep. it will show you
that it takes an EXPR as its first argument, not a regex. now regexes
are the most common first arg with grep but they must be explicitly
coded.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Tue, 14 Apr 2009 12:18:09 -0700 (PDT)
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <cf60d8b3-f09c-4f02-ac79-de62f12a2951@b6g2000pre.googlegroups.com>
On Apr 14, 12:00 pm, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "gs" == grocery stocker <cdal...@gmail.com> writes:
>
> gs> my @this = grep("cdalten" && "telnet", `w`);
>
> what do you think that is doing? the first arg to grep is an
> expression. period. so what do you think this does:
>
> $x = "cdalten" && "telnet" ?
>
> do you see any regex code there?
>
> please learn some more basic perl. what you are trying to do is not
> difficult but you are guessing and thrashing and not programming. if you
> don't know how grep works, the run perldoc -f grep. it will show you
> that it takes an EXPR as its first argument, not a regex. now regexes
> are the most common first arg with grep but they must be explicitly
> coded.
>
And I really don't quite get how something like
@this = grep(/\bcdalten\b/ && /\btelnet\b/, `w`);
is faster than something like
$test = `w | grep cdalten | grep telnet`;
I mean, either way, grep is going to have to be called twice.
------------------------------
Date: Tue, 14 Apr 2009 16:09:50 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <x77i1n575d.fsf@mail.sysarch.com>
>>>>> "gs" == grocery stocker <cdalten@gmail.com> writes:
gs> And I really don't quite get how something like
gs> @this = grep(/\bcdalten\b/ && /\btelnet\b/, `w`);
that is grep inside perl. a subroutine. and it is called only once.
gs> is faster than something like
gs> $test = `w | grep cdalten | grep telnet`;
that is grep the unix utility program which requires forking a
subprocess and you do it twice.
gs> I mean, either way, grep is going to have to be called twice.
nope. they are different greps and the perl one is called only one time.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Tue, 14 Apr 2009 13:15:07 -0700
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <6jr9u4p3sibg81nje8d5ag6b2sdutem4pj@4ax.com>
grocery_stocker <cdalten@gmail.com> wrote:
>Could I write it with one call to perl grep() or would I have use two
>calls to grep()?
The grep() function takes an expression as its first argument. That
means, as long as you can express the condition as an expression, it can
be arbitrarily complex. And your trivial condition can certainly be
expressed in a very simple expression.
jue
------------------------------
Date: Tue, 14 Apr 2009 13:30:07 -0700
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: Regex question. Oh I so cannot do regular expression matching.
Message-Id: <l0s9u4dmqfgpf9slvib4cbo4u848qcbpso@4ax.com>
grocery_stocker <cdalten@gmail.com> wrote:
>> please learn some more basic perl. what you are trying to do is not
>> difficult but you are guessing and thrashing and not programming.
I would word that much stronger: please learn some basic programming!
And while we are at it: PLEASE get a better name. I really don't want to
address you as Grocery.
>And I really don't quite get how something like
>
>@this = grep(/\bcdalten\b/ && /\btelnet\b/, `w`);
>
>is faster than something like
>
>$test = `w | grep cdalten | grep telnet`;
>
>I mean, either way, grep is going to have to be called twice.
Are you aware about the differnce between a program and a function?
Version 1 creates 1 new process and launches w in that process. Then it
captures the output and returns it to the Perl program where grep() just
loops once over the in-memory data.
Version 2 creates 1 new process, starts a shell in that process (because
there are shell meta-characters in the command), then forks of 2 or even
3 more new processes (depending on the implementation), establishes
pipes between those processes, launches w, grep, and grep in those
processes, coordinates read and write between those processes, and
finally returns the final result to the Perl program.
Do you have any idea how expensive starting a new process is?
jue
------------------------------
Date: Tue, 14 Apr 2009 22:28:40 -0700 (PDT)
From: Kartik_Vashishta <kartik.vashishta@gmail.com>
Subject: UPDATE ON FREE UNIX ROOT ACCOUNT ON SOLARIS 10 SPARC
Message-Id: <8efb86bb-9492-47e5-aaf2-8d5634c132f9@k38g2000yqh.googlegroups.com>
For inconveniencing you, I apologize.
Now, to avail of free root access, first login to one system:
telnet trainingzone.getmyip.com
(username: unix password: no password, hit enter), then, telnet
192.168.0.108 (username:root, password: nopt password,hit enter).
Updates about the free training, free root account, will be made
available on:
http://www.kartik.com/FreeUNIXaccount.html
Do not hesitate to contact me.
Comfort and Peace, I wish for you.
Kartik Vashishta
------------------------------
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 2339
***************************************