When the parsing context of the perl variable $/is in row mode, $/defines the shard

Source: Internet
Author: User

By default, \ n is often used as the line break.
When reading a sequence by row, it is based on a line break.

The content of the read strawberry1.gb file is 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

Example 1: DefaultCopy codeThe Code is as follows :#! /Bin/perl
My $ record = '';
Open (DNA filename, 'f: \ perl \ strawberry1.gb') | die ("can not open the file! ");
$ Record = <dna filename>;
Print $ record;

This is the case where no changes are made, that is, each row read by default. 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 $/, we first change it to $/= "// \ n;

Copy codeThe Code is as follows :#! /Bin/perl
My $ record = '';
Open (DNA filename, 'f: \ perl \ strawberry1.gb') | die ("can not open the file! ");
$/= "// \ N ";
$ Record = <dna filename>;
Print $ record;

The result is 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 JX118024
//
VERSION JX118024.1 GI: 402238751
KEYWORDS.
How
///

Here, we can see that this line is separated by //, and the entire part above is regarded as a line.

It can also be used as a separator and a letter. We use how as the separator, $/= "how \ n ";

Copy codeThe Code is as follows :#! /Bin/perl
My $ record = '';
Open (DNA filename, 'f: \ perl \ strawberry1.gb') | die ("can not open the file! ");
$/= "How \ n ";
$ Record = <dna filename>;
Print $ record;

The result is as follows:
C: \ Documents ents 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 ents and Settings \ Administrator>

Similarly, we can discard rows in the traditional sense. For example, we use the ACCESSION of the fifth line as the separator:

Copy codeThe Code is as follows :#! /Bin/perl
My $ record = '';
Open (DNA filename, 'f: \ perl \ strawberry1.gb') | die ("can not open the file! ");
$/= "ACCESSION ";
$ Record = <dna filename>;
Print $ record;

The result is 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: \>

Let's take an example: Use/\ n as the separator:

Copy codeThe Code is as follows :#! /Bin/perl
My $ record = '';
Open (DNA filename, 'f: \ perl \ strawberry1.gb') | die ("can not open the file! ");
$/= "/\ N ";
$ Record = <dna filename>;
Print $ record;

The expected result should be a line before the fourth line, but is the result true?
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 the first/match?

In fact, here/this line does not only have one/, but there are other components here. We will delete this line completely, and then enter only one/, and we will match it again.
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: \>
The correct result is returned this time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.