Aloha Monks,

I am extremly new to perl. My second script. I have written a script to collect four pieces of data and write it to a file. I have then been able to open the file and read the data as an array.

What I would like to know is there a more fexible way in calling the data, so it can be manipulated in layout. I was thinking $variable($count) with a for loop with the size of the array/4 or am I way off base?

I have used strict, and still don't realize what it does, but many people think it is important habit to get into so I'm trying.

Also newline \n doesn't work! Mac OS X Apache BBEdit Adobe GoLive.

Mahalo JW Guillaume

#!/usr/bin/perl -Tw use strict; use CGI qw(:standard); print "Content-Type: text/html\n\n"; ##################################### my $employee=param('employee_name'); my $i=""; my $t=""; my @data=""; my $items; my $lines; ##################################### # Read File # ##################################### print "Employee's name is: $employee<p\/>"; open(JOE, "<Files/$employee.txt"); @data = <JOE>; close (JOE); ##################################### # Print File # ##################################### $lines=scalar@data/4; for ($t=1; $t<=$lines; $t++) { for ($i=1; $i<=4; $i++) { $items=shift(@data); print $items; } print "there is a line break here<p\/>"; } ##################################### print "<p\/>To go Back <A HREF=\"http://127.0.0.1/\">Click here</A>"; ##################################### exit;

20050518 Janitored by Corion: Put code in code tags


In reply to Array manipulation by loop362

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.