
tuxy94
New User
Apr 3, 2008, 1:33 AM
Post #1 of 2
(1305 views)
|
|
Creating a file with special Chars in Perl
|
Can't Post
|
|
Hello, I would like to know how I can create a file that contain special characters in Perl. I have been trying to create a file, with the following function, and it works but it creates an error when it run. I think it is due to the data I am trying to put in my file, for example there are %, @ and others that are to be printed in the file, and I think that the error is due to this. Any ideas on how I can accomplish this? I have attached my code with the error message and one line to be put in the file. Thanks, Code: sub CreateConfig{ my ($file,@data) = @_; $file = $file.".new"; open(NFILE,">$file"); foreach my $item (@data){ printf NFILE "$item\n"; } close(NFILE); } Error: Modification of a read-only value attempted One line of data from the array @data: passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*
|