1 2# This is a test script of IPC::LDT, 3# using file handles to check the 4# transfer of ASCII strings. 5 6 7# load modules 8use IPC::LDT; 9use FileHandle; 10 11# display number of test 12print "1..2\n"; 13 14# build temporary filename 15my $file="/tmp/.$$.ipc.ldt.tmp"; 16 17# store the messages to transfer 18my $msg="This is a simple\nmultiline check message."; 19my @msg=('This message', "contains\nof", 'several parts.'); 20 21 22# write messages 23{ 24 # open file 25 open(O, ">$file") or die "[Fatal] Could not open $file for writing.\n"; 26 27 # build LDT object 28 my $ldt=new IPC::LDT(handle=>*O) or die "[Fatal] Could not build LDT object.\n"; 29 30 # send the messages 31 $ldt->send($msg); 32 $ldt->send(@msg); 33 34 # close the temporary file 35 close(O); 36} 37 38 39# read messages 40{ 41 # open file 42 open(I, $file) or die "[Fatal] Could not open $file for reading.\n"; 43 44 # build LDT object 45 my $ldt=new IPC::LDT(handle=>*I) or die "[Fatal] Could not build LDT object.\n"; 46 47 # read the messages 48 my $read1=$ldt->receive; 49 my $read2=$ldt->receive; 50 51 # perform the checks 52 print $read1 eq $msg ? 'ok' : 'not ok', "\n"; 53 print $read2 eq join('', @msg) ? 'ok' : 'not ok', "\n"; 54 55 # close the temporary file 56 close(I); 57} 58 59# clean up 60unlink $file; 61