This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
my $num=ord 'E'; | |
print "The ASCII is : $num\n"; | |
my $word=chr(69); | |
print "The word is : $word\n"; | |
#The ASCII is : 69 | |
#The word is : E |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
sub add{ | |
my($a,$b)=@_; | |
print $a+$b; | |
return $a+$b; | |
} | |
'add'->(1,2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
result=5>3?1:0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $retry_count = 0; | |
@array = qw(pp dd ff bb); | |
RETRY: | |
eval { | |
my @rr = splice( @array, 0, 1 ); | |
print "@rr\n"; | |
die("tt"); | |
}; | |
if ($@) { | |
my $errstr = $@; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Fcntl qw(:flock); | |
use POSIX qw(strftime); | |
open (FD, " < source.txt") or die "$!\n"; | |
flock(FD, LOCK_EX); | |
print "Yeah i get the lock by pid=$$ at ", cur_time(), "\n"; | |
sleep 10; | |
flock(FD, LOCK_UN); | |
print "Oops i lose the lock by pid=$$ at ", cur_time(), "\n"; | |
close FD; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
my $var = 5; | |
SWITCH: { | |
$var == 1 && do { print "$var = 1n"; last SWITCH; }; | |
$var == 2 && do { print "$var = 2n"; last SWITCH; }; | |
$var == 3 && do { print "$var = 3n"; last SWITCH; }; | |
print "$var is not equal with 1 or 2 or 3n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$n = 10; | |
for($i=1;$i<=$n;$i++){ | |
proc_bar($i,$n); | |
select(undef, undef, undef, 0.2); | |
} | |
sub proc_bar{ | |
local $| = 1; | |
my $i = $_[0] || return 0; | |
my $n = $_[1] || return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use GPS::NMEA; | |
use Data::Dumper; | |
my $gps = new GPS::NMEA('Port' => '/dev/ttyS0', 'Baud' => 9600); | |
while(1) { | |
$gps->parse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#MAC | |
brew install sox | |
brew install cmake | |
brew install libusb | |
git clone git://git.osmocom.org/rtl-sdr.git | |
cd rtl-sdr | |
mkdir build | |
cd build | |
cmake ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rtl_fm -f 97400000 -M wbfm -s 480k -r 48000 - | play -r 48000 -t s16 -L -c 1 - |
OlderNewer