Try escaping the dollar sign. You're probably having an issue with Perl interpreting $GPGLL as a scalar. Since it's undefined, you have a problem. Also, make sure you turn on warnings and strict. That will catch problems like that.
#!/usr/bin/perl -w
use strict;
my $var = "$GPGLL,577.015,N,01201.076,E,"; #wrong!
or
my $var = "\$GPGLL,577.015,N,01201.076,E,"; #better. Note the escape.
or
my $var = '$GPGLL,577.015,N,01201.076,E,';
In the final example, single quotes are used. Double quotes around a string allow for variable interpolation. Single quotes prevent that. There are a variety of ways that your code could have issues with interpolation. If you post a small snippet, we can take a look and figure out exactly how it is occurring.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. | [reply] [d/l] |
#
Why are you doing system("echo $gpsdata") anyway? It's expensive. Try print $gpsdata, or, if you need the extra newline, print "$gpsdata\n". | [reply] [d/l] [select] |
You are telling Perl to run the command:
echo $GPGLL,577.015,N,10201.076,E,
go type that command in by hand and see what gets output.
You see, Perl see that there is a $ in the command that you asked it to run so it runs /bin/sh and tells it to interpret the command for you. /bin/sh replaces $GPGLL with the value of the GPGLL environment (or shell) variable. But there is probably no such variable so the value is just the empty string.
So, as suggested, just use:
print $gpsdata,$/;
instead (the $/ puts a newline on the end).
You could also use:
system("echo",$gpsdata);
because when you give more than one item to system, it prevents the shell from interpreting the arguments that you asked to be passed to the command. But, in this case, the simple print is a much better choice.
See "perldoc -f system" for more information.
-
tye
(but my friends call me "Tye")
| [reply] [d/l] [select] |