output of special chars

in this loop i load up a text file witha story in it
it prints all the words but it doesnt print "!" "?" "." etc......

should i change the while loop?
if so what should i change it to?
thanks

   while(<F>)
   {
   while(/(\w+)/g)
   {
boofullsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guadalupeCommented:
If you just want to print a file line by line with no filtering do this:

while($line = <F>)
{
    print $line;
}

This is a little more verbose than what you had above but is clearer (it also removes the filtering of non-alphanumeric characters which was you original problem.  If yo want to filter some this but not others help me by defining what you want to filter and we'll give it a try...
0
boofullsAuthor Commented:
im having trouble editing the code in that way
could i just change one of these lines?

while(<F>)
   {
   while(/(\w+)/g)
   {

thanks
0
guadalupeCommented:
You could try this:

while(<F>)
{
   while(/(.+)/g)
   {
        #do somthing with the line
   }
}

But pattern matching in this case is pointless.  Here yo have effectivle said if the line contains any character at all (including white space characters like tabs and spaces) then do whatever is in the while loop it is also slightly more expensive...
0
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

boofullsAuthor Commented:
that wont work
sorry that i cant explain why....
its not my code
0
guadalupeCommented:
Well show me a little more and maybe I can help but with the info I have thats what seems like the best...
0
olthoffCommented:
your pattern match \w does not include special characters, your pattern match would have to be
while (/[\w!?,]/g) { #do something };
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.