in reply to Help Me!

use strict; use IO::File; my $file = new IO::File('file.txt','r') or die"Error can't open file"; foreach my $line ($file->getlines) { my ($id, $name, $major, $email) = split(',',$line); chomp $email; }

Replies are listed 'Best First'.
Re^2: Help Me!
by GrandFather (Saint) on Apr 10, 2011 at 02:24 UTC

    and that helps a Perl (and probably programming) beginner how? You've solved a problem that the OP already had code for, but increased the knowledge required to understand the solution in the process.

    True laziness is hard work
      Is there a problem to provide another solution?
      So how do you know that the later code is not easy to read and learn ?

        Swalif, your example made a lot of sense but I already did it the other way, I'm the only girl in my class and I think most of the guys are too shy to help me so thanks to everyone for the help. I played around with the code and was able to figure it out. I've programmed in Java, C++, and Visual Basics so PERL is a little different then what I'm used to. I'm sure I'll be asking for more help on later programs. :)

        The OP already had a solution that did everything your code did and more (although your list context variable initialisation was good). However the introduction of a module for trivial I/O was a major distraction. If there was a good reason for using the module you didn't provide any explanation for it nor did you say how your sample improved on what the OP already showed.

        True laziness is hard work