sub_name(
param1 => 'value1',
param2 => 'value2',
);Define subs like this:
sub sub_name {
my $p1 = {@_}->{param1};
my $p2 = {@_}->{param2};
# etc
my $p1 = {@_}->{param1};
my $p2 = {@_}->{param2};
# etc
}
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
" Mason detection au BufRead,BufNewFile * \ if search('^\s*<%\(args\|once\|init\|perl\|shared\|attr\)>\s*$','n') \| set filetype=mason \| endif
mount -t smbfs //host/subdir hostname -o username=yourusername,fmask=555,dmask=555,ro
Don't use Samba though, use SSHFS.
#!/usr/bin/perl use warnings; my @cmd = @ARGV; my @ls = (); my $t = 10; eval { local $SIG{ALRM} = sub { die "alarm went off" }; alarm $t; @ls = `@cmd`; alarm 0; }; if (! @ls) { print "No response after $t seconds\n"; } else { foreach (@ls) { print $_; } } # actually never gets to here if ($@ and $@ !~ /alarm went off/) { die "Command timed out after $t seconds\n"; };
printf("That took %d"."d %d"."h %d"."m %d"."s",(gmtime($seconds))[7,2,1,0]));
application/x-www-form-urlencoded
(i.e. spaces turn to +)# Send all output to a logfile and supress input typeset LOG="/tmp/${0##*/}.out" mv $LOG ${LOG}.old >/dev/null 2>&1 [[ -t 1 ]] && echo "Writing to logfile '$LOG'." exec > $LOG 2>&1 exec < /dev/null 2<&1
Orange would have had to setup the normal Orange GPRS APN on your account, ... which they don't do for blackberry users (understandably, we're all meant to use BIS).(I can also see in Advanced Options | Host Routing Table, all the "Host Routing Information" entries have APN: blackberry.net)
import java.io.FileOutputStream; import java.sql.*; import org.dbunit.database.*; import org.dbunit.dataset.*; import org.dbunit.dataset.xml.*; // database connection Class driverClass = Class.forName("com.mysql.jdbc.Driver"); Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://host:port/dbname","user","pass"); IDatabaseConnection connection = new DatabaseConnection(jdbcConnection); // prevent error: Potential problem found: The configured data type factory // 'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' might cause problems with the current database 'MySQL' // (e.g. some datatypes may not be supported properly). connection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory()); // full database export IDataSet fullDataSet = connection.createDataSet(); FlatXmlDataSet.write(fullDataSet, new FileOutputStream("dbname"));
import java.text.MessageFormat; int a = 3; String b = "coders"; System.out.println( MessageFormat.format("{0} Java {1}.", String.format("%04d", a), b) );
package com.example; import junit.framework.TestCase; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium; public class GoogleTest extends TestCase { private static Selenium selenium; protected void setUp() { selenium = new DefaultSelenium("localhost" , 4444 , "*firefox", "http://www.google.com"); selenium.start(); selenium.setSpeed("2000"); } public final void testTitle() { selenium.open("http://www.google.com"); selenium.type("//input[@title='Google Search']", "I am using selenium"); selenium.click("//input[@value = 'Google Search']"); assertTrue(selenium.isElementPresent("/html/head/title")); } protected void tearDown() { selenium.stop(); } }
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
for i in *.JPG; do mv "$i" "${i/.JPG}".jpg; doneor
for i in *.jpg; do mv "$i" "`basename $i .jpg`.JPG"; done
open(LIST,'<',$datafile) || die "Failed to open ".$datafile;
my @header = split("\t", <list>);
chomp(@header);
my @nodes = ();
while (my $line = <LIST>) {
chomp($line);
my $i=0; my %node = map { $header[$i++] => ($_?$_:'[empty field]') } split("\t", $line);
push @nodes, \%node;
}
close(LIST);
print Dumper(\@nodes);
{calendar:id=nameOfCalendar|title=Title of Calendar|defaultView=month}
#!/bin/bash
NOW="/tmp/now_tmp"
BEFORE="/tmp/before_tmp"
LABEL=$1
USAGE="usage: "${0%}" [label]"
if [ "x$LABEL" == "x" ]; then echo $USAGE; exit; fi
p4 changes -l -i ./... > $NOW
p4 changes -l -i ./...@$LABEL > $BEFORE
for change_num in $(diff $NOW $BEFORE | perl -lne'/. Change (\d+)/ && print $1');
do
p4 describe $change_num |perl -pne'do { print "-----------------------------------------------------------\n\n"; exit } if m{Differences \.\.\.}'
done
use XML::LibXML;
use XML::LibXML::XPathContext;
$parser = XML::LibXML->new();
$xml = $parser->parse_string($self->raw_xml);
$xpath = XML::LibXML::XPathContext->new($xml->documentElement);
$xpath->registerNs('atom', 'http://www.w3.org/2005/Atom');
print $xpath->findvalue("/atom:feed/atom:title");
File.open(local_filename, 'w') {|f| f.write(doc) }
File.open(local_filename, 'w') {|f| f.write(doc) }
@waitlist = (10,20,16,12,8,22);
foreach $item (@waitlist) {
pipe *{$item},RETHAND;
unless ($pid = fork()) {
# Child process
sleep $item;
print RETHAND "Completed $item\n";
exit();
}
}
foreach $item (@waitlist) {
$response = <$item>;
$now = localtime();
print "$now - $response";
}