Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Breaking out of a while loop: Is there a better way?

by smokemachine (Hermit)
on Nov 02, 2006 at 02:24 UTC ( [id://581809] : note . print w/replies, xml ) Need Help??


in reply to Breaking out of a while loop: Is there a better way?

Couldnt simplificate this with somethink like this? perl -i -pe 'BEGIN{die "Wrong type of file or dont exist" unless $ARGV[0] =~ /\.wpl$/ and -e $ARGV[0]; open $PLAY, $ARGV[0]; while(<$PLAY>){$drive=$1,last if /src=\"(.)\:\\/}print {STDOUT} "It appears the original drive letter is $drive.\nWhat would you like the new drive letter to be?\n";chomp($letter=<STDIN>) until$letter =~/^[a-zA-Z]$/; print {STDOUT} "You want change the $drive drive letter to $letter.\n"}s/="$drive:\\/="$letter:\\/g; print {STDOUT} "."; END{print {STDOUT} $/}' file.wpl

Replies are listed 'Best First'.
Re^2: Breaking out of a while loop: Is there a better way?
by BubbaMonk (Sexton) on Nov 02, 2006 at 03:22 UTC
    Obfuscation is in the eye of the beholder, eh. Doesn't look to simplicated to me! But that might be because I've never used -i or -pe before.....
Re^2: Breaking out of a while loop: Is there a better way?
by Anonymous Monk on Nov 02, 2006 at 13:13 UTC
    Because he works on windows (drive letter anyone) and windows has a limit on command line length. Old was 128 byte new is 1024(?)! So your command line may be too long;-)