ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

#!/usr/bin/env perl
open my $file, $ARGV[1] or die "Could not open file";
while (<$file>) # iterate over the lines
{
s/D/e/g;
for (split) # iterate over the columns in the current line
{
$_ *= 219474.6306726;
print "$_\n";
}
}
close $file;

I have no idea if this will work, I'm still a bit new to Perl, but I couldn't resist .

Hi grail! Your code is neat as always, but why not using just a counter to print the line number? Just another suggestion (a lot of work for the original poster ) but I would end-up with something like this:

Based on the OPs original request they wanted the line numbers to equal the line the column came from as opposed to where your code has an ever increasing
count, ie if there are 3 rows and 3 columns it would be

Just a little note (then I will stop... promised ): why do you use a quoted space in the print statement? Comma separated arguments will be printed out as OFS separated strings. I find the comma more elegant and quick to type.