Canonical answer from aaron_baugher: Think in terms of writing your original content to a new file with some elements removed.

BUT, re your narrative: Your phrase "the 8th column" should be "the 9th column" because your removal target is column 9. Just so it's clear, column 9 is the 8th element, $dataline[8], of an array (@arr) formed by splitting

XP.sta1    -41.5166    0.0513    0.6842    0.1794    0  CPHI.BHZ   300.2458   -42.2436

on white space because "XP.sta1" is $line[0].

my $dataline = "XP.sta1 -41.5166 0.0513 0.6842 0.1794 0 + CPHI.BHZ 300.2458 -42.2436"; my @arr = split /\s+/, $dataline; say "$arr[0], \t $arr[8]"; =head OUTPUT: XP.sta1, -42.2436 =cut

UPDATE: Your pseudocode (I hope it was intended as pseudocode) is far from actually useful and makes very little sense in terms of your problem statement. Something on this order might serve you better:

use 5.018; use Data::Dumper; my $mFile='DATA1127720.txt'; # OP's sample data open(my $tablec, "<", "$mFile") or die "Can't open the datafile: $!"; my @tablec = <$tablec>; for (@tablec) { my @XPinfo = split /\s+/, $_; chomp @XPinfo; my $delayTime = $XPinfo[8]; if ( $delayTime < -10 ) { say "\t OUT OF BOUNDS!!! \$delayTime: $delayTime"; }else{ say $delayTime; # revision to save desired lines left as an e +xercise } } =head EXECUTION D:\>perl 1127720FIXED.pl OUT OF BOUNDS!!! $delayTime: -42.2436 2.5545 2.6160 2.6006 =cut

Your questions will benefit from careful use of language. Your "code so far" could be read as reflecting the PM admonition 'show us your code' ONLY if it accurately reflected your question ...and were it compilable.


In reply to Re: Remove line from file based on numeric column value by ww
in thread Remove line from file based on numeric column value by Bama_Perl

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.