Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 6f49cae0f4
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (28 sloc) 0.694 kB
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
package Devel::Trepan::Condition;
use strict;
use warnings;
use English qw( -no_match_vars );
use vars qw(@EXPORT @ISA);
@EXPORT = qw( is_valid_condition );
@ISA = qw(Exporter);
sub is_valid_condition($) {
my ($expr) = @_;
my $pid = fork();
if ($pid) {
waitpid($pid, 0);
return $CHILD_ERROR == 0;
} else {
close STDERR;
exec($EXECUTABLE_NAME, '-c', '-e', $expr);
}
}
# Demo code
unless (caller) {
for my $expr ('$a=2', '1+', "join(', ', @ARGV)", 'join(", ", @ARGV)') {
my $ok = is_valid_condition($expr);
printf("$expr is %sa valid_condition\n", $ok ? '' : 'not ');
}
}
1;
Jump to Line
Something went wrong with that request. Please try again.