Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 15th, 2001, 03:22 AM
fighter fighter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: South Africa
Posts: 0 fighter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I was just wondering if there is a more efficient way to write this program...
The program basically accepts command line arguments which are option flags followed by the option (eg: -d documentName). I then parse argv and separate them into variables. Then I open a file. Then I have a while loop that reads a line at a time from the file and splits the line into several components, storing them in variables. Then I check whether a few the regular expression given on command line match the variables. If they do, I print that line and depending on the command line args, I print it a certain way.
I have a lot of "if-else" statements inside the while loop. I think I should be able to make it more efficient but I can 't think how. For example: the way in which i have to print the lines is fixed from when the program is started. So is there a way I could not check every time round the while loop, which way I am supposed to be printing before I print?

Reply With Quote
  #2  
Old April 16th, 2001, 01:46 PM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
if your code is no arduously long (ie, 50-100 lines of code) email it too me and i'll take a look at it.

scomrie@shrinkingplanet.ca

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > make my program more efficient


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT