You cannot match a string, which starts with a non-word character, at a word boundary.
$staff = "Elgin \@Stevens BOSS"; # Elgin @Stevens BOSS
s/\b\@Stevens/Dr Stevens/;
Nothing happens because \b is defined as a change from \W to \w, which by definition cannot occur between space and @, because @ is \W.
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 )
Wednesday, October 20, 2010
Friday, October 15, 2010
Perl typeglobs and symbol table
*a represents the symbol table entry for a, ie a hidden binary structure that, when it's prefixed with $, @ etc, or used in filehandle context etc, the appropriate element is selected and used.
$::{'a'} does basically the same thing.
You can do a dereference on $::{'a'}, or indeed in this situation
$a = 9; *b = *a; print ${*b};
though I don't know whether this works because typeglobs and references are really interchangeable or whether some kind of soft dereferencing is happening automatically to make this work.
(The Perl 4 programming book says that %_main holds the symbol table for package main, but this doesn't seem to work now. Presumably $:: replaced it.)
Advanced Perl Programming says that assigning a reference to a typeglob
$a = 9; *b = \$a;
will change only the appropriate part of *b to a reference to $a. Ie after the above example, $b will be 9 but @b, %b etc will be unaffected.
The suggestion in APP is the sub-elements inside a typeglob are references, which is why the above would work, but it doesn't say that explicitly.
$::{'a'} does basically the same thing.
You can do a dereference on $::{'a'}, or indeed in this situation
$a = 9; *b = *a; print ${*b};
though I don't know whether this works because typeglobs and references are really interchangeable or whether some kind of soft dereferencing is happening automatically to make this work.
(The Perl 4 programming book says that %_main holds the symbol table for package main, but this doesn't seem to work now. Presumably $:: replaced it.)
Advanced Perl Programming says that assigning a reference to a typeglob
$a = 9; *b = \$a;
will change only the appropriate part of *b to a reference to $a. Ie after the above example, $b will be 9 but @b, %b etc will be unaffected.
The suggestion in APP is the sub-elements inside a typeglob are references, which is why the above would work, but it doesn't say that explicitly.
Tuesday, October 12, 2010
Google obfuscation
The key to Google's new obfuscation is the Search button - when this is clicked, the search request and all subsequent search requests return JSON which is, I think, then formed into a new results page, rather than fetching a new URL. This means that any Greasemonkey script won't get to run on the new results.
The key then is to make all searches avoid the Search button, by putting different code of our own behind it and also behind the paging buttons.
The key then is to make all searches avoid the Search button, by putting different code of our own behind it and also behind the paging buttons.
Tuesday, October 5, 2010
Javascript this
this refers to the 'owner' of the function in which it occurs.
In the page context this is the window or global object, in a property context it is the object (the object whose property it is).
NB that inline HTML property definitions, eg <element onclick="func()"> are in the page context (probably not what you want if func refers to this).
In the page context this is the window or global object, in a property context it is the object (the object whose property it is).
NB that inline HTML property definitions, eg <element onclick="func()"> are in the page context (probably not what you want if func refers to this).
Subscribe to:
Comments (Atom)