Professional Web Applications Themes

substitution and assignment fun ( was Becoming Disenheartened ) - PERL Beginners

  code:  i always had trouble doing this in perl- just worked around it- then realized that this shouldn't be hard when reading your post... so i played... $s = "I am Perl guru"; $new_s = ($s =~ s/erl/ython/); print "$s \t $new_s \n"; #oops! Prints I am a Python guru 1" #but.... ($new_s = $s) =~ s/erl/ython/; print "$s \t $new_s \n"; #prints I am a Perl guru I am a Python guru Perl can be surprisingly intuitive- using precedence rules to get this done makes good sense to me :)   *shrug* eh- go figure willy http://www.hackswell.com/corenth...

  1. #1

    Default substitution and assignment fun ( was RE: Becoming Disenheartened )


     
    code: 


    i always had trouble doing this in perl- just worked around it- then
    realized that this shouldn't be hard when reading your post... so i
    played...

    $s = "I am Perl guru";

    $new_s = ($s =~ s/erl/ython/);

    print "$s \t $new_s \n"; #oops! Prints I am a Python guru
    1"

    #but....

    ($new_s = $s) =~ s/erl/ython/;
    print "$s \t $new_s \n";

    #prints I am a Perl guru I am a Python guru


    Perl can be surprisingly intuitive- using precedence rules to get this
    done makes good sense to me :)



     


    *shrug* eh- go figure



    willy
    http://www.hackswell.com/corenth
    William Guest

  2. #2

    Default Re: substitution and assignment fun ( was RE: Becoming Disenheartened)

    No doubt please, I know about regular expressions and Python/Ruby
    support them fully. I only showed the approach of method calling. There
    could be not "replace" method.

    William M West wrote: 
    >
    > code:

    >
    >
    >
    > i always had trouble doing this in perl- just worked around it- then
    > realized that this shouldn't be hard when reading your post... so i
    > played...
    >
    > $s = "I am Perl guru";
    >
    > $new_s = ($s =~ s/erl/ython/);
    >
    > print "$s \t $new_s \n"; #oops! Prints I am a Python guru
    > 1"
    >
    > #but....
    >
    > ($new_s = $s) =~ s/erl/ython/;
    > print "$s \t $new_s \n";
    >
    > #prints I am a Perl guru I am a Python guru
    >
    >
    > Perl can be surprisingly intuitive- using precedence rules to get this
    > done makes good sense to me :)
    >
    >
    >
    >

    >
    >
    >
    > *shrug* eh- go figure
    >
    >
    >
    > willy
    > http://www.hackswell.com/corenth[/ref]
    Nicolay Guest

  3. #3

    Default Re: substitution and assignment fun ( was RE: Becoming Disenheartened)

    On Fri, 1 Oct 2004, Nicolay A. Vasiliev wrote:
     

    You're arguing about semantics, but you concede that the functionality
    you're describing exists just as succinctly in both languages.

    So, again -- so what ? It's a difference without a distinction.

    Python & Ruby implement these operations with a .method() syntax.

    Perl generally implements them with a function() syntax.

    The two sides are far more similar than different. Who cares?



    --
    Chris Devers
    Chris Guest

Similar Threads

  1. Replies: 43
    Last Post: October 1st, 09:26 PM
  2. Replies: 2
    Last Post: October 1st, 11:07 AM
  3. Replies: 5
    Last Post: September 29th, 03:17 PM
  4. substitution
    By Olivier in forum PERL Beginners
    Replies: 5
    Last Post: February 24th, 05:16 PM
  5. Regarding substitution
    By Visu in forum PERL Beginners
    Replies: 2
    Last Post: August 10th, 05:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139