By default, it is clear that the rows are distinguished by \ n, which we also call as line breaks.
When reading a sequence, when read by row, the line break is the standard.
The contents of the read STRAWBERRY1.GB file are as follows:
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1)
gene, partial CDs; Plastid.
/
Accession JX118024
//
VERSION JX118024.1 gi:402238751
KEYWORDS.
How
///
SOURCE plastid Fragaria vesca subsp. americana
First example: Default
Copy Code code as follows:
#!/bin/perl
my $record = ';
Open (Dnafilename, ' F:\\PERL\\STRAWBERRY1.GB ') | | Die ("Can not open the file!");
$record = <DNAFILENAME>;
Print $record;
This is the case without any changes, and is the default read one line at a time, the result is as follows:
f:\>perl\b.pl
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
If we change the value of $/, according to the characteristics of our documents, we first change to $/= "///\n;
Copy Code code as follows:
#!/bin/perl
my $record = ';
Open (Dnafilename, ' F:\\PERL\\STRAWBERRY1.GB ') | | Die ("Can not open the file!");
$/= "///\n";
$record = <DNAFILENAME>;
Print $record;
We have the following results:
f:\>perl\b.pl
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1)
gene, partial CDs; Plastid.
/
Accession JX118024
//
VERSION JX118024.1 gi:402238751
KEYWORDS.
How
///
We can see here that this line is delimited by///, and that the entire part of///is considered a row.
The same is not only the character can be used as a separator, letters can also join us to how the separator, $/= "how\n";
Copy Code code as follows:
#!/bin/perl
my $record = ';
Open (Dnafilename, ' F:\\PERL\\STRAWBERRY1.GB ') | | Die ("Can not open the file!");
$/= "how\n";
$record = <DNAFILENAME>;
Print $record;
The results are as follows:
C:\Documents and settings\administrator>f:perl\b.pl
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1)
gene, partial CDs; Plastid.
/
Accession JX118024
//
VERSION JX118024.1 gi:402238751
KEYWORDS.
How
C:\Documents and Settings\administrator>
Also, we can completely discard the traditional lines, for example, we use the accession in the fifth row of the example as delimiters:
Copy Code code as follows:
#!/bin/perl
my $record = ';
Open (Dnafilename, ' F:\\PERL\\STRAWBERRY1.GB ') | | Die ("Can not open the file!");
$/= "accession";
$record = <DNAFILENAME>;
Print $record;
The results are as follows:
f:\>perl\b.pl
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1)
gene, partial CDs; Plastid.
/
Accession
F:\>
One more example: Take/\n as the separator:
Copy Code code as follows:
#!/bin/perl
my $record = ';
Open (Dnafilename, ' F:\\PERL\\STRAWBERRY1.GB ') | | Die ("Can not open the file!");
$/= "/\n";
$record = <DNAFILENAME>;
Print $record;
We expect the result to be one row for the previous row to line fourth, but is this the result?
f:\>perl\b.pl
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1)
gene, partial CDs; Plastid.
/
Accession JX118024
//
F:\>
Why didn't it match up to the first one?
In fact here/this line does not have only one/, but there are other components here, we put this line completely deleted, and then re-enter only one/, we again to match
f:\>perl\b.pl
Locus JX118024 460 bp DNA linear PLN 25-sep-2012
DEFINITION Fragaria vesca subsp. americana RNA polymerase beta subunit (rpoC1)
gene, partial CDs; Plastid.
/
F:\>
This time we get the right results.