Geeks Talk

Prepare for your Next Interview




Number of lines in a PERL script

This is a discussion on Number of lines in a PERL script within the PERL forums, part of the Web Development category; How do I check number of lines in script in PERL? Thanks...


Go Back   Geeks Talk > Web Development > PERL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-03-2007
Junior Member
 
Join Date: Sep 2006
Location: India
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
ksamir2004 is on a distinguished road
Number of lines in a PERL script

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

Thanks
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-17-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,007
Thanks: 0
Thanked 73 Times in 62 Posts
psuresh1982 will become famous soon enough
Re: Number of lines in a PERL script

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

----------------------
suresh
Reply With Quote
  #3 (permalink)  
Old 02-06-2008
Junior Member
 
Join Date: Oct 2007
Location: India
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
amitbhosale is on a distinguished road
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
Reply With Quote
Reply

  Geeks Talk > Web Development > PERL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
about PERL... psuresh1982 PERL 5 09-04-2007 10:04 PM
How is PERL helpful for testers Geek_Guest Career Advice 0 06-28-2007 03:10 AM
Getting a list of ipaddress from the array using perl anushya Scripting 1 02-10-2007 01:42 AM
Points and lines smart_coder Brainteasers 8 01-25-2007 01:00 PM
Need Forums or PERL/PYTHON kalayama Suggestions & Feedback 3 12-21-2006 08:14 PM


All times are GMT -4. The time now is 01:40 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved