What the text file looked like

I'll take a wild guess and say it's a pipe-delimited flat file, similar to this ;-).

If this is the case, what we need to know is what do you want to do with it?

Update: Also, are you sure the data was properly stored to begin with? Have you opened up the text file and checked if the data is both there and in the proper format?

Another Update: Based on what you posted here , the following should work:

In postit.pl...

#!/usr/bin/perl -wT use strict; use CGI; my $q = new CGI; my $name = $q->param('name'); my $surname = $q->param('surname'); my $sex = $q->param('sex'); my $age = $q->param('age'); my $string = join('|', $name, $surname, $sex, $age); open LOG, ">>messages.txt" or die "Can't open file: $!"; print LOG $string, "\n";; close LOG;

And in readit.pl...

#!/usr/bin/perl -wT use strict; open LOG, "messages.txt" or die "Can't open file: $!"; while (<LOG>) { chomp; my @attributes = split /\|/; for my $attribute (@attributes) { print $attribute, "\n"; # or do whatever here } } close LOG;

Now in postit.pl you should perform checks on the size of the parameters. You may also want to consider combining the two scripts and having separate modes (one read_data sub and one write_data sub maybe).

Yet Another Update: Guess I should explain the changes I made to your code:

Feel free to post a follow up if you have any more questions.


In reply to Re: Re: Reading data from a delimited flat file by cjf
in thread Reading data from a document.txt by Kuntent

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.