CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



iphone
User

Dec 17, 2010, 8:43 PM

Post #1 of 2 (2284 views)
How to stop printing a value Can't Post

 
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

Post #2 of 2 (2268 views)
Re: [iphone] How to stop printing a value [In reply to] Can't Post

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".

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives