On Dec 12, 2003, at 7:06 PM, [EMAIL PROTECTED] wrote:


I'm trying to get a script to save a barcode scanner's output to a log file.
[..]

do you mean that you are using
<http://search.cpan.org/~bbirth/Win32-SerialPort-0.19/lib/Win32/ SerialPort.pm>



use Win32::SerialPort;
# use strict;
use warnings;
[..]

you might want to uncomment the use strict.


$LOGDIR = 'c:\perl\scripts'; # path to data file $LOGFILE = "router.log"; # file name to output to $PORT = "COM2"; # port to watch
[ cutting out a prior effort to new the widget ]

# # open the logfile, and Port #

open(LOG,">>${LOGDIR}/${LOGFILE}")
    ||die "can't open smdr file $LOGDIR/$LOGFILE for append:\n";


then deal with the problem here:


$ob = tie (*BIFF, 'Win32::SerialPort')
       || die "Can't tie: $^E\n";

$PortObj = tie (*FH, 'Win32::SerialPort', $Configuration_File_Name) || die "Can't tie: $^E\n"; ## TIEHANDLE ##

from the pod would seem to suggest that you would
want to have a configuration file???

select(LOG), $| = 1; # set nonbufferd mode

#
# Loop forver, logging data to the log file
#

while($_ = <BIFF>){        # print input device to file
    print LOG $_;
}

[..]

you could do this logging part as

print LOG $_ while(<BIFF>);

which will just woof what ever you got from
the bar_code Reader.

HTH...

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to