Entries Tagged as 'Programming'
use Data::Dumper;
my @array;
push @array, {’key1′ => ‘value1′, ‘key2′ => ‘value2′};
push @array, {’key1′ => ‘value1′, ‘key2′ => ‘value2′};
push @array, {’key1′ => ‘value1′, ‘key2′ => ‘value2′};
print Dumper(@array);
Will give you:
$VAR1 = {
‘key2′ => ‘value2′,
‘key1′ => ‘value1′
};
$VAR2 = {
‘key2′ => ‘value2′,
‘key1′ => ‘value1′
};
$VAR3 = {
‘key2′ => ‘value2′,
‘key1′ => ‘value1′
};
Snazzy!
Did you find this post useful or have questions or comments? [...]
[Read more →]
Tags: How Tos · Programming · perl
When writing PHP web apps, I tend to run in to a portability issue when dealing with SQL connectivity. Since I can’t count on having the PEAR DB module available, I rolled my own set of functions to interact with a MySQL database.
The problem lies in escaping characters in your SQL queries. Do [...]
[Read more →]
Tags: Programming · SQL · php
my $ip = ‘1.2.3.4′;
my $block1 = ‘1.2.3.0/27′;
if(checkip($ip, $block1)) {
print STDOUT “$ip is in $block1\n”;
}
else {
print STDOUT “$ip is not in $block1\n”;
}
sub checkip() {
my $ip = shift;
my $block = shift;
@ip1 = split(/\./, $ip);
[...]
[Read more →]
Tags: How Tos · Programming · ip addressing · ipv4 · networking · perl