Perl: Unix - Windows
#1
Scooby Regular
Thread Starter
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
Perl: Unix - Windows
Trying to port a script over from unix to windows.
Got 99% of it done, but it trys to write to a .dat file using dbmopen.
When I run the script on my Linux box (Fedora Core 5) it works fine..
However when I run it on windows it doesnt.
This isnt the code, but produces the same results, so is a good test.
On linux, I get a .dat file, on windows I get a .dir and .pag iirc..
Any ideas for converting it / changing the code to work? Before I rewrite the whole script in vbscript.
David
Got 99% of it done, but it trys to write to a .dat file using dbmopen.
When I run the script on my Linux box (Fedora Core 5) it works fine..
However when I run it on windows it doesnt.
This isnt the code, but produces the same results, so is a good test.
Code:
use SDBM_File; dbmopen(%DBM,"dw",0644) || die "dbmopen failed"; $DBM{"key1"} = "Test1"; $DBM{"key2"} = "Test2"; $DBM{"key3"} = "Test3"; while (($key,$value) = each(%DBM)) { print "$key : $value\n"; } dbmclose(%DBM);
Any ideas for converting it / changing the code to work? Before I rewrite the whole script in vbscript.
David
#3
Scooby Regular
Join Date: Jan 2001
Location: still behind twin turbos
Posts: 469
Likes: 0
Received 0 Likes
on
0 Posts
You need to use strict, use warnings, and scope the the variables %DBM, $key
and $value for best practice. Strange you get a .dat on Linux, I get a .dir and .pag;
All looks to work here.
and $value for best practice. Strange you get a .dat on Linux, I get a .dir and .pag;
Code:
steven@jovian:~/scratch(0) % uname -a Linux jovian 2.6.11-9-amd64-k8-smp #1 SMP Wed Jun 29 16:27:10 CEST 2005 x86_64 GNU/Linux steven@jovian:~/scratch(0) % perl -v This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi ... steven@jovian:~/scratch(0) % perl -MSDBM_File -e 'print $SDBM_File::VERSION, "\n";' 1.05 steven@jovian:~/scratch(0) % ./sdbmfiletest.pl key1 : Test1 key2 : Test2 key3 : Test3 steven@jovian:~/scratch(0) % ls -al dw* -rw-r--r-- 1 steven steven 0 2006-10-31 11:01 dw.dir -rw-r--r-- 1 steven steven 1024 2006-10-31 11:03 dw.pag
#4
Scooby Regular
Thread Starter
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
in english?
I've re-written it to do what I wanted, but pissed off..
the problem is I dont want the .dir and .pag but again I've sussed a way around it, the other thing is the shell script was also doing >blah.dat
David
I've re-written it to do what I wanted, but pissed off..
the problem is I dont want the .dir and .pag but again I've sussed a way around it, the other thing is the shell script was also doing >blah.dat
David
#5
Scooby Regular
Join Date: Jan 2001
Location: still behind twin turbos
Posts: 469
Likes: 0
Received 0 Likes
on
0 Posts
If the shell script was redirecting STDOUT to a file, then all that file would contain would be whatever is in the print statements, no data at all.
If you don't want the data stored in .dir and .pag files, why are you using it?
If you don't want the data stored in .dir and .pag files, why are you using it?
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
hardcoreimpreza
Computer & Technology Related
21
11 October 2015 03:40 PM