Professional Web Applications Themes

String concatenation qn - PERL Beginners

For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 2004 17:52 may have been monitored or recorded as: > hi,. hi > i would like to quickly append a string to a variable. > open NEWFH, "> $filename.new" or die "new procmailrc err"; > where $filename has /tmp/xyz > > Anything really silly here?? Nothing I didnt do wrong at least a thousand times: open NEWFH, "> $filename".".new" or die "new procmailrc err"; will do it. ------------ perldoc perlop: Gory details of parsing quoted constructs When presented with something that might have several dif- ferent interpretations, Perl uses ...

  1. #1

    Default Re: String concatenation qn

    For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 2004 17:52
    may have been monitored or recorded as:
    > hi,.
    hi
    > i would like to quickly append a string to a variable.
    > open NEWFH, "> $filename.new" or die "new procmailrc err";
    > where $filename has /tmp/xyz
    >
    > Anything really silly here??
    Nothing I didnt do wrong at least a thousand times:

    open NEWFH, "> $filename".".new" or die "new procmailrc err";

    will do it.
    ------------
    perldoc perlop:
    Gory details of parsing quoted constructs

    When presented with something that might have several dif-
    ferent interpretations, Perl uses the DWIM (that's "Do
    What I Mean") principle to pick the most probable inter-
    pretation. This strategy is so successful that Perl pro-
    grammers often do not suspect the ambivalence of what they
    write. But from time to time, Perl's notions differ sub-
    stantially from what the author honestly meant.
    -------------

    This is one of the latter cases.

    Wolf

    Wolf Blaum Guest

  2. #2

    Default Re: String concatenation qn

    wolf blaum wrote:
    > For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 2004 17:52
    > may have been monitored or recorded as:
    >
    >
    >>hi,.
    >
    > hi
    >
    >>i would like to quickly append a string to a variable.
    >
    >
    >>open NEWFH, "> $filename.new" or die "new procmailrc err";
    >>where $filename has /tmp/xyz
    >>
    >>Anything really silly here??
    >
    >
    > Nothing I didnt do wrong at least a thousand times:
    >
    > open NEWFH, "> $filename".".new" or die "new procmailrc err";
    >
    > will do it.
    > ------------
    > perldoc perlop:
    > Gory details of parsing quoted constructs
    >
    > When presented with something that might have several dif-
    > ferent interpretations, Perl uses the DWIM (that's "Do
    > What I Mean") principle to pick the most probable inter-
    > pretation. This strategy is so successful that Perl pro-
    > grammers often do not suspect the ambivalence of what they
    > write. But from time to time, Perl's notions differ sub-
    > stantially from what the author honestly meant.
    > -------------
    >
    > This is one of the latter cases.
    >
    > Wolf
    >
    >
    Not sure I see why adding a concatenation helped? The OP's code works
    fine in my 5.8.0 RH 9.0 install and the dot isn't significant within the
    double quotes since it isn't a property or namespace token separator
    like in other languages. Is this version dependent, or maybe UTF-8
    related?

    [url]http://danconia.org[/url]
    Wiggins D'Anconia Guest

  3. #3

    Default String concatenation qn

    hi,.
    i would like to quickly append a string to a variable.
    Suppose $filename has "/tmp/xyz after appending i want to
    get $filename as /tmp/xyz.NEW.

    I'm getting a ? for a . (period).

    I'm doing something like

    open NEWFH, "> $filename.new" or die "new procmailrc err";
    where $filename has /tmp/xyz

    Anything really silly here??

    regards
    -Ajey

    Ajey Kulkarni Guest

  4. #4

    Default Re: String concatenation qn


    On Jan 23, 2004, at 5:24 PM, wolf blaum wrote:
    > For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January
    > 2004 17:52
    > may have been monitored or recorded as:
    >
    >> i would like to quickly append a string to a variable.
    >
    >> open NEWFH, "> $filename.new" or die "new procmailrc err";
    >> where $filename has /tmp/xyz
    >>
    >> Anything really silly here??
    >
    > Nothing I didnt do wrong at least a thousand times:
    >
    > open NEWFH, "> $filename".".new" or die "new procmailrc err";
    [..]

    forgive me for being 'pedantic' but
    given the sequence

    foreach my $filename (list_of_file_names)
    {
    open(NEWFH, "> ${filename}.new" ) or die "new $filename err:$!";
    ....

    }

    One has 'less ambiguity' using the curley braces around
    the variable name so that it will KNOW without a doubt
    that one really means that to be the variable should
    suffice - It really becomes important when you want
    to concatenate without things like a "." between tokens

    foreach my $start (entree) {
    foreach my $phrase (list_of_sillies) {
    my $freak = "${start}Buzz${phrase}here";
    rhetorical_devices($freak);
    }
    }

    Drieux Guest

  5. #5

    Default Re: String concatenation qn

    Thanks a ton to all.

    On Sat, 24 Jan 2004, drieux wrote:
    >
    > On Jan 23, 2004, at 5:24 PM, wolf blaum wrote:
    >
    > > For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January
    > > 2004 17:52
    > > may have been monitored or recorded as:
    > >
    > >> i would like to quickly append a string to a variable.
    > >
    > >> open NEWFH, "> $filename.new" or die "new procmailrc err";
    > >> where $filename has /tmp/xyz
    > >>
    > >> Anything really silly here??
    > >
    > > Nothing I didnt do wrong at least a thousand times:
    > >
    > > open NEWFH, "> $filename".".new" or die "new procmailrc err";
    > [..]
    >
    > forgive me for being 'pedantic' but
    > given the sequence
    >
    > foreach my $filename (list_of_file_names)
    > {
    > open(NEWFH, "> ${filename}.new" ) or die "new $filename err:$!";
    > ....
    >
    > }
    >
    > One has 'less ambiguity' using the curley braces around
    > the variable name so that it will KNOW without a doubt
    > that one really means that to be the variable should
    > suffice - It really becomes important when you want
    > to concatenate without things like a "." between tokens
    >
    > foreach my $start (entree) {
    > foreach my $phrase (list_of_sillies) {
    > my $freak = "${start}Buzz${phrase}here";
    > rhetorical_devices($freak);
    > }
    > }
    >
    >
    > --
    > To unsubscribe, e-mail: [email]beginners-unsubscribeperl.org[/email]
    > For additional commands, e-mail: [email]beginners-helpperl.org[/email]
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >
    Ajey Kulkarni Guest

Similar Threads

  1. string concatenation
    By Rinoa in forum Macromedia ColdFusion
    Replies: 1
    Last Post: April 22nd, 01:05 PM
  2. uninitialized string concatenation?
    By Lonewolf in forum PERL Beginners
    Replies: 1
    Last Post: September 9th, 02:20 PM
  3. Replies: 5
    Last Post: September 7th, 11:02 PM
  4. String Concatenation Bug
    By ecow in forum PHP Development
    Replies: 1
    Last Post: August 18th, 02:14 AM
  5. String concatenation with .= <FH>
    By Jay Tilton in forum PERL Miscellaneous
    Replies: 3
    Last Post: July 13th, 01:53 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