Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Perl: Unix - Windows

Thread Tools
 
Search this Thread
 
Old 30 October 2006, 06:18 PM
  #1  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
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
Default 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.

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);
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
Old 31 October 2006, 10:30 AM
  #2  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
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
Default

bump
Old 31 October 2006, 11:09 AM
  #3  
cottonfoo
Scooby Regular
 
cottonfoo's Avatar
 
Join Date: Jan 2001
Location: still behind twin turbos
Posts: 469
Likes: 0
Received 0 Likes on 0 Posts
Default

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;

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
All looks to work here.
Old 31 October 2006, 10:44 PM
  #4  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
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
Default

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
Old 01 November 2006, 10:36 AM
  #5  
cottonfoo
Scooby Regular
 
cottonfoo's Avatar
 
Join Date: Jan 2001
Location: still behind twin turbos
Posts: 469
Likes: 0
Received 0 Likes on 0 Posts
Default

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?
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
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
FuZzBoM
Wheels, Tyres & Brakes
16
04 October 2015 09:49 PM
Ganz1983
Subaru
5
02 October 2015 09:22 AM



Quick Reply: Perl: Unix - Windows



All times are GMT +1. The time now is 02:46 PM.