oldmonk201 has asked for the wisdom of the Perl Monks concerning the following question:
I have a file consisting of a question on each line. I have created an array with the contents of this file. Some questions are having a \t or \n character.
my $filename_mh_sc_8_qnt = 'mh_science_8_qnt.txt'; open my $mh_sc_8_qnt, '<', $filename_mh_sc_8_qnt or die "Cannot open ' +$filename_mh_sc_8_qnt' for reading: $!"; my @Science = <$mh_sc_8_qnt>; my @shuffle = shuffle @Science; #shuffle the questions my $counter = 1; #number the question. foreach my $qnt (@shuffle){ print $counter, ". " . $qnt ."\n\n"; $counter++; }; print "\n";
The questions with \t and \n characters are not converting to tab and new line. example
Give reasons: \n\n\t(a) Grooves are made in tyres.\n\t(b) Gymnasts apply a coarse substance on their hands.How can print function convert the \t \n in such case. Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print tab within an element of an array
by choroba (Cardinal) on Jan 24, 2018 at 12:21 UTC | |
by oldmonk201 (Initiate) on Jan 24, 2018 at 12:32 UTC | |
|
Re: print tab within an element of an array
by haukex (Archbishop) on Jan 24, 2018 at 12:26 UTC | |
by oldmonk201 (Initiate) on Jan 24, 2018 at 12:33 UTC | |
|
Re: print tab within an element of an array
by haukex (Archbishop) on Jan 24, 2018 at 13:42 UTC |