jitendra B wrote:
Hi All,

Hello,

Can you please let me know the following snippset? why it is used for?


select( STDERR );

Select STDERR as the default filehandle.


$| = 1;

Turn on autoflush for the current default filehandle.
(Redundant because STDERR autoflushes by default.)


select( STDOUT );

Select STDOUT as the default filehandle.


$| = 1;

Turn on autoflush for the current default filehandle.


print STDERR "\nThis is india\n\n";
  print STDERR "Usage: This is build";
  print STDERR "where: base PL label\n";

Print some stuff.


and second question
****************
  second question:- I want to open a file read+write mode and change the
some content in same file without creating another file and copy to it.

MY SCRIPT(Not working as i wish to )
********************
#!/usr/bin/perl

The next two lines should be:

use warnings;
use strict;


open(FILE,">test.txt") or die "Could not open the file: $!";

You are opening "test.txt" in write mode which means that the file will be truncated to zero length first, effectively erasing all the data.


@file=<FILE>;

foreach (@file)
{
       $_=~s/BLR/bangalore/g;

       print "$_";
}
close(FILE);


#!/usr/bin/perl
use warnings;
use strict;

use Tie::File;

tie my @file, 'Tie::File', 'test.txt' or die "Cannot open 'test.txt' because: $!";

s/BLR/bangalore/g for @file;

untie @file;




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
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