Month: June 2010

  • Perl Last Element of Split

    There is an easier way to get last element on a split operation, save split result to an array and use $array[-1] and this will access last element of the arrays.

    Example

    $strings=”foo,bar,test”;
    my @fields = split(/,/, $strings);
    print $fields[-1] ;  # the last str in $strings

  • Perl Backslash in Regular Expression

    This note is for a trick to use Q and E  to escape characters for regular expression. You will find it very useful when you do string substitution and your pattern contains characters like slashes or backslashes .

    (more…)

  • Perl Escape Backslashes in String Substitution

    This note is for a trick to use Q and E  to escape characters for regular expression. You will find it very useful when you do string substitution and your pattern contains characters like slashes or backslashes .

    (more…)

  • Perl Add Directory to Path

    Say you have a directory d:bin and you want to add it to path environment at the beginning of your Perl script. Following code will do the trick.

    my $dir="d:\bin";
    $ENV{PATH}.=";$dir";

    Then $dir will be included in new $ENV{PATH}

  • Manual Uninstall Windows Desktop Search

    Here is how to uninstall Windows Desktop Search (WDS) as it is not visible in add-remove programs

    Manual uninstall Windows Desktop Search 3

    1. Click on the Start Menu, then Run.
    2. Type cmd in the box and click OK. This will bring up the command line.
    3. Type the following and press enter

      %windir%$NtUninstallKB917013$spuninstspuninst.exe /q /promptrestart

    4. A box will now appear to confirm the WDS has been uninstalled and asks you to restart. Once you have restarted the PC WDS will be gone.

    (more…)