Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: unititialized value warning

by wrinkles (Pilgrim)
on Mar 14, 2010 at 02:33 UTC ( #828516=note: print w/ replies, xml ) Need Help??


in reply to Re: unititialized value warning
in thread unititialized value warning

Thanks ikegami, I just needed to check the variables. This fixed it:

use strict; use warnings; use List::Util 'shuffle'; while (<DATA>) { my @newline = split(/\b/); for my $word (@newline) { my $first = ""; my $rem = ""; my $middle = ""; my $last = ""; ($first, $rem) = split /(?<=\b\w)/, $word if $word; ($middle, $last) = split /(?=(\w'\w+|\w)$)/, $rem if $rem; ((length $middle) == 2) ? $middle = reverse $middle : ($middle = join "", shuffle(split //, $middle)) if $middle; print "$first" if $first; print "$middle" if $middle; print "$last" if $last; } }


Comment on Re^2: unititialized value warning
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://828516]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-09-23 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (219 votes), past polls