473,326 Members | 2,099 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,326 software developers and data experts.

How to make this print to file right --

Appreciate help with this, I want the file modified and correctly printed... appreciate your help.
Expand|Select|Wrap|Line Numbers
  1. open (SCR, "scratch.dat") || &CgiDie ("SCRATCH could not be opened while attempting read");
  2.         @scra =<SCR>;
  3.         close (SCR);
  4.         $reps = 1;
  5.         while ($reps < 19)
  6.         {
  7.         foreach $mine (@scra)
  8.             {
  9.             chomp($mine);
  10.             ($the_line, $country_number) = split (/\|/, $mine);
  11.             open (CNT, "+>country.dat") || &CgiDie ("Country list could not be opened trying to position creatures");
  12.             @ymca =<CNT>;
  13.             foreach $thine (@ymca)
  14.                 {
  15.                 chomp($thine);
  16.                 ($ln, $nm, $nr, $ne, $ea, $se, $so, $sw, $we, $nw, $mn, $tt ) = split (/\|/, $thine);
  17.                 if ($ln == $country_number)
  18.                     {
  19.                     $mn = $the_line;
  20.                     }
  21.                 } # End of for each on country file
  22.             $reps++;
  23.             } # End of for each @scra - scratch
  24.  
  25.             close (CNT);
  26.         } # End of while
  27.     #unlink ("scratch.dat");
  28.     &printout;
  29.     }
  30. else
  31.     {
  32.     &signin;
  33.         }
Feb 10 '10 #1
3 1252
numberwhun
3,509 Expert Mod 2GB
You really need to please provide more information. You have fed us a script but have not described what you are seeing that is wrong. What is the input? What do you expect for output into the new file? You have to give us as much information as you can to help us help you.

Regards,

Jeff
Feb 10 '10 #2
My apologies. scratch.dat has 18 lines and each line is:
junk (line number) |country number. Country.dat is over 300 lines. For each loop, I want to read each line of scratch.dat and match the country number in country.dat which is $ln. When the right line of country.dat is found, I then want
to change $mn of country dat to equal $the_line of the scratch file. When all 18
changes are done, I need to write country.dat back with the changes made.
As a side note, I am reading the forum replies and tips. I realize I am needing to change my script to use warnings and strict. Only reason I havent here is I am having to rewrite the whole script and getting this to write the file
back is bugging me. This is only a fraction of that script. I have tried writing it back to country.dat and gotten crazy results. I am not attacking it right.
Feb 10 '10 #3
chaarmann
785 Expert 512MB
We are not able to help you, unless you provide more information.
We can't run the script to see what you mean with "crazy" results, because
1.) we don't have the files scratch.dat and country.dat.
2.) the script is incomplete.
So why don't you provide samle data? (not all 300 lines, 3 carefully chosen ones are enough!)
Show us the "crazy" results. And important, tell us what output you expected instead.
Feb 12 '10 #4

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

Similar topics

7
by: lawrence | last post by:
2 Questions: 1.) Can anyone think of a way to speed up this function? It is terribly slow. I plan to reduce the number of directories to 3, which I guess will speed it up in the end. 2.) This...
6
by: Aubrey Hutchison | last post by:
Using Python 2,3,2 with idle for developing programs about 200 lines long. - Problem is not common to any specific program. Program are rather simple with no trick programming. Usually no classes...
7
by: Lowell Kirsh | last post by:
I have a script which I use to find all duplicates of files within a given directory and all its subdirectories. It seems like it's longer than it needs to be but I can't figure out how to shorten...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
3
by: Terry Hancock | last post by:
I still run into my own ignorance a lot with unicode in Python. Is it possible to define some combination of __repr__, __str__, and/or __unicode__ so that the unicode() wrapper isn't necessary...
3
by: itdaddy | last post by:
hey perl gurus! i am new to this forum cause i need help. I have done many scripts. but i want to use perl to do this: What I want to do is this. I have a QRP file that I can convert to a txt...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
2
by: dmorand | last post by:
When I try to print a 'print version' of my page it looks fine in IE 7, but when I print in IE 6 the margins are all screwed up. The page itself looks the same in both browsers, it's just when I...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.