Ask a Question related to PERL Miscellaneous, Design and Development.
-
Purl Gurl #1
Array Sort Using Regex Matching Fails
Over the years, I have periodically played with this
syntax of regex matching within an array sort. I have
tried a lot of syntax changes.
Never works.
During testing, I have found a substitution operator
does work inside an array sort but does not afford
expected sorted results.
Substring works great within an array sort.
Anyone know why regex matching does not work
within an array sort? Any hacks to enable this?
My opinion is regex matching inside an array sort
would be a very useful feature.
My example attempts to sort on alphabetical letters.
Purl Gurl
--
#!perl
@Array = ("12 ghi 34", "12 def 34", "12 abc 34");
@Array = sort
{
$a =~ /[a-z]+/ cmp $b =~ /[a-z]+/
}
@Array;
$, = "\n";
print @Array;
Purl Gurl Guest
-
Regex for matching a string not in a URL
Returning text from a database...want to find and replace any matching keyword, with a string but ONLY if the keyword DOES NOT reside as part of a... -
array elements matching object properties ?
I'm trying to sort out an application where I need create a conditional statement that matches elements of an array and properties of several... -
REGEX: matching AFTER a specific character
Hi all, Here is a code snippet, and yes I am going to use File::Basename to strip the file path/filename once I've stripped the entire path from... -
Matching array index to values retrieved from database
Hello friends, I have this dynamic array(shown below) that I need to match to values (1 - 10) that I am returning from the database via DSN... -
Finding the non-matching values collection/array
Hi all, Ok, lets say I have the following, Request.Form collection which produces this (as the element names) a b c d -
Uri Guttman #2
Re: Array Sort Using Regex Matching Fails
>>>>> "PG" == Purl Gurl <purlgurl@purlgurl.net> writes:
PG> Never works.
like most of your code.
PG> During testing, I have found a substitution operator
PG> does work inside an array sort but does not afford
PG> expected sorted results.
if it works then why do you complain it doesn't work? typical moronzilla
illogic.
PG> Anyone know why regex matching does not work
PG> within an array sort? Any hacks to enable this?
you need a brain hack. or a brain of any sort. try a nematode first. the
small incremental improvement won't be such a shock. then you can
graduate to segmented worm brains.
PG> My opinion is regex matching inside an array sort
PG> would be a very useful feature.
my opinion is that you should learn to program somewhere else and in
another language.
PG> @Array = ("12 ghi 34", "12 def 34", "12 abc 34");
PG> @Array = sort
PG> {
PG> $a =~ /[a-z]+/ cmp $b =~ /[a-z]+/
HAHAHAHA!!!!
that is such a laugh. i won't help because it is too funny to write out
an answer. of course you will say i don't know the answer but i
do. hint: ever rtfm about context and return values?
PG> print @Array;
where is your usual html header crap?
learn python already. they will love you and you them.
uri
--
Uri Guttman ------ [email]uri@stemsystems.com[/email] -------- [url]http://www.stemsystems.com[/url]
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url]
Damian Conway Class in Boston - Sept 2003 -- [url]http://www.stemsystems.com/class[/url]
Uri Guttman Guest
-
Purl Gurl #3
Re: Array Sort Using Regex Matching Fails
Greg Bacon wrote:
> Purl Gurl wrote:> : @Array = sort { $a =~ /[a-z]+/ cmp $b =~ /[a-z]+/ } @Array;It is impossible for you to know what feelings Randal holds> Is there a reason other than the mutual disdain you and Randal hold
> for one another
for me nor what feelings I hold for Randal.
Randal did invite me to have lunch with him. Randal and I do
treat each other well within civilized expectations and both
of us almost always avoid sensitive topics which would cause
disruption of this newsgroup.
Nonetheless, your comments are of a personal nature and have
no place in a newsgroup. Quite frankly, matters of this nature
are simply none of your business.
My objective is to learn and develop new techniques which> that you wouldn't just use the Schwartzian Transform?
I almost always share with our Perl community.
What is your obvious objective?
Purl Gurl
Purl Gurl Guest
-
Greg Bacon #4
Re: Array Sort Using Regex Matching Fails
In article <3F4BEC16.442CB808@purlgurl.net>,
Purl Gurl <purlgurl@purlgurl.net> wrote:
: [...]
:
: What is your obvious objective?
To understand why you'd want to regmatch more than necessary.
Yes, the ST has an overhead cost, but is perl the appropriate
tool if you're fretting about such matters?
Greg
--
The left-liberal habit is to dismiss all historical pleas for states rights
as mere excuses for racist public policies. But this only shows their lack of
appreciation for the essential role that federalism and decentralism have
played in the long struggle for freedom itself. -- Lew Rockwell
Greg Bacon Guest
-
Uri Guttman #5
Re: Array Sort Using Regex Matching Fails
>>>>> "GH" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
GH> Purl Gurl wrote:
GH> Glad to be able to help one of the most well-known Perl programmers
GH> out there. :)
s/programmers/monkey typists/
and that is insulting the chimps.
uri
--
Uri Guttman ------ [email]uri@stemsystems.com[/email] -------- [url]http://www.stemsystems.com[/url]
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url]
Damian Conway Class in Boston - Sept 2003 -- [url]http://www.stemsystems.com/class[/url]
Uri Guttman Guest
-
Purl Gurl #6
Re: Array Sort Using Regex Matching Fails
Gunnar Hjalmarsson wrote:
> Purl Gurl wrote:> > Anyone know why regex matching does not work
> > within an array sort? Any hacks to enable this?I have, many documents, many reference sources, over a long period of time.> It works fine; no hacks needed. How about studying the docs for the
> function you are trying to use?
> Just apply one of the docs examples to your example:> @Array = sort {
> ($a =~ /([a-z]+)/)[0] cmp ($b =~ /([a-z]+)/)[0]
> } @Array;> (The matches need to be evaluated in list context.)
"list context" - creating an array based on a regex match for this thread.
Yes. I should have clarified what I am trying to do.
My hopes are to avoid a list context. My fault for
not stating what is obvious in my mind, but clearly
obscured to others.
I failed to be clear, concise and coherent.
My thoughts are avoiding a list context would improve
efficiency by reducing memory and cpu usage.
Look over my example beneath my signature for better
clarity. I tried memory parentheses, with no luck,
least with an array sort. I am trying to apply this
syntax below, to an array sort, but not in a list context.
Sort example:
@Array = sort { $a =~ /([a-z]+)/ cmp $b =~ /([a-z]+)/ } @Array;
This is very similar to my print / match function far below.
Some might argue my print / match example automagically creates
an "anonymous" array with only one element. I don't know if this
is actually what happens.
I will determine if benchmark tests can be developed of "equal"
code for straight printing as in my example and printing of
an array element. My hunch is my example below will be more
efficient than creating a true array, then printing. Not so
sure "equal" code can be developed for valid testing; use
of an "invisible" array and a declared array, will certainly
skew results, to a measured degree.
Most diplomatic wording.> Glad to be able to help one of the most well-known Perl programmers
> out there. :)
Purl Gurl
--
#!perl
$string = "12 abc 34";
print $string =~ /([a-z]+)/;
PRINTED RESULTS:
________________
abc
Purl Gurl Guest
-
Benjamin Goldberg #7
Re: Array Sort Using Regex Matching Fails
Purl Gurl wrote:Then you aren't doing it right.>
> Over the years, I have periodically played with this
> syntax of regex matching within an array sort. I have
> tried a lot of syntax changes.
>
> Never works.
The return value of the substitution operator is the number of> During testing, I have found a substitution operator
> does work inside an array sort but does not afford
> expected sorted results.
substitutions done.
Well, it does assuming that you're sorting strings, not abitrary data> Substring works great within an array sort.
structures (like arrays of arrayrefs, hashrefs, scalarrefs, globrefs,
iorefs, regexen).
And, assuming that you know or can easily find the start and end offset
of the string you want within the strings you're sorting.
It works fine. Why are you asking silly questions?> Anyone know why regex matching does not work
> within an array sort?
No hack is needed. It just works.> Any hacks to enable this?
Duh.> My opinion is regex matching inside an array sort
> would be a very useful feature.
Alas, since you haven't read the documentation for how the =~ operator> My example attempts to sort on alphabetical letters.
>
> Purl Gurl
> --
> #!perl
>
> @Array = ("12 ghi 34", "12 def 34", "12 abc 34");
>
> @Array = sort
> {
> $a =~ /[a-z]+/ cmp $b =~ /[a-z]+/
> }
> @Array;
>
> $, = "\n";
>
> print @Array;
works, you don't realize that in scalar context, it's return value is
merely a boolean indicating whether or not the match succeeded, *not*
the contents of the match.
As a result of your ignorance, you've written a sorting routine that
merely puts any strings containing alphabetics after before any strings
not containing alphabetics.
If you wanted to sort based on the contents of the alphabetical portions
of the strings, then you need to either capture $1 after matching, or
else use list context.
You could have written:
@Array = sort {
my ($aletterss) = $a =~ /([a-z]+)/;
my ($bletterss) = $b =~ /([a-z]+)/;
$aletters cmp $bletters;
} @Array;
Or
@Array = sort {
($a =~ /([a-z]+)/)[0] cmp
($b =~ /([a-z]+)/)[0]
} @Array;
Or
@Array = map $$_[0],
sort { $$a[1] cmp $$b[1] }
map [ $_, /([a-z]+)/ ],
@Array;
Or:
@Array = map substr($_,index($_,"\0")+),
sort
map +( (/([a-z]+)/)[0] . "\0$_" ),
@Array;
Or:
@Array = map substr($_,index($_,"\0")+),
sort
map /([a-z]+)/ ? "$1\0$_" : "\0$_",
@Array;
Or:
@Array = map substr($_,index($_,"\0")+),
sort
map { (my $x = $_) =~ tr/a-z//cd; "$x\0$_" }
@Array;
Or:
@Array = sort {
(my $aletters = $a) =~ tr/a-z//cd;
(my $bletters = $b) =~ tr/a-z//cd;
$aletters cmp $bletters;
} @Array;
Or many other things.
[untested]
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
Benjamin Goldberg Guest
-
Benjamin Goldberg #8
Re: Array Sort Using Regex Matching Fails
Purl Gurl wrote:
[snip]>
> Gunnar Hjalmarsson wrote:
>> > Purl Gurl wrote:Don't get lists confused with arrays. They are two different things. A>> > @Array = sort {
> > ($a =~ /([a-z]+)/)[0] cmp ($b =~ /([a-z]+)/)[0]
> > } @Array;>> > (The matches need to be evaluated in list context.)
> "list context" - creating an array based on a regex match for this
> thread.
list is created here. An array is not.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
Benjamin Goldberg Guest
-
Purl Gurl #9
Re: Array Sort Using Regex Matching Fails
Greg Bacon wrote:
> Purl Gurl wrote:> : What is your obvious objective?Creating shorter more efficient regex matching does not fall> To understand why you'd want to regmatch more than necessary.
under your "...more than necessary...." definition.
Randal's method is very efficient and an example> Yes, the ST has an overhead cost, but is perl the appropriate
> tool if you're fretting about such matters?
of excellent coding. I would not say his method has
excessive overhead.
You are confusing "fretting" with "experimentation."
Many of my unique highly efficient methods, considered
heresy by doom-sayers, such as yourself, many of my
methods come about through experimentation and learning.
A good example is my much disliked array shuffle method
which is a good thirty percent more efficient than the
Fisher Yates model and creates a true chaotic shuffle
rather than attempting forced even distribution, as
with Fisher - Yates.
Some are satisfied with residing within a dogmatic rut,
others are not. I suspect Larry Wall, like myself, is
not amongst those stuck in a rut.
Do you have an objective other than promulgating Perl dogma?
The Dark Ages are long past, Mr. Bacon.
Purl Gurl
Purl Gurl Guest
-
Purl Gurl #10
Re: Array Sort Using Regex Matching Fails
Benjamin Goldberg wrote:
(snipped)> Purl Gurl wrote:
I am sure others, specifically boys, are impressed> Or many other things.
with your copious length.
However, you are carefully avoiding my article topic
via verbose ramblings seen by some as "macho."
Purl Gurl
Purl Gurl Guest
-
Purl Gurl #11
Re: Array Sort Using Regex Matching Fails
Benjamin Goldberg wrote:
(snipped)> Purl Gurl wrote:> > Gunnar Hjalmarsson wrote:> > > Purl Gurl wrote:
> > > @Array = sort {
> > > ($a =~ /([a-z]+)/)[0] cmp ($b =~ /([a-z]+)/)[0]
> > > } @Array;> > > (The matches need to be evaluated in list context.)> > "list context" - creating an array based on a regex match for this
> > thread.I don't factually know this. Access in the above example> Don't get lists confused with arrays. They are two different things. A
> list is created here. An array is not.
is via an array element reference, is it not? This suggests
to me memory storage and cpu processing, treat this as an array.
Remove the array element reference [0] and what happens?
print $string =~ /([a-z]+)/;
.... sort { $a =~ /([a-z]+)/ cmp
.... sort { ($a =~ /([a-z]+)/)[0] cmp
First two syntax are very similar; function / regex
Your "list context" third syntax is radically different.
Purl Gurl
Purl Gurl Guest
-
Gunnar Hjalmarsson #12
Re: Array Sort Using Regex Matching Fails
Purl Gurl wrote:
Maybe it does. But it also makes the code do something else but what> Gunnar Hjalmarsson wrote:>>>(The matches need to be evaluated in list context.)
> My thoughts are avoiding a list context would improve
> efficiency by reducing memory and cpu usage.
you want it to do, so it's not particularly _effective_.
No it's not. The above matches are evaluated in scalar context, while> I am trying to apply this
> syntax below, to an array sort, but not in a list context.
>
> Sort example:
>
> @Array = sort { $a =~ /([a-z]+)/ cmp $b =~ /([a-z]+)/ } @Array;
>
> This is very similar to my print / match function far below.
the print function enforces list context.
Sure. From perldoc -f print:> $string = "12 abc 34";
> print $string =~ /([a-z]+)/;
>
> PRINTED RESULTS:
> ________________
>
> abc
"Because print takes a LIST, anything in the LIST is evaluated in list
context..."
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
Purl Gurl #13
Re: Array Sort Using Regex Matching Fails
Purl Gurl wrote:
(snipped)> Gunnar Hjalmarsson wrote:> > Purl Gurl wrote:
> > > Anyone know why regex matching does not work
> > > within an array sort? Any hacks to enable this?> My thoughts are avoiding a list context would improve
> efficiency by reducing memory and cpu usage.> Sort example:> @Array = sort { $a =~ /([a-z]+)/ cmp $b =~ /([a-z]+)/ } @Array;
Here is an example of regex substitution working within
an array sort. This does not enhance sorting, certainly.
Quite the opposite, it kills sorting.
However, this does indicate a regex engine, along with
substitution, can be invoked within an array sort, much
like substring and "list context" discussed.
So, regex substitution works, regex matching does not.
Do you see both the logic and irony of this? Might be
a regex substitution works, purely by accident, when
it really should not work at all, as with regex matching.
I have hopes perhaps there is a hack which will invoke
a regex match correctly.
Purl Gurl
--
#!perl
@Array = ("56 abc 78", "12 def 34");
@Array = sort
{
$a =~ s/[a-z]+// cmp $b =~ s/[a-z]+//
}
@Array;
$, = "\n";
print @Array;
PRINTED RESULTS:
________________
56 78
12 34
Purl Gurl Guest
-
Purl Gurl #14
Re: Array Sort Using Regex Matching Fails
Gunnar Hjalmarsson wrote:
> Purl Gurl wrote:> > Gunnar Hjalmarsson wrote:> >>(The matches need to be evaluated in list context.)> > My thoughts are avoiding a list context would improve
> > efficiency by reducing memory and cpu usage.> > Sort example:> > @Array = sort { $a =~ /([a-z]+)/ cmp $b =~ /([a-z]+)/ } @Array;> > This is very similar to my print / match function far below.> > $string = "12 abc 34";
> > print $string =~ /([a-z]+)/;> > PRINTED RESULTS:
> > ________________> > abc> Sure. From perldoc -f print:However, a print "list context" does not require an array element> "Because print takes a LIST, anything in the LIST is evaluated in list
> context..."
reference as does an array sort. Do you see this distinctive difference?
An array sort using regex matching requires [n] element referencing.
Print, doesn't care at all.
An intermediate step to more efficient code, would be to
eliminate this need for [n] element indexing in a sort.
If removed though, the sort completely fails.
Element indexing is not needed for print.
Element indexing is needed for sorting.
So, which is truly working with a list and which
is truly working with an array?
Purl Gurl
Purl Gurl Guest
-
Uri Guttman #15
Re: Array Sort Using Regex Matching Fails
>>>>> "PG" == Purl Gurl <purlgurl@purlgurl.net> writes:
PG> I don't factually know this. Access in the above example>> Don't get lists confused with arrays. They are two different things. A
>> list is created here. An array is not.
PG> is via an array element reference, is it not? This suggests
PG> to me memory storage and cpu processing, treat this as an array.
PG> Remove the array element reference [0] and what happens?
PG> print $string =~ /([a-z]+)/;
PG> ... sort { $a =~ /([a-z]+)/ cmp
PG> ... sort { ($a =~ /([a-z]+)/)[0] cmp
PG> First two syntax are very similar; function / regex
PG> Your "list context" third syntax is radically different.
as usual you have no grasp on a major perl feature. stop you blathering
already. lists and arrays are not the same thing in perl. a list is
temporary to a single expression and lives on the stack. an array is
created on the heap and can live beyond the current expression. now can
you apply your simian language comprehension skills to that?
i wait to see the idiotic followup.
and this post was for those who follow threads or google and think
moronzilla knows any perl.
uri
--
Uri Guttman ------ [email]uri@stemsystems.com[/email] -------- [url]http://www.stemsystems.com[/url]
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url]
Damian Conway Class in Boston - Sept 2003 -- [url]http://www.stemsystems.com/class[/url]
Uri Guttman Guest
-
Gunnar Hjalmarsson #16
Re: Array Sort Using Regex Matching Fails
Purl Gurl wrote:
Yes, the elements are printed in the original order. What are you> So, regex substitution works, regex matching does not.
> Do you see both the logic and irony of this? Might be
> a regex substitution works, purely by accident, when
> it really should not work at all, as with regex matching.
>
> @Array = ("56 abc 78", "12 def 34");
> @Array = sort {
> $a =~ s/[a-z]+// cmp $b =~ s/[a-z]+//
> } @Array;
>
> $, = "\n";
> print @Array;
>
> PRINTED RESULTS:
> ________________
>
> 56 78
> 12 34
trying to prove? I hope that you are not seriously claiming that the
above sort function changes anything.
Try to start with:
@Array = ("12 def 34", "56 abc 78");
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
Purl Gurl #17
Re: Array Sort Using Regex Matching Fails
Gunnar Hjalmarsson wrote:
> Purl Gurl wrote:> > So, regex substitution works, regex matching does not.
> > Do you see both the logic and irony of this? Might be
> > a regex substitution works, purely by accident, when
> > it really should not work at all, as with regex matching.> > @Array = ("56 abc 78", "12 def 34");
> > @Array = sort {
> > $a =~ s/[a-z]+// cmp $b =~ s/[a-z]+//
> > } @Array;> > $, = "\n";
> > print @Array;> > PRINTED RESULTS:
> > ________________> > 56 78
> > 12 34As expected because sorting is defeated by invalid syntax,> Yes, the elements are printed in the original order.
or I should say my "sort criteria" ($a and $b) are ruined
by the regex substitution although no fatal error is present.
This appears to be another of those cases where odd syntax
is not fatal but does not produce anticipated output.
Not trying to prove anything. My example simply demonstrates> What are you trying to prove?
it is possible to invoke a regex engine within a sort. My
logic is if you can invoke a regex engine for substitution,
perhaps there is a chance you can invoke a regex engine
for regex matching.
I have made no such claim. I have asked if any know of> I hope that you are not seriously claiming that the
> above sort function changes anything.
a hack to invoke regex matching within an array sort,
but not in the usual "list / array" context.
A lot of syntax can be used, which should work, except
perl core cops a fatal error message about attempting
to modify "cmp" in a sort, otherwords, $a and $b variables.
I found $a and $b are loosely analogous to Perl's $_ variable
but are read only variables. If this read only status could
be removed, then regex matching could work, I believe.
Again, what I am asking help on is a hack to invoke regex
matching in an array sort, knowing perl core's regex engine
can be invoked.
All others here, with your exception, are stuck on typical
Perl dogma and are not willing to address this issue, even
if it cannot be done.
Contrasting this, these others, should one of them come up
with a hack for whatever, be sure he would be bragging all
over himself, free of troll responses.
So far, short of your responses, all others have typically
responded with troll articles and childish insults.
Should I change my moniker to "Hudson" there is no doubt
there would be a flood of articles for weeks, in response
to my article.
pffttt...
Thanks for your intelligent well meaning input. Yours are
rather refreshing.
Purl Gurl
Purl Gurl Guest
-
Purl Gurl #18
Re: Array Sort Using Regex Matching Fails
Purl Gurl wrote:
(snipped)> Purl Gurl wrote:> > Gunnar Hjalmarsson wrote:> > > Purl Gurl wrote:
> Here is an example of regex substitution working within
> an array sort. This does not enhance sorting, certainly.
> Quite the opposite, it kills sorting.> So, regex substitution works, regex matching does not.> @Array = ("56 abc 78", "12 def 34");> @Array = sort
> {
> $a =~ s/[a-z]+// cmp $b =~ s/[a-z]+//
> }
> @Array;> PRINTED RESULTS:
> ________________> 56 78
> 12 34
Returning to this to finalize this thread, should you
try to directly modify variables $a and $b, such as,
$a = (some taboo code or value) cmp $b = (some taboo code or value)
doing so will invoke a fatal syntax error, this is,
an attempt to modify a read only variable.
Use of substitution clearly modifies variables $a and $b
but does not invoke a fatal syntax error. More precisely,
each element of the array to be sorted, is modified in
memory via variables $a and $b which, for this case, behave
as $_ would, then sorting takes (does not take) place.
This read only status of $a and $b is defeated and should
not be.
A regex engine is correctly invoked and modification occurs
for regex substitution.
A regex engine appears to not be invoked for regex matching.
Clearly there is a contradiction in perl core pertaining
to regexes in general. You are not to modify default
variables, but can with regex substitution, but are not
allowed to regex match, which does not modify $a and $b.
Purl Gurl
Purl Gurl Guest
-
Uri Guttman #19
Re: Array Sort Using Regex Matching Fails
>>>>> "PG" == Purl Gurl <purlgurl@purlgurl.net> writes:
PG> Gunnar Hjalmarsson wrote:PG> As expected because sorting is defeated by invalid syntax,>> Purl Gurl wrote:
PG> or I should say my "sort criteria" ($a and $b) are ruined
PG> by the regex substitution although no fatal error is present.
PG> This appears to be another of those cases where odd syntax
PG> is not fatal but does not produce anticipated output.
typical moronzilla confusion over syntax vs semantics. the syntax was
perfectly fine as perl compiled her crap. but her knowledge of semantics
is faulty and she blames perl. this is fun!
PG> Not trying to prove anything. My example simply demonstrates
PG> it is possible to invoke a regex engine within a sort. My
PG> logic is if you can invoke a regex engine for substitution,
PG> perhaps there is a chance you can invoke a regex engine
PG> for regex matching.
again, no clue. ANY code can be run via sort since it is passed a CODE
BLOCK, you blockhead! there is NO RESTRICTION there. now semantically,
you should handle the sort pairs properly and return something
meaningful to sort. but your COMPREHENSION of the docs is truly abyssmal
as usual.
PG> I have made no such claim. I have asked if any know of
PG> a hack to invoke regex matching within an array sort,
PG> but not in the usual "list / array" context.
there is no array context. and you don't understand how perl uses
regexes. try reading perlretut and perlrequick and a grade school
english book. or even try PERL ON PHONICS to improve your doc reading
skills. no wonder you always use substr and index, you are too scared
and dumb to use regexes.
PG> A lot of syntax can be used, which should work, except
PG> perl core cops a fatal error message about attempting
PG> to modify "cmp" in a sort, otherwords, $a and $b variables.
huh? cmp is an operator. no way perl can generate an error that says
"can't modify operator 'cmp'". more gibberish from our famous orater.
PG> I found $a and $b are loosely analogous to Perl's $_ variable
PG> but are read only variables. If this read only status could
PG> be removed, then regex matching could work, I believe.
no, you don't get it. you will never get it. so skip regexes. they are
too hard for you. in fact all of perl is too hard. go learn python or
basic already.
PG> Again, what I am asking help on is a hack to invoke regex
PG> matching in an array sort, knowing perl core's regex engine
PG> can be invoked.
how do we invoke the rusty engine in your thick skull? it is more
corroded than the tin man.
PG> All others here, with your exception, are stuck on typical
PG> Perl dogma and are not willing to address this issue, even
PG> if it cannot be done.
heheh. it can be done fine. you just don't understand context, regexes,
the m/// operator, cmp or sort blocks. quite a large hunk of perl.
PG> Contrasting this, these others, should one of them come up
PG> with a hack for whatever, be sure he would be bragging all
PG> over himself, free of troll responses.
try reading my sort paper if you dare. plenty of non-hacks that do all
kinds of things with sort. and before you blather on, it won the best
tech paper at the 3rd perl conference. so larry wall and others actually
think it is a quality paper on sorting in perl. so i must know
something, eh?
PG> So far, short of your responses, all others have typically
PG> responded with troll articles and childish insults.
[url]http://sysarch.com/perl/sort_paper.html[/url]
a real troll article for you. i triple dog dare you to read it. and
let's see your blatherings on it. but you won't even look at
it. remember, your sacred larry chose it as best. so does he know
anything about perl and sorting?
PG> Should I change my moniker to "Hudson" there is no doubt
PG> there would be a flood of articles for weeks, in response
PG> to my article.
nah, hudson was a little kid who didn't know better but can grow out of
it.. you are a moron who will stay that way.
uri
--
Uri Guttman ------ [email]uri@stemsystems.com[/email] -------- [url]http://www.stemsystems.com[/url]
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url]
Damian Conway Class in Boston - Sept 2003 -- [url]http://www.stemsystems.com/class[/url]
Uri Guttman Guest
-
Uri Guttman #20
Re: Array Sort Using Regex Matching Fails
>>>>> "PG" == Purl Gurl <purlgurl@purlgurl.net> writes:
PG> A regex engine is correctly invoked and modification occurs
PG> for regex substitution.
PG> A regex engine appears to not be invoked for regex matching.
PG> Clearly there is a contradiction in perl core pertaining
PG> to regexes in general. You are not to modify default
PG> variables, but can with regex substitution, but are not
PG> allowed to regex match, which does not modify $a and $b.
and the sun is orbiting around the earth and the moon is made of green
cheese and if you sail too far you fall off the earth.
you have no clue about this whatsoever. it is amazing how stupid your
blathering sounds. why don't you just 'fix' this problem in perl's core
and submit a patch to p5p? oh, you don't know c. then learn it. and
waste their time.
uri
--
Uri Guttman ------ [email]uri@stemsystems.com[/email] -------- [url]http://www.stemsystems.com[/url]
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- [url]http://jobs.perl.org[/url]
Damian Conway Class in Boston - Sept 2003 -- [url]http://www.stemsystems.com/class[/url]
Uri Guttman Guest



Reply With Quote

