CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



mkeith123
Novice

Mar 27, 2008, 1:12 PM

Post #1 of 30 (5304 views)
Post deleted by mkeith123

 


KevinR
Veteran


Mar 28, 2008, 1:19 AM

Post #2 of 30 (5300 views)
Post deleted by KevinR [In reply to]

 


mkeith123
Novice

Mar 28, 2008, 9:36 AM

Post #3 of 30 (5296 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Mar 28, 2008, 10:35 AM

Post #4 of 30 (5294 views)
Post deleted by KevinR [In reply to]

 


mkeith123
Novice

Mar 28, 2008, 10:56 AM

Post #5 of 30 (5293 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Mar 28, 2008, 11:00 AM

Post #6 of 30 (5291 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #7 of 30 (5286 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Mar 28, 2008, 10:19 PM

Post #8 of 30 (5284 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #9 of 30 (5279 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Mar 30, 2008, 9:42 PM

Post #10 of 30 (5259 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #11 of 30 (5243 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 1, 2008, 10:22 AM

Post #12 of 30 (5242 views)
Post deleted by KevinR [In reply to]

 


mkeith123
Novice

Apr 2, 2008, 1:00 PM

Post #13 of 30 (5230 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 2, 2008, 1:52 PM

Post #14 of 30 (5229 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #15 of 30 (5180 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 5, 2008, 1:38 PM

Post #16 of 30 (5179 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #17 of 30 (5166 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 6, 2008, 2:06 PM

Post #18 of 30 (5161 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #19 of 30 (5148 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 10, 2008, 11:06 PM

Post #20 of 30 (5143 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #21 of 30 (5138 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 11, 2008, 3:18 PM

Post #22 of 30 (5135 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #23 of 30 (5120 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 12, 2008, 1:32 PM

Post #24 of 30 (5115 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #25 of 30 (5101 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 13, 2008, 10:33 AM

Post #26 of 30 (1522 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #27 of 30 (1520 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 14, 2008, 8:34 AM

Post #28 of 30 (1513 views)
Re: [mkeith123] loop [In reply to] Can't Post

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

Post #29 of 30 (1504 views)
Post deleted by mkeith123 [In reply to]

 


KevinR
Veteran


Apr 14, 2008, 6:51 PM

Post #30 of 30 (1499 views)
Re: [mkeith123] loop [In reply to] Can't Post

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.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives