473,383 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

processing /etc/fb.modes help

Hi i am new to Perl and i was wondering if you could look at my scripts and give me advice and feedback on how i could improve my scripts.

I am using /etc/fb.modes to write Perl scripts.

script 1- This script will read in the file and print one line at a time
#!/usr/bin/perl
open(INFO, `/etc/fb.modes`);
while($line = <INFO>)
{
print $line;
}
close INFO;

Skip comments and empty lines
#!/usr/bin/perl
open(INFO, `/etc/fb.modes`);
next if $line = ~ /^#/; #skips comments
next if $line =//; #skips emptylines
while($line = <INFO>)
{
print $line;
}
close INFO;


skips endmode lines
#!/usr/bin/perl
open(INFO, `/etc/fb.modes`);
next if $line = ~ /^#/; #skips comments
next if $line =//; #skips emptylines
next if $line =endmode;
while($line = <INFO>)
{
print $line;
}
close INFO;

How would i skip lines beginning with whitespace?

i want to split the header line in /etc/fb.modes
i want to split where the hyphens are and print out the first 2 fields on separate lines
for example
mode "640X480
75"
This is what ive done

#!/usr/bin/perl
open(INFO, `/etc/fb.modes`);
@line = split /-/, "mode "640X480-75";
print mode "\n" ;
print 75"\n";
print "=========================" "\n"; # i did this so its easy to read
Oct 16 '07 #1
3 2219
jcor
63
You can use the chomp() operator to skip the empty lines.

Chomp is a operator exactly to "get rid" of newline characters.
I'm a newbie in Perl either but I guess it's probably what you need.

good luck,

Joćo
Oct 16 '07 #2
KevinADC
4,059 Expert 2GB
You can use the chomp() operator to skip the empty lines.

Chomp is a operator exactly to "get rid" of newline characters.
I'm a newbie in Perl either but I guess it's probably what you need.

good luck,

Joćo
chomp() dos not skip blank/empty lines.
Oct 16 '07 #3
jcor
63
chomp() dos not skip blank/empty lines.

Ok
Like I said, I was not sure.

Sorry to make confusion,

Joćo
Oct 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mkoleno346 | last post by:
If I want to change autentication modes for an instance of MSDE that I already installed, what is the best way to go about this? I don't think you can change authentication modes using any of the...
3
by: Dubya | last post by:
Hello Everyone, I have this little app, that I would like to configure two modes of operation by using command line arguments. If the app is started with no arguments, the Main UserForm shows...
2
by: Gaurav Vaish | last post by:
Hi, How can I accomplish multiple authentication modes in one application? I have the following scenario: - A company, X, has some employees - Those on rolls have an AD account - Those...
1
by: Sunny | last post by:
Hi guys, I am using NVdia Geforce4 MX series graphics card for my dual monitor setup. There are different modes available for dual display (e.g clone mode ,span mode). These modes can be...
3
by: Dubya | last post by:
Hello Everyone, I have this little app, that I would like to configure two modes of operation by using command line arguments. If the app is started with no arguments, the Main UserForm shows...
9
by: Jacek Dziedzic | last post by:
Hi! I often find that my programs need to store information on "current mode of something" with two or at most several mutually exclusive "modes" to choose from, e.g. - datafile: is it in a)...
5
by: erikcw | last post by:
Hi all, I've created a script that reads in a file, replaces some data (regex), then writes the new data back to the file. At first I was convinced that "w+" was the tool for the job. But now...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
0
by: JohnQ | last post by:
(The thread "Error Handling Idioms" prompted this post. I meant to post it at the top level, but it got posted as a reply. So here it is again!) An attempt at common defintions: fault: the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.