Leser: 26
1 2 3 4 5 6 7
my $sth = $dbh->prepare("SELECT * FROM eib_tele") or die $dbh->errstr(); $sth->execute() or die $dbh->errstr; while (my($id,$system_id,$sernr,$ga1,$data,$tid,$pid,$ep_time,$last_time,$src_type,$src_addr,$rt_counter,$Quelladresse) = $sth->fetchrow_array()) {print("$id,$system_id,$sernr,$ga1,$data,$tid,$pid,$ep_time,$last_time,$src_type,$src_addr,$rt_counter,$Quelladresse \n"); }
1 2 3
use Data::Dumper; local $Data::Dumper::Useqq = 1; warn Dumper $variable_aus_db;
(1,0,'BT0900085211',4613,X'015B',0,4480,1274678734,'2010-05-24 07:25:36',3,4459,6),
$VAR1 = undef;
11319,0,BT0900085211,4615,M?,2559,511,1276347003,2010-06-12 14:48:40,3,4459,6,1.1.107
1
2
3
4
5
6
7
8
9
10
11
12
# oben:
use strict;
use warnings;
use Data::Dumper;
# später:
my $sth = $dbh->prepare("SELECT * FROM eib_tele LIMIT 1") or die $dbh->errstr();
my $rv = $sth->execute() or die $dbh->errstr;
while( my $href = $sth->fetchrow_hashref() ) {
print Dumper($href->{data}); # hier muss für data der Feldname rein
}
$VAR1 = "\1[";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
#!/usr/bin/perl use warnings; use strict; use strict; use warnings; use Data::Dumper; my $USER = "xxx"; my $PASS = ""; my $ga1 = "1"; my $data = "1"; my $system_id =""; my $sernr=""; my $tid=""; my $pid=""; my $ep_time=""; my $last_time=""; my $src_type=""; my $src_addr=""; my $rt_counter=""; my $i="1"; my @test=(); my $str=""; my $ttest; my $variable_aus_db; my $tret; my $var; use DBI; use Data::Dumper; local $Data::Dumper::Useqq = 1; warn Dumper $variable_aus_db; my @dsn = ("DBI:mysql:database=vvvvvv;" . "host=localhost", $USER, $PASS); # Datenbank andocken my $dbh = DBI->connect(@dsn, { PrintError => 0, AutoCommit => 1, } ) or die $DBI::errstr; # oben: # später: my $sth = $dbh->prepare("SELECT * FROM eib_tele where ID = '5'") or die $dbh->errstr(); my $rv = $sth->execute() or die $dbh->errstr; while( my $href = $sth->fetchrow_hashref() ) { $var = print Dumper($href->{data}); # hier muss für data der Feldname rein print Dumper($href->{data}); } $var = unpack "H4", $var; my $decimal = hex($var); print ($var ); $dbh->do("update eib_tele SET Quelladresse = '$var' where ID = '5'") or die $dbh->errstr(); $dbh->disconnect();
1 2 3 4 5
my $s = "\x01H"; $s = unpack "H4", $s; print hex $s; # decimal __ENDE__ 328
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/usr/bin/perl # man braucht die Module nur einmal zu laden use warnings; use strict; use DBI; use Data::Dumper; local $Data::Dumper::Useqq = 1; my $USER = "xxx"; my $PASS = ""; my @dsn = ("DBI:mysql:database=vvvvvv;" . "host=localhost", $USER, $PASS); # Datenbank andocken my $dbh = DBI->connect(@dsn, { PrintError => 0, AutoCommit => 1, } ) or die $DBI::errstr; # Abfrage Präparieren my $sth = $dbh->prepare("SELECT * FROM eib_tele where ID = '5'") or die $dbh->errstr(); # Abfrage ausführen $sth->execute() or die $dbh->errstr; # den fünften Eintrag der Ersten gelesenen Zeile holen my $var = $sth->fetchrow_arrayref()->[4]; # Abfrage beenden $sth->finish(); # Wert testweise Ausgeben print Dumper($var); # Wert Konvertieren $var = unpack "H4", $var; my $decimal = hex($var); # Konvertierten Wert ausgeben print "$var\n"; # Datanbankverbindung beenden $dbh->disconnect();