Linux-SocketFilter

 view release on metacpan or  search on metacpan

lib/Linux/SocketFilter/Assembler.pm  view on Meta::CPAN


=cut

sub assemble
{
   my $self = __PACKAGE__;
   my ( $text ) = @_;

   my $ret = "";

   foreach ( split m/\n/, $text ) {
      s/^\s+//;      # trim whitespace
      next if m/^$/; # skip blanks
      next if m/^;/; # skip comments

      my ( $op, $args ) = split ' ', $_, 2;
      my @args = defined $args ? split m/,\s*/, $args : ();

      $self->can( "assemble_$op" ) or
         die "Can't compile $_ - unrecognised op '$op'\n";

      $ret .= $self->${\"assemble_$op"}( @args );
   }

   return $ret;
}



( run in 1.355 second using v1.01-cache-2.11-cpan-71847e10f99 )