List Info

Thread: Sorting a file




Sorting a file
user name
2007-06-12 15:05:25
Below is the little progress I had made. I hope you can help
me out
with the rest.  I will like to re-arrange some data in a
file and save
the file into a new one.
open (file, "lots_info") or die "can't"
;
open (new, ">new.txt") or die
"can't";
data
= <file>;
while (<file>)
{
if ($data[$x] =~ /(FinalValue="1")/ || $data[$x]
=~ /(Final
Value="2")/ || $data[$x] =~ /(Final
Value="3")/ || $data[$x] =~ /
(Final Value="4")/ || $data =~ /(Final
Value="5")/
|| $data[$x] =~ /(Final Value="6")/)
{
#read the next four lines after each the "Final
Value" and re-arrange
the position of the lines.  At the end, I need to write the
whole file
into the " new.txt" and replace the name of the
file with "lots_info",
thus replacing the old "lots_info" file.


}


}
close file;
close new;

#BELOW ARE THE DATAS NOT IN ORDER

 <C4Value="75" />
  <LFValue="95" />
  <FMValue="89" />
  <ISValue="0.9" />

#BELOW ARE THE ORDER I WANT THEM TO BE:
  <FMValue="87" />
  <ISValue="0.8" />
  <LFValue="95" />
  <C4Value="75" />

Thank you in advance


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Perl Programming" group.
To post to this group, send email to perl-programminggooglegroups.com
To unsubscribe from this group, send email to
perl-programming-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/perl-programming
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )