Weibel Daniel wrote at Thu, 26 Sep 2002 09:55:01 +0200: > I'm trying to get a random line from a text file and than delete the file. > I came up with this and it works, however the line which was cut/past adds > without any reason a backspace/space on it. It doesn't write it all on one > line. How can I change the script that it doesn't add anything on it. Must > I add a start/end to the txt file? > Please can somebody help me > Daniel > > $random_file = "/home/sites/site70/web/cgi-bin/i-merchant/admin/setup/ric.txt"; > [Snipped your example]
One way to do what you describe is a three liner: use File::Random qw/random_line/; # could be found in CPAN my $line = random_line($random_file); unlink $random_file; (The File::Random module contains also methods to select randomly a file) Please read also perldoc -q 'random line' Greetings, Janek PS: Please excuse my self announcement as I wrote the File::Random module :-)) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]