in reply to Print multiple value from file

Second if block

##if ($_=~ /ssId=\s*?(\S+)/) if ($_=~ /subSnpClass=\s*?(\S+)/)
poj

Replies are listed 'Best First'.
Re^2: Print multiple value from file
by Helan_Ahmed (Initiate) on Aug 10, 2015 at 10:11 UTC

    Oh sorry I made syntax error, I updated the script, but even when I search for subSnpClass, it print ssId twice

      After corrections to these 2 lines
      # $_= ~ /ssId=\s*?(\S+)/ $_ =~ /ssId=\s*?(\S+)/ #if ($_= ~ /subSnpClass=\s*?(\S+)/) if ($_ =~ /subSnpClass=\s*?(\S+)/)

      I got this result

      RS_SNPs subSnpClass3931 snp 76536062 snp
      maybe try this
      #!perl use strict; use warnings; my $Gene = 'ds_chY.xml'; my $outfile = 'ID.txt'; open my $out,'>',$outfile or die "Could not open file '$outfile' $!"; print $out "RS_SNPs\tsubSnpClass\n"; open my $in,'<',$Gene or die "Could not open file '$Gene' $!"; while (<$in>){ if ( /ssId=\s*"([^"]+)/ ){ print $out "$1\t"; } if ( /subSnpClass=\s*"([^"]+)/ ){ print $out "$1\n"; } }
      poj

        Oh, thanks a lot, it works now, but when I tried to print observed data such C/T, it does not work. and very thanks for your help