Home: Perl Programming Help: Regular Expressions:
How to stop printing a value



iphone
User

Dec 17, 2010, 8:43 PM


Views: 4952
How to stop printing a value

 
I have a hash like below,values are in an array,some values of array are comments,now I want to add a check not to print the comments.I tried the below(print join(",", grep(!/\/*.*?\/*/, @$value));
but not successful

Code
$VAR1 = { 
'file.txt' => [
'pages/value/data.h
',
'@label
',
'/* CAT/APP/file.c */
',
};


Code
for my $key (keys %Hash) 
{
my $value = $Hash{$key};
if (scalar @$value)
{ # check that the arrayref isn't empty
print join(",", grep(!/\/*.*?\/*/, @$value));
}

}



shawnhcorey
Enthusiast


Dec 18, 2010, 6:55 AM


Views: 4936
Re: [iphone] How to stop printing a value

Try:

Code
print join(",", grep(!/\/\*.*?\*\//, @$value));

I find it easier if I space things out:

Code
print join(",", grep(! m{ \/ \* .*? \* \/ }msx, @$value));


__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".