On Dec 5, 2003, at 9:53 AM, [EMAIL PROTECTED] wrote: [..]
I'm trying to
put together to automate some things I currently do manually.

I have a file whose format looks like this:

name1          name2          name3
name4          name5          name6, etc.

The names are separated by spaces. I need the names to be one name per
line, like this:


name1
name2
name3, etc.
[..]

Slow down, breath, one step at a time.

First off, if the file is OUTSIDE of the program
it will help to read the lines of data into your
program - so we will need something like

open(FD, $file_name) or die "unable to read file $file_name :$!";

then we can 'read the lines in'

        my @list_oh_names;
        while(<FD>)
        {
                chomp;  # take away those pesky end line
                my @tmp = split(/\s+/);
                push(@list_oh_names, @tmp);
        }
        close(<FD>);

you can then check it with

        for(0..$#list_oh_names)
        {
                print "$_ has $list_oh_names[$_]\n";
        }

Now how to get the name of the file in

my ($file_name) = @ARGV;

would be a way, but I think YOU REALLY
will want to become good friends with

Getopt::Long

be cool, impress your friends and co-workers...

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to