I'm not entirely sure what you mean by "It gives no effects after: ...". For instance, is $tempFile not created? If it is, then that would be an effect. Perhaps you mean $megalithFile is empty after the script completes; although, that seems unlikely unless you received some error message (which I'd also class as an effect).

NOTE: I have the first edition of "Programming the Perl DBI" (February 2000), so what I'm looking at may differ from your copy if you have a more recent edition. The while loop you show is on page 24 of my copy - you may be able to use that as a reference point.

The purpose of the examples you're referring to is to show how you could use Data::Dumper to format input records so that they may be evaled. On page 23, you'll see:

my $dumpedValues = $dumper->Dump(); ... eval $dumpedValues;

From your code above and your description of xxx.txt, you appear to be evaling the single record:

$name="MyName";$location="MyLoc";$mapRef="MyRef";$type="MyType";$descr +iption="MyDesc";

In order for

my ( $name, $location, $mapref, $type, $description ) = @$fields;

to be doing something useful, you should be evaling something that looks more like:

$fields = [ qw{name location mapref type description} ];

You appear to have removed all the comments that appear in the book. The comment regarding the eval should have provided a clue. My copy has:

### Evaluate perl record string to set $fields array reference my $fields; eval $_; die if $@;

Two paragraphs before the while loop code, my copy has:

"... use Data::Dumper to format the records ...

I suggest you try doing that.

If you're still having problems, please show your input and output within <code>...</code> tags (as opposed to a prosaic description).

-- Ken


In reply to Re: Cannot update record in file with Dump module by kcott
in thread Cannot update record in file with Dump module by perlisok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.