So what I hope to manage to do is:
1. read in a file
2. find some entries
3. use those entries to proceed
So first I'm changing to the directory where those files are. They are into a series of folders and subfolders and I am looping (rest of script not shown) to find them all.
Then I'm checking if this file exists and, if it does, I'm opening it for read.
Then, what I want to do but I don't know how to implement it, is find the 3 entries that exist in this file. These 3 entries are space delimited and I have already initiated them as variables from before in my script. My files look like this, for example: FOLDING SHAPE OXYGEN
so I want to match those three entries (folding, shape, oxygen) using split. These three entries already correspond to variables $pattern, $cyclo and $group. In a different file, these 3 entries might have different values, so that's why I can't match the actual words "folding" and so on.
Obviously this is wrong. I get the message I think I need to find a way to say "split those entries and put them in those three variables", but I don't know how? Anyone can suggest how to proceed?chdir "$results$filepath" or print "cannot chdir to $results$filepath +! $!"; if (-e "test.txt") { open (my $test, '<', "test.txt") or print "Can't open file: $!"; while(my $line = <$test>){ chomp $line; split(" ", $line); print $line; } }
In reply to split file and put contents in variables? by angela2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |