On Mon, Jun 11, 2012 at 10:42 PM, Brian Fraser <frase...@gmail.com> wrote: > On Mon, Jun 11, 2012 at 10:49 AM, lina <lina.lastn...@gmail.com> wrote: >> >> Hi, >> >> >> $ for i in `seq -f '%02g' 1 10` ; do echo $i ; done >> 01 >> 02 >> 03 >> 04 >> 05 >> 06 >> 07 >> 08 >> 09 >> 10 >> >> I wonder how can I get something like above in the perl. >> > > for my $i ("01".."10") { > say $i; > } > Thanks all.
Here is the script I wrote (seems it works, but not so sure it's correct or not.) For a series of files. I want to find "7" out in each line of the first file. and then its position was took, the final line the "7" position is "9", suppose Then in the next file, I wish to find the "9" out. one by one like this. #!/usr/bin/env perl use strict; use warnings; use autodie qw(open close); use Carp qw(croak); use 5.012; my $tra=7; my @files=("01".."40"); foreach(@files){ $tra=process_onefile("replica_index_$_.xvg"); } sub process_onefile{ my $b; open my $fh, '<', @_; while(<$fh>){ my @Tem_rep = split ' ', $_; my $index = 1; ++$index until $Tem_rep[$index] == $tra; say $index-1; $b = $index-1; } return $b; } Thanks ahead for any improvement you may suggest, Best regards, -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/