Welcome to the Monastery.
Attacking your problem should have 3 steps: "How do I read a file?", "How do substitutions on a string?" and "How do I output the result?". For the first, you'll likely want to use open and read, for the second you'll want to use a regular expression and then lastly you'll want to use print statements. A sample code follows, though you could certainly create more succinct and faster code one you gain familiarity:
use strict; use warnings; # Read data into an array open my $fh, "<", "input.txt"; my @strings = (); while (my $line = <$fh>) { chomp $line; push @strings, $line; } close $fh; # Replace trailing _in and _out foreach my $line (@strings) { $line =~ s/\_in$|\_out$//; } # Output to STDOUT foreach my $line (@strings) { print $line, "\n"; }
In reply to Re: read few alphabets from a given data
by kennethk
in thread read few alphabets from a given data
by sharan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |