Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Saturday, January 28, 2012

Perl array insert

To insert an array @b before position n in an array a, use

splice(@a, n, 0, @b);

(ie 'replace 0 elements of @a, starting at offset n, with the elements of @b').

splice always puts into the list all the elements that it's given. If you tell it to replace fewer elements than it's given, the remaining elements are inserted. In this example, no elements are replaced and all elements are inserted.

Wednesday, January 25, 2012

SQL Server transactions

Three modes:

Autocommit = each statement is effectively its own transaction.
Implicit = transaction starts with the first DML statement and continues until you issue COMMIT or ROLLBACK. Another transaction starts at the next DML statement.
Explicit = you delimit transactions with BEGIN TRAN/COMMIT TRAN.

All connections start in autocommit mode.
Implicit mode is entered and left with SET IMPLICIT_TRANSACTIONS.
Explicit transactions are delimited by their BEGIN/COMMIT. When the transaction finishes, autocommit mode resumes.

Tuesday, January 24, 2012

qx and stderr

There seems to be no problem getting stderr included in the result of qx() - just put 2>&1 on the end of the command just as you would at the prompt.

Thursday, January 5, 2012

Windows edit controls and text files

Windows edit controls represent newlines as \r\n.

Windows/DOS text files represent newlines as \r\n.

If you want to read text from a file into an edit control, make sure you open it in "b" mode (eg fp = fopen("\\config.sys", "rb");).

If b is not specified, the file is opened in text mode, which causes \r\n to be transformed into \n, and edit controls do not translate a single \n into a newline. They represent it as a blob instead.

Wednesday, January 4, 2012

std::vector

The things that you put in a vector must be "copyable and assignable", ie not arrays. The only way to have a vector of char arrays is to put the array in a struct.

Followers

Blog Archive