Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

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 Blogs FAQ Tag Cloud Calendar Mark Forums Read

PERL PERL Scripts - Tips, Tricks, Issues, Latest News, PERL Resource and PERL related topics can be discussed in this forum.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2007
Junior Member
 
Join Date: Sep 2006
Location: India
Posts: 6
Thanks: 0
Thanked 2 Times 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,016
Thanks: 0
Thanked 91 Times in 72 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

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


All times are GMT -4. The time now is 05:59 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved