Hi all,

Damian Conway's "Object Oriented Perl" has been so highly praised on this 
list that I had to run out an order myself a copy.  The praise is not 
without merit -- it's a marvelous book (and readable too!!!).

On p. 28 of his review of the "essential Perl" he talks briefly about a 
hash slice, and I who have been perling since the old perl 4 days had never 
come across that capability before.  But in a piece of code I'm writing 
right now, I tried it out and I continueally get the following compile time 
error:

     Can't modify single ref constructor in scalar assignment at \
            accntREQUEST.cgi line 154, near ");"

There's always more than one way to skin a cat, and I've tried several. 
This is what I really want to accomplish:

my $colleague = {};
@{$colleague} = { "status",
                  "id",
                  "last_name",
                  "first_name",
                  "middle_name",
                  "campus",
                  "dob"
                 } = split(/:/, $record);

But, I have also tried the following, which is closer to Conway's example:

my %colleague;
@colleague{ .... } = split(/:/, $record);

And I have also created the hash and added the keys prior to attempting the 
insert.  I have even tried putting the split in an additional set of 
parentheses on the notion that maybe I had to make the list context 
explicit.

In every case, I get the error quoted above.  The only thing that changes 
is the offending line number, which is always the last line of the 
instruction.

Does his example not work, or more likely, what am I doing wrong.

-- Rob

       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)

  Rob Tanner
  McMinnville, Oregon
  [EMAIL PROTECTED]

Reply via email to