Hi Ary,

On Friday 21 Jan 2011 17:39:48 Ary Kleinerman wrote:
> Shlomi,
> 
> On Fri, Jan 21, 2011 at 12:13 PM, Shlomi Fish <shlo...@iglu.org.il> wrote:
> > 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.
> 
> The steve's mail, in this thread, said the following:
> 
> "I need to add 2 lines to a file and add the following text.
> 
> ENTHDR|1|3.0
> STAGEHDR|Barcoded"
> 
> So... my code do exactly that.
> 

Yes, but the subject line reads "Script to prepend text to beginning of file", 
so you have not noticed that.

> > As a result it suffers from many bad practices. See:
> > http://perl-begin.org/tutorials/bad-elements/
> > 
> I only showed the idea of the code. It's assumed that echo one should
> 
> improve it. This is the idea. But thats for this URL. I didn't know it and
> It's very useful.

You should not write such sub-optimal code especially not as response to 
beginners' questions on a beginners mailing list where they can learn bad 
practices from it.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/

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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to