Hi Kaustav,
You can do something such as:
#!/usr/bin/perl -w
use strict;
my $file = "foo.file";
open(FILE, $file) or die "Can't open $file: $!";
my @lines= <FILE>;
close FILE;
@lines = grep {!/\.(txt|scc)$/} @lines;
print qq{$_\n} for @lines;
This isn't "deleting" from the array, rather reforming it.
Cheers,
Kevin
On Fri, Apr 27, 2001 at 01:25:40PM +0100, Kaustav Bhattacharya
([EMAIL PROTECTED]) spew-ed forth:
> Am rather a beginner at perl and was wondering how to do the following. I've
> read in a text file containing a list of file paths. the list is read in to
> an array. I want to scan through the whole array and remove all lines with
> end as .txt and .scc. i.e remove that element in the array. My file list
> looks like this:
>
> D:\Liberate\Connect\app\pages\servicemanager\splash.gif
> D:\Liberate\Connect\app\pages\servicemanager\splash.html
> D:\Liberate\Connect\app\pages\servicemanager\vssver.scc
> D:\Liberate\Connect\app\pages\servicemanager\sounds\enter.wav
> D:\Liberate\Connect\app\pages\servicemanager\sounds\key.wav
> D:\Liberate\Connect\app\pages\servicemanager\sounds\vssver.scc
>
>
> and my code thus far is:
>
> #\usr\local\bin\perl
>
> $file = 'flashimage.txt'; # Name the file
> open(INFO, $file); # Open the file
> @lines = <INFO>; # Read it into an array
> close(INFO); # Close the file
>
> foreach $eachline (@lines) {
> $eachline =~ s/scc//g
> }
>
> print @lines;
>
>
--
[Writing CGI Applications with Perl - http://perlcgi-book.com]
The difference between whining and advocacy is great. It took me seven years to
figure that out.
-- Michael J. Fox