spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Comment out different ranges of values in a file - Perl


Your %hash should actually hold keys (numbers) which you want to prefix with #

#!/usr/bin/perl

use warnings;
use strict;

# my %hash = (2,4,7,8);
my ($rangefile) = @ARGV;

open (my $RANGE, "<", $rangefile) or die
"Couldn't open $rangefile: $!
";
my %hash;
while ( <$RANGE> ) {
        my ($begin, $end) = split;
        @hash{$begin .. $end} = ();
}
close $RANGE;

while (<DATA>) {
        my ($num) = /^(d+)/ or next;
        s/^/#/ if exists $hash{$num};
        print;
}

__DATA__
1
2
3
4
5
6
7
8
9
10

Categories : Perl

Related to : Comment out different ranges of values in a file - Perl
SQL query to get average values over a list of time ranges
case based aggregation is one way to do this in single query. SELECT AVG(case when dateColumn > startRange1 && dateColumn < endRange1 then column1 end) as range1Avg, AVG(case when dateColumn > startRange2 && dateColumn < endRange2 then column1 end) as range2Avg FROM Table1

Categories : SQL
Date ranges with DST in javascript
Both the JavaScript Date object and the moment object in moment.js are for representing a specific instant in time. In other words, a date and a time. They internally track time by counting the number of milliseconds that have elapsed since the Unix Epoch (Midnight, Jan 1st 1970 UTC) - ignoring leap seconds. That means, fundamentally, they are not the best way to work with whole calendar dates.

Categories : Javascript
Version ranges in buildout.cfg
A version spec with something = <= 1234 is invalid. Both an = and a <= isn't the right syntax. I'd treat the problem differently. You use your setup.py's install_requires already to restrict buildout a version between 1.7 and 1.8. Buildout will respect that requirement, so you don't need to duplicate it in the buildout config. What buildout's version pinning is for is exactly that: pinning

Categories : Python
Algorithm to Compare Ranges
You need to use BETWEEN operator like select * from table1 where values between 30 and 60; (OR) where values between 59 and 100; You can as well use > and < operator to get the same evaluation select * from table1 where values >= 30 and values <= 60; If it's a range comparison as Strawberry pointed in comment then you can check like where 30 < 59 and 59 < 60 and 60 < 1

Categories : Mysql
Appending ranges in loop
First off, the end result of your code would appear to be similar to just auto cc(aaa); boost::stable_sort(cc); (Assuming, from your sample code, that aaa contains integers in the range [0..size()-1)) If you can afford to simply copy, just use a backinsert iterator: std::vector<int> cc; for (size_t i = 0; i < aaa.size(); ++i) boost::copy(boost::equal_range(aaa, i), back_inserter(

Categories : C++
Recently Add
unable to connect selenium webDriver through perl bindings
SSL error calling Perl web service via https using LWP
SOAP::Lite always faults in debug mode
perl referencing a hash outside of the scope that populated it (histogram)
Perl script to print out all the lines containing a keyword and the line below it
PERL Unicode Escape string pass from command line argument wrong output
Perl process crashes after handling signal
Marpa: Can I explicitly disallow keywords as identifiers?
Perl: Import text, containing ÅÄÖ, from file
error using perl - Proc::ProcessTable. works in cmd line, not in .pl file
DBIx::Class chaining resultsets with same table in prefetch
Time as input, print timetable in Perl
compare values of different tables perl
Automatically increasing ID generation using PERL
Syntax Error, first line after dostuff
Delete files in a folder using Perl
Perl '-d' operator is not detecting a directory
Perl appending text to new line
write_timeout in IO::Socket::Timeout
Using ForkManager and Perl properly?
Is a cyclic dependency solved with require?
Posting metric to google analytics from perl script
How can I check if a user enters my page the first time?
Sorting arrays of intervals in perl?
Perl: How to get the link target of a soundcloud feed mp3
Uninitialized value in concatenation
Perl code - pipe "|" in `open()` statement
perl command line backticks with matrix
Perl OO - Creating a list of objects
extract gene-id + function annotation from .gff
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.