Home > Archive > PERL Miscellaneous > March 2005 > problem with old version of (Active) Perl
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
problem with old version of (Active) Perl
|
|
| k9boy@hotmail.com 2005-03-29, 8:57 pm |
| I wrote the code on my local machine, which runs ActivePerl 5.8. The
machine that will use this code runs ActivePerl 5.6. Part of the code
opens up a large file (>85MB), substitute string values line by line,
then writes it to another file. Surprisingly, this part of the code
quits after reading about 10MB when running on version ActivePerl 5.6.
This alone causes the problem:
$origfile = "C:\\dir\\file.a";
$newfile = "C:\\dir\\file.b";
open INF, $origfile or die $!;
open OUTF, ">$newfile" or die $!;
while(<INF> ) {
print OUTF $_;
}
close INF;
close OUTF;
I can't get Perl upgraded without quite some difficultly, so does
anyone know what might be causing this problem?
Thanks in advance.
| |
| xhoster@gmail.com 2005-03-29, 8:57 pm |
| k9boy@hotmail.com wrote:
> I wrote the code on my local machine, which runs ActivePerl 5.8. The
> machine that will use this code runs ActivePerl 5.6. Part of the code
> opens up a large file (>85MB), substitute string values line by line,
> then writes it to another file. Surprisingly, this part of the code
> quits after reading about 10MB when running on version ActivePerl 5.6.
Any error messages? exit status? If you add an END block, does it get
executed before the program "quits"? Do you need to binmode the files?
Xho
> This alone causes the problem:
>
> $origfile = "C:\\dir\\file.a";
> $newfile = "C:\\dir\\file.b";
>
> open INF, $origfile or die $!;
> open OUTF, ">$newfile" or die $!;
> while(<INF> ) {
> print OUTF $_;
> }
> close INF;
> close OUTF;
>
> I can't get Perl upgraded without quite some difficultly, so does
> anyone know what might be causing this problem?
>
> Thanks in advance.
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
| |
| Fabian Pilkowski 2005-03-30, 8:59 am |
| * k9boy@hotmail.com schrieb:
>
> I wrote the code on my local machine, which runs ActivePerl 5.8. The
> machine that will use this code runs ActivePerl 5.6. Part of the code
> opens up a large file (>85MB), substitute string values line by line,
> then writes it to another file. Surprisingly, this part of the code
> quits after reading about 10MB [...]
Problems like this could happen due to forgetting binmode() on windowish
systems. Have a look at
perldoc -f binmode
and try out if that helps. Apart from that your code seems to be correct
for me, just your escaped backslashes in filenames give less readability
than a simple forward slash »/« which is already sufficient on windows.
regards,
fabian
| |
| k9boy@hotmail.com 2005-03-30, 3:57 pm |
| *slaps head* Thanks. Looks like binmode does it, although my files
should have been pure text.
I originally had forward slashes, but I noticed that Windows (XP Pro)
doesn't always behave properly with them. For example, at the command
prompt:
C:\>type C:\A.txt
This is in C:\
C:\>type C:\temp\A.txt
This is in C:\temp
C:\>type C:/A.txt
The syntax of the command is incorrect.
C:\>type "C:/A.txt"
This is in C:\
C:\>type "C:/temp/A.txt"
This is in C:\
The last result is incorrect... unless I'm doing it wrong.
In my Perl script, I'm making a "system" call to an EXE. When using
back slashes, the EXE generates a log file in the directory it was run
from. When using foward slashes, the EXE generates a log file in the
directory containing the EXE. I can't explain it, so I'm playing it
safe.
Thanks for the replies.
| |
| Joe Smith 2005-03-30, 8:57 pm |
| Fabian Pilkowski wrote:
> just your escaped backslashes in filenames give less readability
> than a simple forward slash »/« which is already sufficient on windows.
You should qualify that statement. Forward slashes can be used
instead of backslashes in Perl programs. The same is not true
for other Windows programs invoked by exec(), system(), or qx``.
-Joe
| |
| Fabian Pilkowski 2005-03-30, 8:57 pm |
| * Joe Smith schrieb:
> Fabian Pilkowski wrote:
>
> You should qualify that statement. Forward slashes can be used
> instead of backslashes in Perl programs. The same is not true
> for other Windows programs invoked by exec(), system(), or qx``.
You're right. That is, what I've meant.
thanks,
fabian
| |
| Alan J. Flavell 2005-03-30, 8:57 pm |
| On Wed, 30 Mar 2005, Fabian Pilkowski wrote:
> * Joe Smith schrieb:
>
> You're right. That is, what I've meant.
AFAIK, forward slashes are OK in the depths of Windows APIs: the
key problem is with the Windows shell itself (due to the tradition of
using "/" to introduce options, somewhat analogous to the Unix-ish
habit of using "-").
| |
| Tad McClellan 2005-03-30, 8:57 pm |
| Joe Smith <joe@inwap.com> wrote:
> Fabian Pilkowski wrote:
>
> You should qualify that statement. Forward slashes can be used
> instead of backslashes in Perl programs. The same is not true
> for other Windows programs invoked by exec(), system(), or qx``.
Is that true even for
system PROGRAM LIST
where there is no shell involved?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
|
|
|