snowrider has asked for the wisdom of the Perl Monks concerning the following question:
shouldnt line 12 open $text instead of $file? snowrider1: #!/usr/bin/perl 2: #this programs prompts a user for a filename and then 3: #replaces all tabs in that file with 3 spaces. 4: print "What file do you want to \"detabify?\" "; 5: $file=<>; 6: chomp $file; 7: $/=undef; #changes the input record separator so it'll +read the entire file in at once 8: open FILE, "<$file"; 9: $text=<FILE>; #reads the entire file in 10: close FILE; 11: $text=~s/\t/ /g; #replaces tabs 12: open FILE, ">$file"; 13: print $text; #write changes to file 14: close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: is this correct
by kschwab (Vicar) on Feb 02, 2001 at 22:28 UTC | |
by PsychoSpunk (Hermit) on Feb 02, 2001 at 22:36 UTC | |
by snowrider (Pilgrim) on Feb 02, 2001 at 22:45 UTC | |
by Chady (Priest) on Feb 02, 2001 at 23:59 UTC | |
by el-moe (Scribe) on Feb 03, 2001 at 05:19 UTC | |
|
Re: is this correct
by davorg (Chancellor) on Feb 02, 2001 at 22:10 UTC | |
|
Re: is this correct
by Gloom (Monk) on Feb 03, 2001 at 00:10 UTC | |
by arhuman (Vicar) on Feb 03, 2001 at 00:15 UTC | |
by repson (Chaplain) on Feb 03, 2001 at 08:20 UTC |