[28499] in Perl-Users-Digest
Perl-Users Digest, Issue: 9863 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 18 14:06:05 2006
Date: Wed, 18 Oct 2006 11:05:15 -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, 18 Oct 2006 Volume: 10 Number: 9863
Today's topics:
Re: alarm() - SIGALRM sent too eariy? <nospam-abuse@ilyaz.org>
Re: Archive::Zip - writeToFileNamed log? <lev.weissman@creo.com>
Re: FTP to a windows file share? <bwilkins@gmail.com>
Re: FTP to a windows file share? <scobloke2@infotop.co.uk>
Re: FTP to a windows file share? <someone@example.com>
Re: FTP to a windows file share? <bwilkins@gmail.com>
Re: How to access a property within a class <asandstrom@accesswave.ca>
Re: I have no problems eating cereal...after it softens samiam@mytrashmail.com
Re: I have no problems eating cereal...after it softens <glennj@ncf.ca>
Re: I have no problems eating cereal...after it softens <tzz@lifelogs.com>
Re: I have no problems eating cereal...after it softens samiam@mytrashmail.com
Re: I have no problems eating cereal...after it softens <jgibson@mail.arc.nasa.gov>
Inappropriate ioctl for device using system("useradd") <bryan@worldspice.net>
Re: Inappropriate ioctl for device using system("userad <mritty@gmail.com>
Re: Inappropriate ioctl for device using system("userad <someone@example.com>
Inspecting the ''number' of /g match count <wahab@chemie.uni-halle.de>
Re: Inspecting the ''number' of /g match count <mritty@gmail.com>
Re: Inspecting the ''number' of /g match count greg.ferguson@icrossing.com
Re: Inspecting the ''number' of /g match count <bik.mido@tiscalinet.it>
Re: Inspecting the ''number' of /g match count <someone@example.com>
Re: Inspecting the ''number' of /g match count <wahab@chemie.uni-halle.de>
Matching umlauts <fritz-bayer@web.de>
Re: Matching umlauts <mritty@gmail.com>
Re: modify posting guidelines to allow MIME charset=utf <tzz@lifelogs.com>
Perl and Dos Batch File Create <bradbrockman@yahoo.com>
Re: Perl and Dos Batch File Create <davidjpeacock@magma.ca>
Re: Perl and Dos Batch File Create <bradbrockman@yahoo.com>
Re: question about cpan module <sherm@Sherm-Pendleys-Computer.local>
thanks to all for "goatse =()=" (was: Inspecting the '' <wahab@chemie.uni-halle.de>
Re: UTF-8 encoding problem <tzz@lifelogs.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Oct 2006 15:27:01 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: alarm() - SIGALRM sent too eariy?
Message-Id: <eh5h45$11fo$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
<anno4000@radom.zrz.tu-berlin.de>], who wrote in article <4pmgi5Fjfms6U1@news.dfncis.de>:
> > Use a Hires_Timer_t pointer instead of these integers, NOT hardwire
> > time-interval-as-two-integers.
> Okay, but that still means routines that now take an integer now must
> accept something else in its place.
Sure, there is no workaround for this...
Yours,
Ilya
------------------------------
Date: 18 Oct 2006 08:29:44 -0700
From: "MoshiachNow" <lev.weissman@creo.com>
Subject: Re: Archive::Zip - writeToFileNamed log?
Message-Id: <1161185384.463631.281610@m73g2000cwd.googlegroups.com>
Anybody ?
------------------------------
Date: 18 Oct 2006 08:18:09 -0700
From: "Brian Wilkins" <bwilkins@gmail.com>
Subject: Re: FTP to a windows file share?
Message-Id: <1161184689.693807.232540@m73g2000cwd.googlegroups.com>
MattJ83 wrote:
> So i have to make the connection with a file share of that server.
> Eg - ukbr1234.computer1.com ----- \\ukbr1234\share and then the
> location in this share would be /test for example.
>
> The trouble is i don't think the file share format '\\ukbr1234\share'
> is accepted by the perl script.....
If the file share is local, why not open a file in the directory using
simple Perl syntax:
open(FILE, "\\ukbr1234\share\test");
Windows will take care of handling the connection between yourself and
the file share as it is usually mapped by the operating system.
------------------------------
Date: Wed, 18 Oct 2006 16:53:56 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: FTP to a windows file share?
Message-Id: <QvidndGKFuyE06vYRVnyhA@bt.com>
Brian Wilkins wrote:
> MattJ83 wrote:
>>The trouble is i don't think the file share format '\\ukbr1234\share'
>>is accepted by the perl script.....
>
> open(FILE, "\\ukbr1234\share\test");
>
In that double-quoted string constant, \s means any whitespace character
doesn't it?
I'd use single quotes: '\\ukbr1234\share\test'
I think forward slashes (/) should work and are preferable since you can
safely interpolate variables into a string containing them (after
changing quotes).
open my $fh, '<', '//ukbr1234/share/test'
or die "can't open file because $!";
------------------------------
Date: Wed, 18 Oct 2006 16:35:13 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: FTP to a windows file share?
Message-Id: <5JsZg.27766$P7.2190@edtnps89>
Ian Wilson wrote:
> Brian Wilkins wrote:
>> MattJ83 wrote:
>>> The trouble is i don't think the file share format '\\ukbr1234\share'
>>> is accepted by the perl script.....
>>
>> open(FILE, "\\ukbr1234\share\test");
>
> In that double-quoted string constant, \s means any whitespace character
> doesn't it?
No, \s only has meaning in a regular expression, in a double quoted string \s
evaluates to s.
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: 18 Oct 2006 09:41:46 -0700
From: "Brian Wilkins" <bwilkins@gmail.com>
Subject: Re: FTP to a windows file share?
Message-Id: <1161189706.474775.76070@k70g2000cwa.googlegroups.com>
Ian Wilson wrote:
> In that double-quoted string constant, \s means any whitespace character
> doesn't it?
>
> I'd use single quotes: '\\ukbr1234\share\test'
>
> I think forward slashes (/) should work and are preferable since you can
> safely interpolate variables into a string containing them (after
> changing quotes).
>
> open my $fh, '<', '//ukbr1234/share/test'
> or die "can't open file because $!";
Yes, single quotes would be best.
------------------------------
Date: Wed, 18 Oct 2006 16:50:54 GMT
From: "Arved Sandstrom" <asandstrom@accesswave.ca>
Subject: Re: How to access a property within a class
Message-Id: <OXsZg.27770$P7.26335@edtnps89>
"Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net> wrote in
message news:omaZg.14974$UG4.11420@newsread2.news.pas.earthlink.net...
> On 10/17/2006 12:41 PM, Arved Sandstrom wrote:
>> [...]
>> 5. Be cognizant of scoping when it comes to how you set up your class
>> data. It's fine that you are using a file lexical - this is ordinarily
>> better than using a package global. But if you are going to inherit from
>> this module, say a MyDerivedPM which "uses" myPM and has @ISA=("myPM"),
>> be aware that $aProperty is visible only to methods defined in myPM. This
>> is covered in perltoot, and if you do use class data *and* inheritance,
>> read the manpage.
>
> How to deal with inheritable class data is discussed in perltooc.
Yes. Also mentioned in perltoot (to the extent that one becomes aware of the
issue, and has a beginning solution).
AHS
------------------------------
Date: 18 Oct 2006 08:31:51 -0700
From: samiam@mytrashmail.com
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <1161185511.796843.6280@i42g2000cwa.googlegroups.com>
Ian Wilson wrote:
>
> This sort of response always reminds me of
> http://www.catb.org/~esr/faqs/smart-questions.html#not_losing
Samiam replies:
Thanks for replying Ian: I read the article you suggested and
appreciate your input.
Since many have expressed their opinions and mandates on the issues,
perhaps I may also:
IMHO, there are bigger things afoot that one can't see if one has
already irrovocably subscribed to the the bi-laws of the pack.
No one at any time in this thread gave any substantive evaluation of my
"Aren't unique identifiers workable, perhaps more readily identified
than > upon >>?"
Instead, it's been "Our leaders say a thousand angle brackets are good
for us and you better get in line for your helping too...or else."
When questioned, the Whine Stigma Stick was brought out
indiscriminately.
Historically, the right, wrong or helpful quotient of something has
been irrelevant as long as someone in Authority speaks to the easily
manipulated tendency of most people to follow along. This happened in
Nazi Germany, in most Communist countries, with McCarthy, and is
mirrored in every little sub-culture such as the KKK or in Ivy League
Academia where people just absorb the leader's opinions uncritically,
especially once the Leader becomes a trusted source.
There is always some weak resistance usually overcome with stigma
tools. For instance, my friends are some of the brightest from Harvard,
Princeton and CalTech. Even still, they are subject to this phenomenon.
One good example from this academic subculture is the issue of
Evolution. The majority of scientists and those in Academia regard
Evolution as unquestionable fact. This has become clear in hundreds of
conversations. However, when asked why they have so much faith in
Evolution, not a single person had actually reviewed the "supporting"
data and couldn't even give me any references.
The one who did give references had simply accepted the notions of
those who claimed to be authoritative, but he didn't know enough about
the subject matter (much less do any field testing) to evaluate the
authority. He admitted this.
Not one of them had critically evaluated Evolution in even a cursory
analytical way, much less granularly questioned each assertion, proof,
claim for it's integrity, veracity, and logic.
When I pointed this out, quite a few of them, being exceptionally
bright and intellectually more honest than the average, admitted it was
a completely unexamined faith resting on the academic laurels of the
vocal proponents of Evolution. Further, they also admitted, after some
extended dialogue, to having a voice in their head that they wanted to
please - their peer group; in this case a very esteemed and prestigious
group of friends and colleagues.
They admitted that they would be thought less of, even tacitly
disdained, if they subscribed to something other than the party line,
but especially the most odious notion of all, creationism or the idea
that a quick look around strongly implies if not denotes a designer.
The stigma stick there is association with fundamentalists or
Intelligent Design groups, whose positions have also been uncritically
demonized with broad biased strokes.
The stigma stick is additionally loaded with the threat of rejection by
their peers and the fear they will be categorized as intellectually
inferior, should they deviate from the party line. The peer stigma
stick is EXTREMELY effective.
So bright or dull, people rather uniformly uncritically accept their
trusted authority's values and evaluations and should they question or
think of taking a different tack, a little prod with the Stigma Stick
will fix that.
In this group, the Stigma Stick (S.S.) is "Are you a whiner?" This
allows the complaint to bypass critical evaluation and those who have
already submitted to the S.S. are eager to justify their submission by
subjugating others to it. This is psychology 101, but not the kind you
learn about in class, the kind you learn about by looking around.
The details of this instance are:
I agree that conventions are helpful in efficiently moving data in the
same way traffic laws help in the movement of vehicles. The conventions
here are useful and I support them.
However, the standards are not necessarily perfect and should be
subject to timely re-evaluations so that improvement and intelligently
directed evolution is possible.
Being gracious in how we treat deviances from our questionable
standards is not something we should dispense with, even under the
threat of the Whine Stigma Stick (WSS).
Sometimes it's better to let some tiny small thing pass rather than
waste space and bandwidth pointing out the spec in someone's eye. It
probably WASTES FAR MORE SPACE to dedicate a post to one tiny arguable
error, than the arguable error itself. This is pure economics, not to
mention dignified and polite.
There is a nice way to correct and there is an imperious castigating
unkind way which is likely to illicit a reaction contrary to the
purpose of the correction. How is that helpful to anyone?
Help does not come from one source. The Perl world does not begin and
end with Tad and Scott, with all due respect. I appreciate their input,
truly, respect their knowledge, truly, am humbled by their
contributions, honestly, but deviating from their opinions is not a
crime and if they wish to withhold their help from anyone who suggests
contrary ideas, there are many others willing to help without a "credit
check." Even in this post, many have been gracious and practically
helpful without being nit pickers.
The Perl group conventions were not a diplomatically decided upon
instrument whose current paradigm represents the whole. There are
thousands upon thousands of people that travel these groups. The
convention represents the preferences of, when it comes down to it,
probably one guy, EVEN IF MANY now kow tow to it. Mostly unilateral
conventions can always be improved upon, unless Jesus is the one who
put the "Uni" in "Uni-lateral."
L,
S
------------------------------
Date: 18 Oct 2006 15:57:09 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <slrnejcjml.3c3.glennj@smeagol.ncf.ca>
At 2006-10-18 11:31AM, "samiam@mytrashmail.com" wrote:
[... 100 lines deleted ...]
> waste space and bandwidth pointing out the spec in someone's eye. It
> probably WASTES FAR MORE SPACE to dedicate a post to one tiny arguable
> error, than the arguable error itself.
Indeed.
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: Wed, 18 Oct 2006 17:20:07 +0100
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <g69irihmw94.fsf@lifelogs.com>
On 18 Oct 2006, samiam@mytrashmail.com wrote:
> No one at any time in this thread gave any substantive evaluation of my
> "Aren't unique identifiers workable, perhaps more readily identified
> than > upon >>?"
OK, I'll do it: it's a bad idea. It creates a context switch between
identifier styles, which is annoying. Please give up on this, lurk a
while, and you'll learn more than by posting long diatribes no one
will read.
> Historically, the right, wrong or helpful quotient of something has
> been irrelevant as long as someone in Authority speaks to the easily
> manipulated tendency of most people to follow along. This happened in
> Nazi Germany, in most Communist countries, with McCarthy, and is
> mirrored in every little sub-culture such as the KKK or in Ivy League
> Academia where people just absorb the leader's opinions uncritically,
> especially once the Leader becomes a trusted source.
Impressively, you have managed to invoke Godwin's law fairly early,
and you may not even know about it. I was expecting at least 3 more
posts.
Ted
------------------------------
Date: 18 Oct 2006 09:28:00 -0700
From: samiam@mytrashmail.com
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <1161188880.415893.248870@i42g2000cwa.googlegroups.com>
Glenn Jackman wrote:
> At 2006-10-18 11:31AM, "samiam@mytrashmail.com" wrote:
> [... 100 lines deleted ...]
> > waste space and bandwidth pointing out the spec in someone's eye. It
> > probably WASTES FAR MORE SPACE to dedicate a post to one tiny arguable
> > error, than the arguable error itself.
>
> Indeed.
>
> --
> Glenn Jackman
> Ulterior Designer
Indeed a misapplication of the principle. Questioning the overall
convention, the right to do so, and poor treatment of others in general
contrary to the goal is hardly a tofu spec in the eye.
Indeed back at ya :-)
L,
S
------------------------------
Date: Wed, 18 Oct 2006 09:50:22 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: I have no problems eating cereal...after it softens. Why is replacing a simple string so hard then?
Message-Id: <181020060950222578%jgibson@mail.arc.nasa.gov>
In article <UuqdnS8eg5iBb6jYRVnyvQ@bt.com>, Ian Wilson
<scobloke2@infotop.co.uk> wrote:
> Have you read Google's advice:
> http://groups-beta.google.com/support/bin/answer.py?answer=46492&topic=9253
> The section "Summarize what you're following up" seems relevant.
>
> Google have long been critisized for their poor interface:
> http://cfaj.freeshell.org/google/
>
> In summary, this advises google-groups users to click "show options"
> then use the "reply" link at the bottom of the article, this makes it
> easier to avoid offending the people you want help from.
Now, Google Groups' "reply" link at the bottom of each article adds the
quoted text to the reply, so this advice is no longer relevant.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 18 Oct 2006 09:01:58 -0700
From: "samasama" <bryan@worldspice.net>
Subject: Inappropriate ioctl for device using system("useradd")
Message-Id: <1161187318.125414.91340@m73g2000cwd.googlegroups.com>
My line of code is simply...
system("/usr/sbin/useradd $luser -M -n -c '$opts[4]' -d $opts[5] -s
$opts[6]") || die "Useradd : $!\n";
and dying with:
Useradd : Inappropriate ioctl for device
I haven't a clue : )
Running CentOS, 4.4 up to date.
Any help is vastly appreciated.
--
samasama
------------------------------
Date: 18 Oct 2006 09:24:20 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Inappropriate ioctl for device using system("useradd")
Message-Id: <1161188660.113492.233060@i42g2000cwa.googlegroups.com>
samasama wrote:
> My line of code is simply...
>
> system("/usr/sbin/useradd $luser -M -n -c '$opts[4]' -d $opts[5] -s
> $opts[6]") || die "Useradd : $!\n";
>
> and dying with:
> Useradd : Inappropriate ioctl for device
>
> I haven't a clue : )
>
> Running CentOS, 4.4 up to date.
>
> Any help is vastly appreciated.
system(), unlike pretty much every other Perl function, does not return
0 on failure. Rather, it returns 0 on success. Therefore, the
standard "do_this() or die" convention does not apply. You must
instead use a non-intuitive "do_this() and die".
Paul Lalli
------------------------------
Date: Wed, 18 Oct 2006 16:45:21 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Inappropriate ioctl for device using system("useradd")
Message-Id: <BSsZg.27768$P7.18320@edtnps89>
samasama wrote:
> My line of code is simply...
>
> system("/usr/sbin/useradd $luser -M -n -c '$opts[4]' -d $opts[5] -s
> $opts[6]") || die "Useradd : $!\n";
>
> and dying with:
> Useradd : Inappropriate ioctl for device
>
> I haven't a clue : )
>
> Running CentOS, 4.4 up to date.
>
> Any help is vastly appreciated.
Start by reading the documentation for the function and variable you are using:
perldoc -f system
perldoc perlvar
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Wed, 18 Oct 2006 16:36:00 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Inspecting the ''number' of /g match count
Message-Id: <eh5edl$2li$1@mlucom4.urz.uni-halle.de>
Hi,
on some occasions, I'm puzzled by some
inconvenience regarding multiple matches
in Perl (in contrast to multiple substi-
tutions). Consider:
use strict;
use warnings;
my $s = 'dodo dada dudu dede dada didi dada dumm';
my $n1 = $s =~ /dada/g;
print "$n1\n";
my $n2 = @{[ $s =~ /dada/g ]};
print "$n2\n";
my $n3; ++$n3 while $s =~ /dada/g;
print "$n3\n";
My point is here, we have ...
#1 - naive try, in the spirit of substitutions, of course fails here,
#2 - another one, pull up the match results into array and count - fails too,
#3 - do it 'the Fortran' way, works
How do you do in such cases?
Regards
Mirco
------------------------------
Date: 18 Oct 2006 08:07:47 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Inspecting the ''number' of /g match count
Message-Id: <1161184067.919626.230270@i3g2000cwc.googlegroups.com>
Mirco Wahab wrote:
> on some occasions, I'm puzzled by some
> inconvenience regarding multiple matches
> in Perl (in contrast to multiple substi-
> tutions). Consider:
>
> use strict;
> use warnings;
>
> my $s = 'dodo dada dudu dede dada didi dada dumm';
>
> my $n1 = $s =~ /dada/g;
> print "$n1\n";
>
> my $n2 = @{[ $s =~ /dada/g ]};
> print "$n2\n";
>
> my $n3; ++$n3 while $s =~ /dada/g;
> print "$n3\n";
>
> My point is here, we have ...
> #1 - naive try, in the spirit of substitutions, of course fails here,
> #2 - another one, pull up the match results into array and count - fails too,
> #3 - do it 'the Fortran' way, works
>
> How do you do in such cases?
There's an even uglier method, that is apparently a defacto idiom:
my $n4 = () = $s =~ /dada/g;
The empty list produces a list assignment, which means the pattern
match is evaluated in list context. In list context, a pattern match
with the /g modifier returns a list of all matches. That list
assignment is then evaluated in a scalar context. A list assignment in
scalar context returns the number of items assigned.
The simple truth is that there's not often a real need for this in any
"real" code I write. Rarely do I need to know how many matches there
are. I either need to do_something() while there is another match, or
I need to change all matches to something else. For that reason, the
fact that all of these methods are ugly as sin doesn't bother me too
much.
Paul Lalli
------------------------------
Date: 18 Oct 2006 08:45:52 -0700
From: greg.ferguson@icrossing.com
Subject: Re: Inspecting the ''number' of /g match count
Message-Id: <1161186352.170958.68950@i3g2000cwc.googlegroups.com>
Mirco Wahab wrote:
[...]
> My point is here, we have ...
> #1 - naive try, in the spirit of substitutions, of course fails here,
> #2 - another one, pull up the match results into array and count - fails too,
> #3 - do it 'the Fortran' way, works
>
> How do you do in such cases?
This looks like one of those "getting bit in the *ss by a
type-conversion" things.
I use the method in Perl FAQ #4, "How can I count the number of
occurrences of a substring within a string?", which says...
Another version uses a global match in list context, then assigns the
result to a scalar, producing a count of the number of matches.
$count = () = $string =~ /-\d+/g;
------------------------------
Date: 18 Oct 2006 18:08:27 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Inspecting the ''number' of /g match count
Message-Id: <a3kcj2d2mr51impmjrjavm8bqcj2bahcb2@4ax.com>
On Wed, 18 Oct 2006 16:36:00 +0200, Mirco Wahab
<wahab@chemie.uni-halle.de> wrote:
>on some occasions, I'm puzzled by some
>inconvenience regarding multiple matches
>in Perl (in contrast to multiple substi-
>tutions). Consider:
[snip]
>How do you do in such cases?
Point is, you want the match in list context, but then you want to
ignore the list and just evaluate it in scalar context just for the.
The "goatse" operator is there exactly for this purpose, although it
doesn't really exist:
my $count =()= 'foo' =~ /./g;
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Wed, 18 Oct 2006 16:48:54 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Inspecting the ''number' of /g match count
Message-Id: <WVsZg.27769$P7.17340@edtnps89>
Mirco Wahab wrote:
>
> on some occasions, I'm puzzled by some
> inconvenience regarding multiple matches
> in Perl (in contrast to multiple substi-
> tutions). Consider:
>
> use strict;
> use warnings;
>
> my $s = 'dodo dada dudu dede dada didi dada dumm';
>
> my $n1 = $s =~ /dada/g;
> print "$n1\n";
>
> my $n2 = @{[ $s =~ /dada/g ]};
> print "$n2\n";
>
> my $n3; ++$n3 while $s =~ /dada/g;
> print "$n3\n";
>
> My point is here, we have ...
> #1 - naive try, in the spirit of substitutions, of course fails here,
> #2 - another one, pull up the match results into array and count - fails too,
$ perl -le'
my $s = q/dodo dada dudu dede dada didi dada dumm/;
my $n2 = @{[ $s =~ /dada/g ]};
print $n2;
'
3
How is that failing?
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Wed, 18 Oct 2006 19:17:27 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Inspecting the ''number' of /g match count
Message-Id: <eh5nsb$5d5$1@mlucom4.urz.uni-halle.de>
Thus spoke John W. Krahn (on 2006-10-18 18:48):
> Mirco Wahab wrote:
>> My point is here, we have ...
>> #1 - naive try, in the spirit of substitutions, of course fails here,
>> #2 - another one, pull up the match results into array and count - fails too,
>
> $ perl -le'
> my $s = q/dodo dada dudu dede dada didi dada dumm/;
> my $n2 = @{[ $s =~ /dada/g ]};
> print $n2;
> '
> 3
>
> How is that failing?
I didn't pos($s) = 0, therefore missed the
first 'dada' which was already behind pos.
Otherwise, that approach would be perfectly
fine - except for cases with 10^6 match
strings - like DNA analysis.
Regards,
Mirco
------------------------------
Date: 18 Oct 2006 09:50:29 -0700
From: "fritz-bayer@web.de" <fritz-bayer@web.de>
Subject: Matching umlauts
Message-Id: <1161190229.732550.298770@b28g2000cwb.googlegroups.com>
Hi,
I have to match words, which contains umlauts like =E4=F6=FC and also
french and other ones.
Is there a way to use regular expressions in such a way that those get
treated like their normal corresponding letters?
In other words, that "M=FCnchen" =3D "Munchen" when I do a pattern match
with =3D~ ?
Of course I could do all kinds of workarounds, but since there are many
of those characters, even from other countries, I was wondering if
there is some option, which will turn this on/off.
Something like the "-i" switch for case in/sensitive searches.
Fritz
------------------------------
Date: 18 Oct 2006 10:26:51 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Matching umlauts
Message-Id: <1161192411.384669.177460@m7g2000cwm.googlegroups.com>
fritz-bayer@web.de wrote:
> I have to match words, which contains umlauts like =E4=F6=FC and also
> french and other ones.
>
> Is there a way to use regular expressions in such a way that those get
> treated like their normal corresponding letters?
>
> In other words, that "M=FCnchen" =3D "Munchen" when I do a pattern match
> with =3D~ ?
It is, in general, a really bad idea to simply pretend that one letter
is another. For an very basic example, the Spanish word "s=ED" means
"yes", while the Spanish word "si" means "if". They are different
letters, and should be treated as such.
However, I don't think that's your actual question. I think what you
really want is to know if there's a way to make regexp special
characters like \w expand its notion of what a "letter" is. And the
answer to that is "yes". Simply enable locales in your script.
perldoc perllocale
perldoc locale
> Of course I could do all kinds of workarounds, but since there are many
> of those characters, even from other countries, I was wondering if
> there is some option, which will turn this on/off.
>
> Something like the "-i" switch for case in/sensitive searches.
#!/opt2/perl/bin/perl
use strict;
use warnings;
use locale;
use POSIX qw(locale_h);
$_ =3D "S=ED se=F1or!";
print "Before locale in effect:\n";
print "$1\n" while /(\w+)/g;
setlocale(LC_CTYPE, "es_MX.ISO8859-1");
print "After locale in effect:\n";
print "$1\n" while /(\w+)/g;
__END__
Before locale in effect:
S
se
or
After locale in effect:
S=ED
se=F1or
Paul Lalli
------------------------------
Date: Wed, 18 Oct 2006 16:09:04 +0100
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: modify posting guidelines to allow MIME charset=utf8
Message-Id: <g694pu1oe3z.fsf@lifelogs.com>
On 17 Oct 2006, merlyn@stonehenge.com wrote:
>>>>>> "Mumia" == Mumia W (reading news) <paduille.4060.mumia.w@earthlink.net>
>>>>>> writes:
>
> Mumia> Allowing UTF8 with the proper content-transfer encoding gets my vote
> too.
>
> An individual group cannot vote on this. This is a news.admin-level problem,
> and the news-admins must be involved.
The posting guidelines are not maintained by news admins, as far as I
know. MIME is already allowed in this newsgroup (the postings that
come through every day are evidence of that). The request, as stated
in the subject, is to modify the posting guidelines, not anything
about the newsgroup at the server level.
What do the news admins have to do?
> Otherwise, it's like a group of inmates "voting" to be allowed to run
> outside the walls for 30 minutes a day. It's pointless.
Usenet is not a prison. comp.lang.perl.misc is not even moderated.
Can you explain your analogy a little bit?
Ted
------------------------------
Date: 18 Oct 2006 08:58:48 -0700
From: "banker123" <bradbrockman@yahoo.com>
Subject: Perl and Dos Batch File Create
Message-Id: <1161187128.753413.28270@f16g2000cwb.googlegroups.com>
I am new to Perl and I am trying to use Perl to complete this task.
I have a source file that list the parameter that needs to be inserted
into a batch file, as shown below the parameter needs to be inserted
after JFCLIENT.EXE/f=********* followed by /n=001 the parameter is the
second column in my tab delimited file. The first column is the name
that should be used for the batch file (06712305.bat=06712305
parameter, 06712305CO.bat=KCM parameter)
Output File 1 (Filename 06712305.bat)
\\CPC06LBA03S\APPS\FORMWARE\PROGRAMS\JFCLIENT.EXE /f=06712305 /n=001
Output File 2 (Filename 06712305CO.bat)
\\CPC06LBA03S\APPS\FORMWARE\PROGRAMS\JFCLIENT.EXE /f=KCM /n=001
Source File Tab Delimited (data.txt)
06712305 06712305
06712305CO KCM
145405 145405
What have I tried?
Since I'm fairly new this is my first real task using Perl, I
appreciate help getting started. I assume I would want to read the
parameter and the batch filename into a variable, I would want to loop
through the source file using the foreach control to insert the
parameter and create the batch file with the proper filename for each
record.
------------------------------
Date: Wed, 18 Oct 2006 12:36:51 -0500
From: David Peacock <davidjpeacock@magma.ca>
Subject: Re: Perl and Dos Batch File Create
Message-Id: <slrnejcphh.1vl.davidjpeacock@david-peacocks-computer.local>
banker123 <bradbrockman@yahoo.com> wrote:
> I am new to Perl and I am trying to use Perl to complete this task.
Welcome.
> I have a source file that list the parameter that needs to be inserted
> into a batch file, as shown below the parameter needs to be inserted
> after JFCLIENT.EXE/f=********* followed by /n=001 the parameter is the
<snip>
Thanks for the spec, it may be useful information to keep in mind when
we analyse your code.
Please post what you have tried so far and indicate which parts you
would like help with.
> Since I'm fairly new this is my first real task using Perl, I
> appreciate help getting started.
<snip>
http://learn.perl.org/ will help you get started out.
--
David Peacock - davidjpeacock@magma.ca
http://quasicanuck.blogspot.com/
------------------------------
Date: 18 Oct 2006 10:53:25 -0700
From: "banker123" <bradbrockman@yahoo.com>
Subject: Re: Perl and Dos Batch File Create
Message-Id: <1161194005.839339.285670@h48g2000cwc.googlegroups.com>
open (data, 'source data') or die ("Cannot Open");
open (test, ">test.bat") or die ("Cannot Open");
@array=<data>;
foreach $line (@array)
{
chop($line);
($rec1,$rec2,)=split(/\t/,$line);
print test "\\CPC06LBA03S\APPS\FORMWARE\PROGRAMS\JFCLIENT.EXE /f=$rec2
/n=001";
}
David Peacock wrote:
> banker123 <bradbrockman@yahoo.com> wrote:
> > I am new to Perl and I am trying to use Perl to complete this task.
>
> Welcome.
>
> > I have a source file that list the parameter that needs to be inserted
> > into a batch file, as shown below the parameter needs to be inserted
> > after JFCLIENT.EXE/f=********* followed by /n=001 the parameter is the
> <snip>
>
> Thanks for the spec, it may be useful information to keep in mind when
> we analyse your code.
>
> Please post what you have tried so far and indicate which parts you
> would like help with.
>
> > Since I'm fairly new this is my first real task using Perl, I
> > appreciate help getting started.
> <snip>
>
> http://learn.perl.org/ will help you get started out.
>
> --
> David Peacock - davidjpeacock@magma.ca
> http://quasicanuck.blogspot.com/
------------------------------
Date: Wed, 18 Oct 2006 09:16:33 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: question about cpan module
Message-Id: <m2vemhpxvy.fsf@Sherm-Pendleys-Computer.local>
"Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net> writes:
> On 10/17/2006 02:22 PM, Jialin Li wrote:
>> I am using interactive shell of cpan modules with
>> perl -MCPAN -e shell
>>
>> inside the shell, how can have the function like 'less'
>> when browsing with a,b,d,m?
>>
>> Thanks,
>> Jialin
>
> On my system, there is a ~/.cpan/CPAN/MyConfig.pm
>
> In that file, I can change the value of the 'pager' entry to whatever
> pager I want.
You could also use the 'o' command from within the CPAN shell:
o conf pager /usr/bin/less
That sets the variable for a single session, to save it permanently:
o conf commit
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 18 Oct 2006 18:13:58 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: thanks to all for "goatse =()=" (was: Inspecting the ''number' of /g match count)
Message-Id: <eh5k59$4bk$1@mlucom4.urz.uni-halle.de>
... this is what I missed so far!
Thanks
Mirco
------------------------------
Date: Wed, 18 Oct 2006 16:10:16 +0100
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: UTF-8 encoding problem
Message-Id: <g69zmbtmzhj.fsf@lifelogs.com>
On 18 Oct 2006, shreshth.luthra@gmail.com wrote:
> I am having a GUI which accepts a Unicode string and searches a given
> set of xml files for that string.
>
> Now, i have 2 XML files both of them saved in UTF-8 format, having
> characters of different language.
>
> Although both of them are having UTF-8 as BoM, but only first file is
> having UTF-8 defined in XML declration at the top of the XML file as
> well.
>
> Now, when i search for some different langauge character in that
> directory using a third party GUI for desktop search, it shows that the
> charcter exist in the first file (in which XML declation was also
> there), but not in the second file (having only BoM)
>
> Initilally i thought that the problem is mainly because of UTF-8 being
> supporting both MultiBye and Unicode, but could not find much on it,
> because both of them had the same contents when opened in Binary mode
> (Except for XML Declaration in 1 of them)
We'd love to help. Can you explain what your Perl question is?
Ted
------------------------------
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 V10 Issue 9863
***************************************