in reply to =~ matches non-existent symbols
Using while (<>) is good (even with slurp-mode input) because that way you can pipe data from any other process as input to the script, or you can put one or more file names on the command line (e.g. "*.txt").#!/usr/bin/perl use strict; use warnings; $/ = undef; # slurp-mode for input, just in case while ( <> ) { # reads stdin or all file names in ARGV s/\s+//g; # remove whitespace tr/ACGTacgt//d; # remove all acgt if ( length() ) { # anything left? print "$ARGV bad content: $_\n"; } else { print "$ARGV all clean!\n"; } }
When you read multiple input files in one run, putting "$ARGV" in the print statements tells you which files are good or bad.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: =~ matches non-existent symbols
by Anonymous Monk on Nov 17, 2014 at 04:20 UTC | |
by graff (Chancellor) on Nov 17, 2014 at 10:18 UTC | |
by Laurent_R (Canon) on Nov 17, 2014 at 07:20 UTC | |
|
Re^2: =~ matches non-existent symbols
by ikegami (Patriarch) on Nov 19, 2014 at 15:31 UTC | |
by graff (Chancellor) on Nov 20, 2014 at 05:25 UTC | |
by ikegami (Patriarch) on Nov 21, 2014 at 19:42 UTC |