Solved

Beginners question

Posted on 2001-06-29
3
169 Views
Last Modified: 2013-12-25
I am a beginner and this probably an extremely simple question, please excuse me.

How do I reverse a flatfiles contents, what I mean by reverse is this:

Existing flatfile contents.

1\n
2\n
3\n

What I want to convert it to is:

3\n
2\n
1\n

This is how I currently read the file:

open(FILE,"$dbase")
@all=<FILE>;
close(FILE);

0
Comment
Question by:haast
3 Comments
 
LVL 8

Accepted Solution

by:
bebonham earned 50 total points
ID: 6240246
open(FILE,"$dbase")
@all=<FILE>;
close(FILE);
@all=reverse @all;
open FILE, ">$dbaseReversed";
print FILE @all;
close FILE;


##the reverse function;

Bob
0
 
LVL 3

Expert Comment

by:rag2000
ID: 6240260
reverse the array
@reverseAll = reverse @all
0
 

Author Comment

by:haast
ID: 6240632
Thank you, it works fine.

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question