#!/usr/bin/perl -w use strict; while (<DATA>) { chomp; my ($basedir, @dot_names) = split(/\./,$_); my $type = (split('/',$basedir))[-1]; my $school = "null"; $school=$dot_names[-2] if (@dot_names >1); #open the file here and use the variables as prefix for each line print "type: $type school: $school\n"; } =prints type: abc school: null type: def school: null type: abc school: cole type: abc school: drew type: def school: cole type: def school: drew =cut __DATA__ /home/test/abc/.date_run_dir /home/test/def/.date_run_dir /home/test/abc/.date_file_sent.email@wolverine.cole.edu /home/test/abc/.date_file_sent.dp3.drew.net /home/test/def/.date_file_sent.email@wolverine.cole.edu /home/test/def/.date_file_sent.dp3.drew.net
In reply to Re: Help constructing proper regex to extract values from filenames and concurrently opening those same files to access records
by Marshall
in thread Help constructing proper regex to extract values from filenames and concurrently opening those same files to access records
by JaeDre619
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |