Hi Ary,

On Friday 21 Jan 2011 16:01:36 Ary Kleinerman wrote:
> A simple way:
> 
> #!/usr/bin/perl -w
> open FILE, ">>file.txt";
> print FILE "line1\n";
> print FILE "line2\n";
> print FILE "ENTHDR|1|3.0\n";
> print FILE "STAGEHDR|Barcoded\n";
> close FILE;
> 

This script will *append* 4 lines to "file.txt" - not prepend them and 
furthermore does not use:

1. Three args open.

2. Lexical filehandles.

3. or die after an open.

4. "use strict;" and "use warnings;".

5. Still uses the "-w" flag.

As a result it suffers from many bad practices. See:

http://perl-begin.org/tutorials/bad-elements/

From where did you learn Perl that you recommend writing such crude code?

Regards,

        Shlomi Fish

> On Thu, Jan 20, 2011 at 3:57 PM, steve1040 <[email protected]> wrote:
> > I need to add 2 lines to a file and add the following text.
> > 
> > ENTHDR|1|3.0
> > STAGEHDR|Barcoded
> > 
> > I don't have any idea how to do this in Perl
> > 
> > Thanks
> > Steve
> > 
> > 
> > --
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> > http://learn.perl.org/

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

Chuck Norris can make the statement "This statement is false" a true one.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to