Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Checking is variable contains literal periods in if statment...

by kennethk (Monsignor)
on Mar 05, 2014 at 18:42 UTC ( #1077130=note: print w/ replies, xml ) Need Help??


in reply to Checking is variable contains literal periods in if statment...

What makes you think your conditional is failing? The following modification of your posted code

#!/usr/bin/perl -w use strict; #my $filename = "quotas.txt"; #open FILE, "$filename" or die "Cannot open $filename for reading: $!\ +n"; #open REPORT, ">report.csv" or die "Cannot open report.csv for writing +: $!\n"; undef $/; my $file = <DATA>; $/ = "\n"; my ($header,@records) = split /directory\s+/, $file; while (@records){ my $line = shift @records; if ($line !~ /\.\.\./) { # my ($path, $usage, $threshold) = $line =~ / (\S+) #grab pat +h # \D+ # (\d\S+) #stop at the first digit for usage # .*? # \[hard-threshold\] #seek out threshold # .*? # \(\s+(.*?)\) #capture threshold inside parens #/sx; # print REPORT "$path,$usage,$threshold\n"; print "NO ELLIPSIS: $line"; } else { print "ELLIPSIS: $line"; } } __DATA__ Type Path Policy Snap +Usage -------------------- ------------------------------ ----------- ----- +-------- directory /ifs/home/admin enforcement no + 32K [hard-threshold] ( 1.0G) [hard-threshold-exceeded] (no) [container] [usage-with-no-overhead] ( 32K) [usage-with-overhead] ( 103K) [usage-inode-count] (4) directory /ifs/home/ftp enforcement no + 31B [hard-threshold] ( 1.0G) [hard-threshold-exceeded] (no) [container] [usage-with-no-overhead] ( 31B) [usage-with-overhead] ( 6.0K) [usage-inode-count] (3) directory /ifs/gpd/data/trufusion/dat... enforcement no + 43G /ifs/gpd/data/trufusion/data0003 [hard-threshold] ( 80G) [hard-threshold-exceeded] (no) [container] [usage-with-no-overhead] ( 43G) [usage-with-overhead] ( 95G) [usage-inode-count] (606)
yields
NO ELLIPSIS: /ifs/home/admin enforcement no 32K + [hard-threshold] ( 1.0G) [hard-threshold-exceeded] (no) [container] [usage-with-no-overhead] ( 32K) [usage-with-overhead] ( 103K) [usage-inode-count] (4) NO ELLIPSIS: /ifs/home/ftp enforcement no 31B + [hard-threshold] ( 1.0G) [hard-threshold-exceeded] (no) [container] [usage-with-no-overhead] ( 31B) [usage-with-overhead] ( 6.0K) [usage-inode-count] (3) ELLIPSIS: /ifs/gpd/data/trufusion/dat... enforcement no 43G /ifs/gpd/data/trufusion/data0003 [hard-threshold] ( 80G) [hard-threshold-exceeded] (no) [container] [usage-with-no-overhead] ( 43G) [usage-with-overhead] ( 95G) [usage-inode-count] (606)
which looks kosher to me.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re: Checking is variable contains literal periods in if statment...
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077130]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2014-09-22 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (189 votes), past polls