vis1982 has asked for the wisdom of the Perl Monks concerning the following question:
ACEEWSMKIIWSDJDWKDKEKSSAQWE
and want to extract lines with option 5-10 with output like
SMKII
The code isBut Gave error.What can be possible error?#!/usr/bin/perl use strict; use warnings; if ( $#ARGV < 2 ) { print "Usage: extract.pl firstLine lastLine filename\n"; exit 1; } my $start = $ARGV[0]; my $stop = $ARGV[1]; my $file = $ARGV[2]; open (FILE,$file) || die "Can't open file \"$file\".\n"; my $count=0; while () { $count++; if ( $count >= $start && $count <= $stop ) { print ; } } close(FILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print and extract the line
by Corion (Patriarch) on Jul 07, 2010 at 13:04 UTC | |
by suhailck (Friar) on Jul 07, 2010 at 13:19 UTC | |
|
Re: print and extract the line
by Neighbour (Friar) on Jul 07, 2010 at 13:06 UTC | |
by ww (Archbishop) on Jul 07, 2010 at 15:05 UTC | |
|
Re: print and extract the line
by ww (Archbishop) on Jul 07, 2010 at 14:08 UTC | |
by vis1982 (Acolyte) on Jul 07, 2010 at 14:51 UTC | |
by Hugmeir (Sexton) on Jul 07, 2010 at 15:37 UTC | |
by ww (Archbishop) on Jul 07, 2010 at 18:25 UTC | |
|
Re: print and extract the line
by Tux (Canon) on Jul 07, 2010 at 13:27 UTC | |
by vis1982 (Acolyte) on Jul 07, 2010 at 14:48 UTC | |
by Marshall (Canon) on Jul 07, 2010 at 15:59 UTC | |
|
Re: print and extract the line
by johngg (Canon) on Jul 07, 2010 at 16:12 UTC | |
|
Re: print and extract the line
by Fletch (Bishop) on Jul 07, 2010 at 13:14 UTC | |
|
Re: print and extract the line
by suhailck (Friar) on Jul 07, 2010 at 13:17 UTC |