in reply to Re: Problem using transliteration to modify a variable...
in thread Problem using transliteration to modify a variable...

GrandFather wrote:

The great big fat hints you should have seen and pondered were: Use of uninitialized value in transliteration (tr///) at noname.pl lin +e 9, <DATA> line 1. Use of uninitialized value in concatenation (.) or string at noname.pl + line 10, <DATA> line 1. download Note that I used a __DATA__ (see the Special Literals sub-section) section rather than using an external file for the test code so the line numbers will differ somewhat from yours.

I, in fact, do pay attention to output when I have strictures in play. My problem is with the interpretation of much of strictures output, which I sometimes find difficult. I'm sorry, however, to have neglected to post that output... I'll do better next time.

With regard to the reference to using __DATA__ ...
I followed up with reading the recommended Special Literals sub-section. It appears to be a very useful tool for script portability and testing. Thanks, for that bit of information!

One question, though, regarding the use of __DATA__, when a script requires two or more sets of data. How would one, then, represent and call upon the subsequent sets?

Thanks, again!

  • Comment on Re^2: Problem using transliteration to modify a variable...

Replies are listed 'Best First'.
Re^3: Problem using transliteration to modify a variable...
by GrandFather (Saint) on Jul 10, 2007 at 01:41 UTC

    It depends a lot on context. You can have only one __DATA__ section, but you could put section markers in it if appropriate (your code would need to recognize them though).

    Another technique for embedding blocks of input is to use here docs (see the <<EOF section in perlop):

    use warnings; #use strict; my $text1 = <<TEXT; This is the text for \$text1. Note that multiple lines are allowed. Note too that the terminating line must exactly match the string betwe +en the << and the ; on the starting line. In particular any white space must mat +ch exactly. TEXT print $text1;

    Prints:

    This is the text for $text1. Note that multiple lines are allowed. Note too that the terminating line must exactly match the string betwe +en the << and the ; on the starting line. In particular any white space must mat +ch exactly.

    Other tricks that may help for posting questions here are discussed in I know what I mean. Why don't you?.

    Update: fixed link


    DWIM is Perl's answer to Gödel
      I'm sorry, but... "id:/510718" does not appear to contain a correct link.