Gossamer Forum
Home : General : Perl Programming :

writing Perl scripts with binmode

Quote Reply
writing Perl scripts with binmode
I have a perl script which writes other perl scripts.

Should I use normal File printing method or binmode to write these new Perl scripts?

open(FILE, ">test.pl");
print FILE qq|
#!/usr/bin/perl
blah blah blah
|;
close FILE;

Thanks for input.

Zeshan.
Quote Reply
Re: [zeshan] writing Perl scripts with binmode In reply to
you don't want to use binmode when writing ASCII files. binmode is for anything that is not plain text, like images.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [zeshan] writing Perl scripts with binmode In reply to
Something like this should work;

Code:
open(FILE, ">test.pl") || die "Error: $!";
print FILE q{#!/usr/bin/perl

blah blah blah

};
close FILE;

As Andrew said, you don't need BINMODE for ASCII type files.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] writing Perl scripts with binmode In reply to
Looks like I spawned a new name :-)

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] writing Perl scripts with binmode In reply to
Blush

I meant Philip, of course :p

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] writing Perl scripts with binmode In reply to
actually, Andrew is my middle name.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [zeshan] writing Perl scripts with binmode In reply to
Hi all,

I've been trying a similar thing. However the Perl file that my program creates causes a 500 error.

All the code generated works. If I copy the raw code into my text editor and upload the result it works just fine. I therefore assume that the cause of the error is something to do with not saving the file in an ascii format?? Or maybe my server has a problem with running files created on the server itself... Any advice on this would be much appreciated!

Thanks! Cool