Note that there are some explanatory texts on larger screens.

plurals
  1. POhelp extracting both contents of a file and values from the same filename using perl
    primarykey
    data
    text
    <p>Sorry, if this to verbose, but I have a perl script that is partly working. I have a regular expression that extracts either <code>foo|bar</code> and a prefix on a string given. But the problem is my strings are also FILE NAMES which I also want to open and retrieve its contents like <code>locale_col.dat.2010120813.png</code> (see Expected Output below).</p> <p>The output now looks like this:</p> <pre><code>Content:/home/myhome/col/.my_file_del.mail@locale.foo.org Key1:foo:Key2:col Content:/home/myhome/col/.my_file_del.dp1.bar.net Key1:bar:Key2:col Content:/home/myhome/jab/.my_file_del.mail@locale.foo.org Key1:foo:Key2:jab Content:/home/myhome/jab/.my_file_del.dp1.bar.net Key1:bar:Key2:jab </code></pre> <p>I need help tweaking this so that in one pass I can read the list of strings (file names from FileList.txt), extract particular values from the file name path (using regex) and open the file name for its contents. I hope that makes sense or am I looking at breaking this into 2 perl scripts? Thanks for your input.</p> <p>Code (WIP):</p> <pre><code>open FILE, "&lt; /home/myname/FileList.txt"; while (&lt;FILE&gt;) { my $line = $_; chomp($line); print "Content:$_"; #This is just printing the filenames. #I want to get the contents of those file names instead. Stuck here. if ($line =~ m/home\/myname\/(\w{3}).*[.](\w+)[.].*/){ print "Key1:$2:Key2:$1\n"; } } close FILE; </code></pre> <p>Contents of FileList.txt:</p> <pre><code>/home/myname/col/.my_file_del.mail@locale.foo.org /home/myname/col/.my_file_del.dp1.bar.net /home/myname/jab/.my_file_del.mail@locale.foo.org /home/myname/jab/.my_file_del.dp1.bar.net </code></pre> <p>Example content of one of the listed files: (which I need help here with to extract)</p> <pre><code>$ cat .my_file_del.mail@locale.foo.org locale_col.dat.2010120813.png </code></pre> <p>Expected Output:</p> <pre><code>Content:locale_col.dat.2010120813.png Key1:foo:Key2:col ... .. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload