CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [kdejan] if else equality question: Edit Log



Kenosis
User

Feb 24, 2013, 6:11 PM


Views: 597
Re: [kdejan] if else equality question

Here's another option:


Code
use strict; 
use warnings;

while (<>) {
chomp;

if ( length $_ < 1480 ) {
print "$_\n";
next;
}

s/(.{1415})//;
tr/AaGg/0011/;

print "$1$_\n";
}


Usage: perl script.pl inFile [>outFile]

The substitution matches and captures the first 1415 characters of the read line (contained in the default scalar $_), then removes them. The variable $1 now contains the pre-gap string, and $_ contains the post-gap string. A transliteration (implicitly) operates on $_, and then the pre-gap and post-gap strings are printed.

The optional command-line parameter, if used, redirects output to a file.


(This post was edited by Kenosis on Feb 24, 2013, 6:19 PM)


Edit Log:
Post edited by Kenosis (User) on Feb 24, 2013, 6:19 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives