drieux wrote:


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

Thanks!
Yes, that's the module I'm using. I don't know why I was thinking I didn't need the config file I if I set the port settings in the script. After saving a config file I was able to get the script to run without errors (with strict uncommented). It runs quickly and finishes w/o saving anything in the log file but I think that's because at the moment it runs, there isn't anything coming in COM2. I didn't get a chance to play with it too much though.


Thanks again,
Ron


-- 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