http://qs1969.pair.com?node_id=550555


in reply to Log File Parsing using "split"

Well, kind of minor, but:

Regarding
if ( $logfile =~ /WMS/ ) { $media = "wms"; $prefix = "/usr/home/script/${media}_cust/"; $suffix = ".$media.log"; } else { die "Unknown file format"; }
So, if it matches WMS, you set some variables, if not you die. Why, then, not just set the variables, then check the match and die? It's not (wholly) just golfing, I think it makes it a bit more logically clear.
$media='wms'; $prefix = "/usr/home/script/${media}_cust/"; $suffix = ".$media.log"; die "logfile name does not contain 'WMS'\n" if $logfile !~ /WMS/;
Also, is it now printing each full record whenever it starts with a digit? Or rather, is that what you're trying to do? I agree that you seem to be using $thiscust for multiple purposes -- once as the customer id and once as a file hande, and this seems unadvised.



-----------------
s''limp';@p=split '!','n!h!p!';s,m,s,;$s=y;$c=slice @p1;so brutally;d;$n=reverse;$c=$s**$#p;print(''.$c^chop($n))while($c/=$#p)>=1;