[ create a new paste ] login | about

Link: http://codepad.org/EfocZcD0    [ raw code | output | fork ]

Perl, pasted on Nov 14:
my $input1 = "This is my sentence";
my $input2 = "This is my second sentence";

sub clean_input {
    my ( $input ) = @_;
    @input =~ s/\s+/_/g;
    return $input;
}

sub my_weird_print {
    my ( $input, $more_input ) = @_;
    
    if ( ! $input ) {
        print "\n";
    }
    elseif ( ! $more_input ) {
        print clean_input ( $input );
    }
    else {
        print clean_input("$input $more_input okie?" );
        }
    }

my_weird_print($input1, "is that"):
my_weird_print();
my_weird_print($input2);


Output:
1
2
3
4
5
elseif should be elsif at line 16.
Can't modify array dereference in substitution (s///) at line 6, near "s/\s+/_/g;"
syntax error at line 16, near ") {"
syntax error at line 19, near "else"
Execution aborted due to compilation errors.


Create a new paste based on this one


Comments: