williamr/sbs_findstr.pl
author William Roberts <williamr@symbian.org>
Wed, 10 Jun 2009 17:17:58 +0100
changeset 7 705136d2022f
parent 3 8b87ea768cb8
child 15 a5c7bdb47359
permissions -rw-r--r--
sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
#! perl
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
#
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# 
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
# Contributors:
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
#
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
# Description:
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
# Filter an SBSv2 log to keep only recipes which match a specified RE
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    17
use strict;
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    18
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    19
my $expression = shift @ARGV;
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    20
my $line;
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    21
my $skipping = 1;
7
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    22
my $current_target = "";
2
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    23
3
8b87ea768cb8 Add a utility to convert raptor timestamps back into localtime.
William Roberts <williamr@symbian.org>
parents: 2
diff changeset
    24
@ARGV = map {glob} @ARGV;
8b87ea768cb8 Add a utility to convert raptor timestamps back into localtime.
William Roberts <williamr@symbian.org>
parents: 2
diff changeset
    25
2
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    26
while ($line =<>)
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    27
  {
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    28
  if (substr($line,0,9) eq "</recipe>")
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    29
    {
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    30
    print $line if ($skipping == 0);  
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    31
    $skipping = 1;    # set this to 0 to get the "between recipes" stuff
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    32
    next;
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    33
    }
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    34
  if (substr($line,0,8) eq "<recipe ")
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
    {
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
    if ($line =~ /$expression/io)
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
      {
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
      $skipping = 0;
7
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    39
      $current_target = "";
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    40
      if ($line =~ /(target='[^']+') /)
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    41
        {
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    42
        $current_target = $1;
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    43
        }
2
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
      }
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    45
    else
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    46
      {
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    47
      $skipping = 1;
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    48
      }
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    49
    }
7
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    50
  next if ($skipping == 1);  
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    51
  if (substr($line,0,8) eq "<status ")
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    52
    {
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    53
    substr($line,-3) = "$current_target />\n";
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    54
    }
705136d2022f sbs_findstr.pl inserts the target attribute into the status, for quick grepping. The sbs_quickstatus.pl does this for all <status> elements
William Roberts <williamr@symbian.org>
parents: 3
diff changeset
    55
  print $line;
2
a600c1a596f7 Create "williamr" directory in utilities, and add an assortment of Perl scripts
William Roberts <williamr@symbian.org>
parents:
diff changeset
    56
  }