Hi Perlmonks... I am very confused with the quotes '"'in Perl.. Actually.. when I want to print or search '"' in some var, do I have to use \" instead of only ". Actually I have tried using \" but it still give me some error. Below are input and output file:
INPUT DATE 13-JUN-2000 COMMERCIAL SUPPLIERS SEQUENCE /exon="49-333" /intron="1-48;334-385" // DATE 14-JUN-2000 COMMERCIAL SUPPLIERS SEQUENCE /exon="1-120" /intron=" " // OUTPUT EXPECTED DATE "13-JUN 2002" Exon {Translation%49-333} Intron {Translation%1-48} Intron (Translation%334-385} DATE "14-JUN 2002" Exon {Translation -} Intron {Translation%1-120} REAL OUTPUT "ATE "13-JUN-2000 }xon {Translation%49-333 Intron {Translation%1-48} }ntron {Translation%334-385 "ATE "13-JUN-2000 }xon {Translation%1-120 }ntron {Translation%
This is my code:
#!/usr/local/bin/perl -w # A program that accept an input file: Scorpion database from Gen Bank # and will output the database in BioWare format my $file1="$ARGV[0]" #var to save the input database my $result=">".$ARGV[1]; my $counter=1; open(INFO1,$file1) or die "Can't open $file1.\n";#open file1 open(OUT,$result) or die "Can't open $result.\n"; #foreach line in the files foreach(<INFO1>) { if(/^DATE\s*(.*)-(.*)-(.*)/){ print 'DATE'."\t".'"'."$1-$2-$3".'"'."\n"; } elsif(/\s*\/intron=(.+)\n/) { my $item; my $local=$1; $local =~ s/\"//g; foreach $item (split('\;',$local)) { print "Intron\t \{Translation%$item\}\n"; } #end foreach } #end elsif elsif(/\s*\/exon=(.+)\n/) { my $item; my $local=$1; $local =~ s/\"//g; foreach $item (split('\;',$local)) { print "Exon\t", " \{Translation\%","$item\}","\n"; }#end foreach }#end elsif }
I have also tried to put the date together in one string:
print "DATE\t \"$1-$2-$3\"\n";
But it also give me the same result as above.

The Gory details of parsing quoted constructs ( in perldoc ) doesn't really help me. Is there something wrong in my code? Thanks so much...


In reply to strange quotes by agustina_s

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.