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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



Laurent_R
Veteran / Moderator

May 25, 2013, 4:32 AM


Views: 701
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:


Code
FullName


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


Code
#!/usr/bin/perl 
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