r585@llin: dpavlin | 2006-05-12 22:02:20 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 12 May 2006 19:59:25 +0000 (19:59 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 12 May 2006 19:59:25 +0000 (19:59 +0000)
 added prefix and fixed few mistakes in or die

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@463 07558da8-63fa-0310-ba24-9fe276d99e06

conf/normalize/isis_ffzg.pl
lib/WebPAC/Normalize/Set.pm

index d18a4aa..e7de2b6 100755 (executable)
@@ -174,19 +174,19 @@ tag('IssuedWith',
 
 display('Parts',
        lookup(
-               regex( 's/^/dio-jzav:/', rec(900) )
+               prefix( 'dio-jzav:', rec(900) )
        )
 );
 
 search('Parts',
        lookup(
-               regex( 's/^/id-dio-jzav:/', rec(900) )
+               prefix( 'id-dio-jzav:', rec(900) )
        )
 );
 
 display('PartsEF',
        lookup(
-               regex( 's/^/naslov-efzg:001/', rec('001') )
+               prefix( 'naslov-efzg:001', rec('001') )
        )
 );
 
@@ -196,7 +196,7 @@ tag('PartsID',
 
 tag('Piece',
        lookup(
-               regex( 's/^/nazlov-efzg:/',
+               prefix( 'nazlov-efzg:',
                        first(
                                rec(463,1)
                        )
@@ -206,7 +206,7 @@ tag('Piece',
 
 tag('PieceSubtitle',
        lookup(
-               regex( 's/^/podnazlov-efzg:/',
+               prefix( 'podnazlov-efzg:',
                        first(
                                rec(463,1)
                        )
index f18e8c0..9589b51 100644 (file)
@@ -4,7 +4,9 @@ use Exporter 'import';
        set_rec set_lookup
        get_ds clean_ds
        tag search display
-       rec1 rec2 rec regex first lookup join_with
+       rec1 rec2 rec
+       regex prefix
+       first lookup join_with
 /;
 
 use warnings;
@@ -19,11 +21,11 @@ WebPAC::Normalize::Set - describe normalisaton rules using sets
 
 =head1 VERSION
 
-Version 0.02
+Version 0.03
 
 =cut
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 =head1 SYNOPSIS
 
@@ -59,7 +61,7 @@ By default, output will go into I<search> and I<display>.
 my $out;
 
 sub tag {
-       my $name = shift or "tag needs name as first argument";
+       my $name = shift or die "tag needs name as first argument";
        return unless (@_);
        $out->{$name}->{tag} = $name;
        $out->{$name}->{search} = \@_;
@@ -75,7 +77,7 @@ Define tag just for I<display>
 =cut
 
 sub display {
-       my $name = shift or "display needs name as first argument";
+       my $name = shift or die "display needs name as first argument";
        return unless (@_);
        $out->{$name}->{tag} = $name;
        $out->{$name}->{display} = \@_;
@@ -90,7 +92,7 @@ Prepare values just for I<search>
 =cut
 
 sub search {
-       my $name = shift or "search needs name as first argument";
+       my $name = shift or die "search needs name as first argument";
        return unless (@_);
        $out->{$name}->{tag} = $name;
        $out->{$name}->{search} = \@_;
@@ -209,6 +211,19 @@ sub regex {
        return @out;
 }
 
+=head2 prefix
+
+Prefix all values with a string
+
+  @v = prefix( 'my_', @v );
+
+=cut
+
+sub prefix {
+       my $p = shift or die "prefix needs string as first argument";
+       return map { $p . $_ } @_;
+}
+
 =head2 first
 
 Return first element