Home: Perl Programming Help: Intermediate:
Post deleted by mkeith123



mkeith123
Novice

Mar 27, 2008, 1:12 PM


Views: 14504
Post deleted by mkeith123

 


KevinR
Veteran


Mar 28, 2008, 1:19 AM


Views: 14500
Post deleted by KevinR

 


mkeith123
Novice

Mar 28, 2008, 9:36 AM


Views: 14496
Post deleted by mkeith123

 


KevinR
Veteran


Mar 28, 2008, 10:35 AM


Views: 14494
Post deleted by KevinR

 


mkeith123
Novice

Mar 28, 2008, 10:56 AM


Views: 14493
Post deleted by mkeith123

 


KevinR
Veteran


Mar 28, 2008, 11:00 AM


Views: 14491
Re: [mkeith123] loop

Mike,

'path/to/outfile' is a generic example, substitue whatever is appropriate. If you want to write the output in the same directory the script runs in just use a filename with no path:

'outfile.txt'

or whatever you want to call the file.
-------------------------------------------------


mkeith123
Novice

Mar 28, 2008, 2:52 PM


Views: 14486
Post deleted by mkeith123

 


KevinR
Veteran


Mar 28, 2008, 10:19 PM


Views: 14484
Re: [mkeith123] loop

You are only using the name of the file you want to read ($current_file):

open ($IN, $current_file) or die "$!";

so that file would have to be in the same directory as the script or you have to change directory to the directory where to $current_file resides or use the full path to the file:

open ($IN, "path/to/$current_file") or die "$!";

Also, in your first post in this thread, the filename has an underscore in it but in the code you posted there is no underscore in the filename. So remove the underscore in this line if it should not be there:

my $current_file = sprintf "mv_%07d.txt", $file;
-------------------------------------------------


(This post was edited by KevinR on Mar 28, 2008, 10:22 PM)


mkeith123
Novice

Mar 29, 2008, 10:17 AM


Views: 14479
Post deleted by mkeith123

 


KevinR
Veteran


Mar 30, 2008, 9:42 PM


Views: 14459
Re: [mkeith123] loop

Mike, I don't know the answers to those questions. You have to try and figure out where your files are and where the perl script is and such. The "my" does belong there.
-------------------------------------------------


mkeith123
Novice

Apr 1, 2008, 8:49 AM


Views: 14443
Post deleted by mkeith123

 


KevinR
Veteran


Apr 1, 2008, 10:22 AM


Views: 14442
Post deleted by KevinR

 


mkeith123
Novice

Apr 2, 2008, 1:00 PM


Views: 14430
Post deleted by mkeith123

 


KevinR
Veteran


Apr 2, 2008, 1:52 PM


Views: 14429
Re: [mkeith123] loop

just declare it with "my" on this line:

my $current_file = sprintf "mv_%07d.txt", $file;

that will take care of the error message you are getting.
-------------------------------------------------


mkeith123
Novice

Apr 5, 2008, 12:01 PM


Views: 14380
Post deleted by mkeith123

 


KevinR
Veteran


Apr 5, 2008, 1:38 PM


Views: 14379
Re: [mkeith123] loop

Mike,

I don't really know why you are seeing that path. That is not the directory where your perl script is? Post the full text of the error message.
-------------------------------------------------


mkeith123
Novice

Apr 6, 2008, 12:04 PM


Views: 14366
Post deleted by mkeith123

 


KevinR
Veteran


Apr 6, 2008, 2:06 PM


Views: 14361
Re: [mkeith123] loop

My guess is that Dzsoft has confused the process somehow. I would try putting the Calc6.pl script and the Comparison.txt file in a known directory and run the perl script from the known directory. Something simple like:

c:\test\Calc6.pl

Also, I think Dzsoft is for perl based CGI scripts, your program is not a CGI script, it is a command line script. That probably explains the warning.
-------------------------------------------------


mkeith123
Novice

Apr 10, 2008, 4:00 PM


Views: 14348
Post deleted by mkeith123

 


KevinR
Veteran


Apr 10, 2008, 11:06 PM


Views: 14343
Re: [mkeith123] loop

They just mean to print the value of that variable at that point in the script but we already know what that value will be. It was as I thought, DZSoft is confusing the process. I think all IDE's work like that, they create a temp file of the script so you can edit and run it dynamically without first having to save it to hard disk. All you have to do to avoid the problem is do what I said, save the script to a known directory and run it from there.

The question right now is are you sure the files in:

C:/UnzippedDownloads/training_set/

are named how you say they are:

mv_0000001.txt) to (mv_0017700.txt)

change this line:


Code
open (my $IN, "C:/UnzippedDownloads/training_set/$current_file") or die "$!";

to:

Code
open (my $IN, "C:/UnzippedDownloads/training_set/$current_file") or die "$current_file: $!";


and see which value of $current_file can't be found.
-------------------------------------------------


mkeith123
Novice

Apr 11, 2008, 8:23 AM


Views: 14338
Post deleted by mkeith123

 


KevinR
Veteran


Apr 11, 2008, 3:18 PM


Views: 14335
Re: [mkeith123] loop

if you mean this line:

<$IN>; #<-- skips first line

it will only skip the first line of the file. But remove it if you want to.
-------------------------------------------------


mkeith123
Novice

Apr 12, 2008, 9:50 AM


Views: 14320
Post deleted by mkeith123

 


KevinR
Veteran


Apr 12, 2008, 1:32 PM


Views: 14315
Re: [mkeith123] loop

attach (not post) one of the $current_file files to a post and i will take a look at it.
-------------------------------------------------


mkeith123
Novice

Apr 13, 2008, 9:26 AM


Views: 14301
Post deleted by mkeith123

 


KevinR
Veteran


Apr 13, 2008, 10:33 AM


Views: 3923
Re: [mkeith123] loop

Miie, you say you get a blank screen, that is because the script doesn't print anything to the screen, all results are printed to the file Comparison.txt. Are you saying the file is blank?

When I run the script with the input file I get output in the Comparison.txt file like this:

key = 729846, value = 4
key = 504620, value = 2
key = 1181170, value = 3
key = 2078679, value = 5
key = 2238063, value = 3
key = 14756, value = 4
-------------------------------------------------


(This post was edited by KevinR on Apr 13, 2008, 10:33 AM)


mkeith123
Novice

Apr 13, 2008, 4:15 PM


Views: 3921
Post deleted by mkeith123

 


KevinR
Veteran


Apr 14, 2008, 8:34 AM


Views: 3914
Re: [mkeith123] loop

I don't know why that is. The file Comparison.txt should be in the same directory as the script and as far as I can tell should have data written to it like I showed. Try using a full path instead of just the filename.
-------------------------------------------------


mkeith123
Novice

Apr 14, 2008, 2:44 PM


Views: 3905
Post deleted by mkeith123

 


KevinR
Veteran


Apr 14, 2008, 6:51 PM


Views: 3900
Re: [mkeith123] loop

Mike, it looks like it should work. You are not using Unix or Linux so it should not be a problem of permissions. It works fine for me when I tested the exact code and file you attached.
-------------------------------------------------