Welcome to Perl jwashburn. ww already gave some good advice. I'd like to add - play. Try stuff out. Do things a little bit at a time, but each time try something new. When you run into a brick wall, come here and ask about it.

For your current problem, take it a little bit at a time. So far you have a file open, but for test purposes there is a trick you can do: include the data in the program like this:

use strict; use warnings; while (<DATA>) { chomp; print "$_\n"; } __DATA__ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* * File: G:\xcacls.txt Permissions: Type Username Permissions Inheritance + Allowed BUILTIN\Administrators Full Control This Folder Onl +y Allowed \Everyone Read and Execute This Folder Onl +y Allowed NT AUTHORITY\SYSTEM Full Control This Folder Onl +y * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* *

DATA is a magic file handle (Perl has a lot of magic) that you don't have to open and that is used to read the stuff following __DATA__ or __END__. The chomp removes the line seperator character sequence from the end of the string. In this case the string is in the default variable $_. So the script reads the data following __DATA__ a line at a time, removes the line end sequence from each line, then prints it (putting the line end sequence back in).

Now you can focus on finding stuff.

use strict; use warnings; while (<DATA>) { chomp; if (m/^File: (.*)/) { print "$1 allows:\n"; } elsif (m/^Allowed (.*)/) { print "$1\n"; } } __DATA__ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* * File: G:\xcacls.txt Permissions: Type Username Permissions Inheritance + Allowed BUILTIN\Administrators Full Control This Folder Onl +y Allowed \Everyone Read and Execute This Folder Onl +y Allowed NT AUTHORITY\SYSTEM Full Control This Folder Onl +y * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* *

The additional magic here is using if and regexes to find and extract interesting data. The ^File at the start of the regex says 'match the text File: at the start of the string. Which string? The one in the default variable $_. The (.*) is a capture match. The brackets mean 'capture whatever is matched inside the brackets'. The dot means 'match any character' (not quite the full story, but enough for now). The asterix means 'match the thing to the left as many times as possible'.

In the print the special variable $1 is used to give the stuff captured.

Ok, there's a start. The next step is to figure out what and how you want formatted using HTML and pull out the pieces, possibly using more regexs, or more likely by using substr (because the files are using fixed size fields).

After that you can put your file handling back in and print to another file rather than to the console and you should be in business.

Note that it is strongly recommended that you use the three parameter open rather than the two parameter open that you did in your sample code. THe three parameter open looks like:

open inFile, '<', 'inFileName';

It avoids various security issues and makes it clear that the file is being opened for input.


DWIM is Perl's answer to Gödel

In reply to Re: PERL newbie Cant figure out where to start by GrandFather
in thread PERL newbie Cant figure out where to start by jwashburn

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.