Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Murder of a Perl coder (announced)

by Jenda (Abbot)
on Oct 14, 2004 at 20:31 UTC ( [id://399324]=note: print w/replies, xml ) Need Help??


in reply to Re: Murder of a Perl coder (announced)
in thread Murder of a Perl coder (announced)

You mean you looked at, even used the RegExps in C# and did not throw up? Man you have a good stomach!

A global match that gives you a data structure five levels deep made of five different types of objects? Replacement that's either a completely static string or a "reference to a function" (for .Net guys "a delegate") that has to be defined somewhere far off because C# doesn't support unnamed functions/blocks? I've seen several examples in C# that implemented something like s{%(\w+)%}{$hash{$1}}g;. None of them was shorter than some twenty lines and each and every one of them was ugly and hard to understand. Shame I don't have the book here.

I think that if I'll continue to be forced to "work" in C# I'll end up wrapping the real Perl regexps in a .Net class whose design might not be so "clean OO", but will be easier to use. Like I did with VB.

Jenda
We'd like to help you learn to help yourself
Look around you, all you see are sympathetic eyes
Stroll around the grounds until you feel at home
   -- P. Simon in Mrs. Robinson

Replies are listed 'Best First'.
Re^3: Murder of a Perl coder (announced)
by EdwardG (Vicar) on Oct 15, 2004 at 12:13 UTC

    Each to their own taste, but here's the contrast -

    # perl s{%(\w+)%}{$hash{$1}}g // C# Regex.Replace(s, @"%(\w+)%", new MatchEvaluator( hashLookup ) );

     

      Where's the hashLookup() defined? The Perl code was complete, the C# is far from complete.

      Jenda
      We'd like to help you learn to help yourself
      Look around you, all you see are sympathetic eyes
      Stroll around the grounds until you feel at home
         -- P. Simon in Mrs. Robinson

        If you want to argue about C# being more verbose, you win!

        But in your example %hash isn't defined (barring autoviv), so I didn't bother with hashLookup in mine. I wasn't trying to score points for brevity, if that's what matters to you.

         

Re^3: Murder of a Perl coder (announced)
by Discipulus (Canon) on Oct 15, 2004 at 08:08 UTC
    Shame on me 'cause I have forgot to thanks you Jenda!.

    Thanks for all the time you have shared your magic with me, like your funny _b_a_c_k_u_p utility, and with other monks with your inhestimable site-repository.

    cheers from roma Lor*

    PS see you on www.C#monks.org ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://399324]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2024-04-25 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found