CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [sdlan75] How to read only the first line: Edit Log

Veteran / Moderator

May 25, 2013, 4:32 AM

Views: 1781
Re: [sdlan75] How to read only the first line

This is not clear to me, it is a bit contradicory.

If you want to print only the first line of your file (as per the title of your post), you will print:


If this is what you want, you can do something like this (I have modified your code to reflect generally admitted best practices) :

use strict;
use warnings;

my ($option, $myfile) = @ARGV;

open my $INFILE, "<", $myfile or die "cannot open $myfile $!\n";
my $line = <$INFILE>;
if ($option eq "n") {
print $line;
close $INFILE;

But that is presumably not what you want.

Do you want to print the first employee (second line)? or the first field of each line? or something else? Please explain.

(This post was edited by Laurent_R on May 25, 2013, 4:55 AM)

Edit Log:
Post edited by Laurent_R (Veteran) on May 25, 2013, 4:55 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives