Hey there, not sure if you're still looking for solutions since this is from a couple weeks ago.
If you are still looking, what would be the duplicates that you want to exclude? Would it just be filenames that are duplicated or some portion of the path, or something else?
Thank you for the response, the field has values that are a list, some examples would be:
'1,'
'1,2,3,4,5,'
'1,2,3,5,6,10,'
And I'd like to convert it to a range (or ranges) if possible. Using those examples, something like:
'1'
'1-5'
'1-3,5-6,10'
I've continued searching and it seems the...
I have a series of string values that are generally a contiguous list of integers in a format of "1,2,3,4,5," -- although sometimes there can be contiguous ranges mixed with non-contiguous entries, such as "0,1,2,3,10,13,20,21,22,".
What I'm hoping to do is convert them to a range notation. So...
It seems like the first line of data (the one with 'green') may have an error -- and there was no attachment. So taking what you entered as a sample, here you go:
use warnings;
use strict;
my %tiers;
my $fh = *DATA;
my $headers = <$fh>; # Grab Headers
while (<$fh>) {
next if /^\s*$/; # Skip...
Could you please provide some actual sample log data (with any sensitive information scrubbed) and your expected results for any of that data?
Otherwise we're just making guesses. Thanks!
I might do something like this:
use warnings;
use strict;
use File::Find;
my $dir = './txt/'; # Change this to your directory
my $month = '07'; # Get this from STDIN, command line, etc.
find( {wanted => \&remove_files_by_month, follow => 0}, $dir);
sub remove_files_by_month() {
if (-f $_) {...
Looks like you might need to write some code to handle the scrolling?
I found this looking around on google: [link]http://rob.themayfamily.me.uk/perl/win32-gui/scrollbars/sb3[/url]
That link is to part 3 of the tutorial which is where the scroll bars are added (I believe you said you already...
What is the data type of that field in your database? If you print everything without using printf/sprintf (so, just using print) are the values what you expect (without the leading zeros)?
I imagine it's getting changed somewhere else. If I run the code you posted, I get the following results:
NFC_AMT before adding zeroes: 115
NFC_AMT after adding zeroes: 0000115
Not exactly what you're looking for since it's not a one-liner, but if you're going to be renaming files like this a lot -- this could come in handy:
#!/usr/bin/perl
# -w switch is off bc HERE docs cause erroneous messages to be displayed under Cygwin
#From the Perl Cookbook, Ch. 9.9
# rename -...
If you're just going to be using single letter switches, I'd suggest using GetOpt::Std.
If you're going to stick with GetOpt::Long, the module is working like it should. Your 'e' option requires a string as an argument, it got one: '-d'. So -d isn't being read as a switch/option, but as an...
Did you read the perdocs on Getopt::Long? There's a lot in there, but the bit below was near the top.
In the "Getting Started with Getopt::Long" section, the approximately fourth paragraph reads:
The auto_abbrev option looks like it handles the specific behavior you were noticing.
So, first, in order to get the result you expect, you could use this instead:
for(my $i = 0; $i <= $#a1; $i++) {
$h1{$i} = [@a1]; #\@a1;
}
The difference there is that $h1{$i} is assigned a reference to an anonymous array that contains all the elements in @a1 (so there will be a unique...
Oops, use this instead (works the same, but less changes if $sort_idx needs to be updated.)
sub sort_sub {
my $sort_col = shift;
my $sort_idx = $sort_col - 1; # May not be necessary to subtract 1
if ($a->[$sort_idx] eq $b->[$sort_idx]) {
if (scalar @_) {
return &sort_sub(@_);
}...
This should give you a start, you'll probably want to do a bit more error checking in the sort subroutine, but a custom sort seems like the way to go. The sort sub below uses recursion to deal with the unknown number of columns that will be used to sort.
Since I'm not entirely sure what you're...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.