Results 1 to 3 of 3

Thread: Number of lines in a PERL script

  1. #1
    Junior Member
    Join Date
    Sep 2006
    Answers
    6

    Number of lines in a PERL script

    How do I check number of lines in script in PERL?

    Thanks


  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: Number of lines in a PERL script

    One fairly efficient way is to count newlines in the file.

    ----------------------
    suresh


  3. #3
    Junior Member
    Join Date
    Oct 2007
    Answers
    5

    Re: Number of lines in a PERL script

    hi

    you can add ( print __LINE__ ; ) statement at the end of your script it will display how many lines are there in the script.

    For e.g

    #!/usr/bin/perl
    use strict;

    my @array=qw(hello World Show must go on);

    my $first_str;
    my $second_str;

    my @rev_sorted=reverse( sort { lc $second_str cmp lc $first_str } @array) ;

    print "\n Rev_Sorted array:@rev_sorted";
    my $count=scalar @array;
    print "\n Count :$count";
    print "\n $array[($count/2)] \n";

    print __LINE__;

    Ans is:
    16


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact