RE: __DATA__ Token Problem
Thanks for your Tips. my $data = tell DATA; print $data\n; truncate $0, $data; This looks very promising to me. Therefor that the host is a Unixsystem, I might be able to solve my problem. I don´t really understand $0 at the moment. I thought its the name the script was started with. Bastian -Ursprüngliche Nachricht- Von: John W. Krahn [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 6. Juli 2004 06:37 An: Perl Beginners Betreff: Re: __DATA__ Token Problem On Monday 05 July 2004 05:07, Bastian Angerstein wrote: Hello, Hello, I have a few questions regarding to the DATA Filehandle: 1. This handle ist opend by default or do I have to open it by myself? It is opened by default. 2. Is it possible to change to content of what the handle so that the __DATA__ Sektion of my skript changes? It depends on the operating system. *nix will allow you to modify any file if you have permission to do so. Some versions of DOS\Windows will allow you to modify running programs but most won't. 3. Can I delete anything data from DATA so that the __DATA__ section is empty? Again, it depends on what the operating system will allow. This works on my Linux OS: #!/usr/bin/perl use warnings; use strict; my $data = tell DATA; print $data\n; truncate $0, $data; __DATA__ line 1 line 2 line 3 line 4 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: __DATA__ Token Problem
On Tuesday 06 July 2004 03:47, Bastian Angerstein wrote: my $data = tell DATA; print $data\n; truncate $0, $data; This looks very promising to me. Therefor that the host is a Unixsystem, I might be able to solve my problem. I don´t really understand $0 at the moment. I thought its the name the script was started with. Yes it is. That is after all the file that you want to truncate. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
__DATA__ Token Problem
Hello, I have a few questions regarding to the DATA Filehandle: 1. This handle ist opend by default or do I have to open it by myself? 2. Is it possible to change to content of what the handle so that the __DATA__ Sektion of my skript changes? 3. Can I delete anything data from DATA so that the __DATA__ section is empty? Deutsche Telekom AG T-Com, Technische Infrastruktur Niederlassung Überregional Bastian Angerstein Network Support Center - Network Management Support Maybachstr.57; D-70469 Stuttgart +49 711 8939 1889 (Tel.) +49 711 8939 6604 (Fax) mailto:[EMAIL PROTECTED] http://www.t-com.de -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: __DATA__ Token Problem
Hi Bastian, Bastian Angerstein wrote on 05.07.2004: Hello, I have a few questions regarding to the DATA Filehandle: 1. This handle ist opend by default or do I have to open it by myself? According to the docs, it should be opened by the __DATA__ token: The __DATA__ token opens the DATA handle in whichever package is in effect at the time, so different modules can each have their own DATA filehandle, since they (presumably) have different package names. 2. Is it possible to change to content of what the handle so that the __DATA__ Sektion of my skript changes? I don't think it's a good idea to have a script write to itself. The DATA section is meant to keep static input out of the way of your processing commands. If you want to modify it, I suggest storing it outside of the script. - Jan -- If all else fails read the instructions. - Donald Knuth -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: __DATA__ Token Problem
On Jul 5, 2004, at 2:57 PM, Jan Eden wrote: 2. Is it possible to change to content of what the handle so that the __DATA__ Sektion of my skript changes? I don't think it's a good idea to have a script write to itself. The DATA section is meant to keep static input out of the way of your processing commands. If you want to modify it, I suggest storing it outside of the script. The above warning is excellent and VERY true, but to be complete and answer the question: Yes, it is possible. You reopen the DATA handle in read write mode. Careful though, as Jan said, Here be dragons! James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: __DATA__ Token Problem
Bastian Angerstein wrote: I have a few questions regarding to the DATA Filehandle: 1. This handle ist opend by default or do I have to open it by myself? 2. Is it possible to change to content of what the handle so that the __DATA__ Sektion of my skript changes? 3. Can I delete anything data from DATA so that the __DATA__ section is empty? What did you try so far? :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: __DATA__ Token Problem
On Monday 05 July 2004 05:07, Bastian Angerstein wrote: Hello, Hello, I have a few questions regarding to the DATA Filehandle: 1. This handle ist opend by default or do I have to open it by myself? It is opened by default. 2. Is it possible to change to content of what the handle so that the __DATA__ Sektion of my skript changes? It depends on the operating system. *nix will allow you to modify any file if you have permission to do so. Some versions of DOS\Windows will allow you to modify running programs but most won't. 3. Can I delete anything data from DATA so that the __DATA__ section is empty? Again, it depends on what the operating system will allow. This works on my Linux OS: #!/usr/bin/perl use warnings; use strict; my $data = tell DATA; print $data\n; truncate $0, $data; __DATA__ line 1 line 2 line 3 line 4 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response