in reply to getting a sequence of numbers and leters

It might be easier to split the line on white space and slice out the relevant items.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<__EOD__ or die $!; BOGUS PPI3_SYNY3 276 aa linear BCT 13-NOV-2019 __EOD__ chomp( my $line = <$inFH> ); close $inFH or die $!; my( $bogus, $acids ) = ( split m{\s+}, $line )[ 1, 2 ]; say qq{Bogus : $bogus\nNumber of amino acids : $acids} +;' Bogus : PPI3_SYNY3 Number of amino acids : 276

I hope this is helpful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: getting a sequence of numbers and leters
by Marshall (Canon) on Mar 24, 2020 at 18:21 UTC
    I work with many space separated files and I agree that split is often the easiest way to go. I would recommend using the character form of the "split on whitespace" in this situation because it has the property of ignoring leading whitespace, as I demo at Re: But I want null values in my array. This is just one of many, "yeah but's" and exceptions that I've discovered over time.