#1: print string in file
Posted on 2010-08-17 13:59:42 by Irfan Sayed
--0-319478403-1282046382=:54054
Content-Type: text/plain; charset=us-ascii
Hi All,
I need to print some string into the file.
the string is like this : "<?xml version="1.0" encoding="UTF-8"?>"
i have written code like this :
print MYFILE "<?xml version="1.0" encoding="UTF-8"?>\n" where MYFILE is a file
handler.
if i run this code , it is giving so many syntax errors.
any advice please
Regards
Irfan
--0-319478403-1282046382=:54054--
Report this message |
|
#2: RE: print string in file
Posted on 2010-08-17 14:11:05 by Bob McConnell
From: Irfan Sayed
> I need to print some string into the file.=20
> the string is like this : "<?xml version=3D"1.0" encoding=3D"UTF-8"?>"
>=20
> i have written code like this :
> print MYFILE "<?xml version=3D"1.0" encoding=3D"UTF-8"?>\n" where =
MYFILE
is a file=20
> handler.
>=20
> if i run this code , it is giving so many syntax errors.=20
> any advice please
You can't have unescaped quotes in a quoted string. Try this:
print MYFILE "<?xml version=3D\"1.0\" encoding=3D\"UTF-8\"?>\n";
or this:
print MYFILE '<?xml version=3D"1.0" encoding=3D"UTF-8"?>' . "\n";
Bob McConnell
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Report this message |
#3: Re: print string in file
Posted on 2010-08-17 14:14:15 by Shawn H Corey
On 10-08-17 07:59 AM, Irfan Sayed wrote:
> Hi All,
>
> I need to print some string into the file.
> the string is like this : "<?xml version="1.0" encoding="UTF-8"?>"
>
> i have written code like this :
> print MYFILE "<?xml version="1.0" encoding="UTF-8"?>\n" where MYFILE is a file
> handler.
>
> if i run this code , it is giving so many syntax errors.
> any advice please
>
> Regards
> Irfan
>
>
>
Use a backslash to escape the internal double quotes:
print MYFILE "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Report this message |
#4: Re: print string in file
Posted on 2010-08-17 21:05:57 by rvtol+usenet
Irfan Sayed wrote:
> print MYFILE "<?xml version="1.0" encoding="UTF-8"?>\n"
> where MYFILE is a file handler.
s/handler/handle/
print $MYFILE qq{<?xml version="1.0" encoding="UTF-8"?>\n};
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Report this message |
#5: Re: print string in file
Posted on 2010-08-19 08:30:32 by Irfan Sayed
--0-2084779122-1282199432=:78646
Content-Type: text/plain; charset=us-ascii
Thanks all
it worked.
--Irfan
________________________________
From: Dr.Ruud <rvtol+usenet@isolution.nl>
To: beginners@perl.org
Sent: Wed, August 18, 2010 12:35:57 AM
Subject: Re: print string in file
Irfan Sayed wrote:
> print MYFILE "<?xml version="1.0" encoding="UTF-8"?>\n" where MYFILE is a file
>handler.
s/handler/handle/
print $MYFILE qq{<?xml version="1.0" encoding="UTF-8"?>\n};
-- Ruud
-- To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
--0-2084779122-1282199432=:78646--
Report this message |