in reply to Why this script is not running on windows?
Hi abhikalrt53,
Why not turn it into a real script?
$ perl -MO=Deparse -ane '$s = ""; foreach (@F) { /(\d+)-(\d+)/ and $2 +- $1 >= 30 and $s .= " $1-$2" } print "$F[0]$s\n" if $s' LINE: while (defined($_ = <ARGV>)) { our @F = split(' ', $_, 0); $s = ''; foreach $_ (@F) { $s .= " $1-$2" if /(\d+)-(\d+)/ and $2 - $1 >= 30; } print "$F[0]$s\n" if $s; }
With a bit of cleanup:
#!/usr/bin/env perl use warnings; use strict; while (<>) { my @fields = split; my $s = ''; for (@fields) { if ( /(\d+)-(\d+)/ && $2 - $1 >= 30 ) { $s .= " $1-$2"; } } print "$fields[0]$s\n" if $s; }
Hope this helps,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why this script is not running on windows?
by abhikalrt53 (Novice) on Nov 01, 2016 at 11:01 UTC | |
by haukex (Archbishop) on Nov 01, 2016 at 11:12 UTC | |
by abhikalrt53 (Novice) on Nov 01, 2016 at 11:22 UTC |