Solved

Beginners question

Posted on 2001-06-29
3
165 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to dynamically set the form action using jQuery.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now