String concatenation qn

Ask a Question related to PERL Beginners, Design and Development.

  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. Similar Questions and Discussions

    1. string concatenation
      I want to be able to get that string #getAllCollection.itemTypeDescriptionEn# From those two strings...
    2. uninitialized string concatenation?
      Ok, this has me bewildered. I have added some fields to a pipe-delimited file and added the keys to the switch to chomp each line correctly. I am...
    3. Use of uninitialized value in concatenation (.) or string at...
      What does this mean?? I'm thoroughly puzzled and I've been scouring the net for an answer. I've been assuming it means I'm not putting strings...
    4. String Concatenation Bug
      Can anyone think of a reason why this is happening? $b = xxx //<enormously long string with at least 100000 characters> $c = yyy //<shorter...
    5. String concatenation with .= <FH>
      powell_luke@hotmail.com (Luke Powell) wrote: : I found that when I did this: : : $record .= <FH>; #replaces rather than appends to $record :...
  3. #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

  4. #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

  5. #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

  6. #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-unsubscribe@perl.org[/email]
    > For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >
    Ajey Kulkarni Guest

Posting Permissions

  • You may not post new threads
  • You may 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