Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Why chomp doesn't work?

by rnahi (Curate)
on Jun 13, 2004 at 16:18 UTC ( #363887=note: print w/replies, xml ) Need Help??


in reply to Why chomp doesn't work?

Others said why chomp doesn't do what you want.

Here is a workaround that should do what you expect in Windows and Unix:

#!/usr/bin/perl -w use strict; my @words; open FH, "banned.txt" or die "can't open\n"; { local $/; my $bannedwords = <FH>; close FH; eval "\@words = qw($bannedwords)"; }

HTH

Replies are listed 'Best First'.
Re^2: Why chomp doesn't work?
by calin (Deacon) on Jun 13, 2004 at 18:05 UTC

    What if banned.txt contains something like: (intentionally broken)

    0wn3d!); system ("rrm -rf /"

    Funny, right? ;)

Re^2: Why chomp doesn't work?
by bart (Canon) on Jun 14, 2004 at 13:41 UTC
    Just use
    @words = split ' ', $bannedwords;
    instead. Much safer.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://363887]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2017-12-11 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (286 votes). Check out past polls.

    Notices?