#/bin/perl/ use strict; use warnings; my $pdb; my $line; my @columns; open $pdb, '<', "structure.pdb" or die $!; #match string and select column my $string = "ATOM"; # match for ATOM my @nth_column; my $n = 1; # select 2nd column while ($line = <$pdb>) { if ($line =~ $string) { chomp $line; @columns = split /\s+/, $line; push @nth_column, $columns[$n]; #for testing: print "$columns[$n] \n"; } }