package SugarTrail::Template::CondBlock; # condition block # init() # parse(string) # matches(data) use strict; use warnings; use Data::Dumper; sub init { my $class = shift; my $self = {}; return bless $self, $class; } sub parse { my $self = shift; my $string = shift; my @parts = split ";", $string; foreach (@parts) { s/^\s+//; s/\s+$//; my ($n, $o, $v) = m/([a-zA-Z0-9_ ]+)([<>=~+\-*@]*)(.*)/; next unless $n; $n =~ s/\s+$//; $o =~ s/\s+$//; $o =~ s/^\s+//; $v =~ s/\s+$//; my @v = split m/\s*,\s*/, $v; push @{$self->{conds}}, { n => $n, o => $o, v => \@v }; } } sub match { my $self = shift; my $args = shift; } 1;