G'day CTinMich,
Welcome to the monastery.
Your current solution seems to be doing a lot of unnecessary processing: slurp entire file; split into records; loop through those records. Depending on the size of the input file, that could be using a lot of memory. Depending on the number of records, shift @records could also be doing a lot of unnecessary processing.
The following (simpler) solution has none of those issues.
#!/usr/bin/env perl use strict; use warnings; { local $/ = "\ndirectory"; while (<DATA>) { next if $. == 1; /(\S+)\D+(\d\S+)\s+(\/\S+|)[^(]+\(\s*([^)]+)/; my ($path, $usage, $threshold) = ($3 || $1, $2, $4); print "path=$path; usage=$usage; threshold=$threshold\n"; } } __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)
Output:
path=/ifs/home/admin; usage=32K; threshold=1.0G path=/ifs/home/ftp; usage=31B; threshold=1.0G path=/ifs/gpd/data/trufusion/data0003; usage=43G; threshold=80G
-- Ken
In reply to Re: Checking is variable contains literal periods in if statment...
by kcott
in thread Checking is variable contains literal periods in if statment...
by CTinMich
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |