Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Why is this not working .. Grep problem

Avatar of zoomer003
zoomer003Flag for Canada asked on
7 Comments1 Solution545 ViewsLast Modified:
use strict;
use warnings;
use Fcntl;  

print "What file would you like GERP to look in,[DO NOT DRAG THE FILE COPY AND PASTE THE PATH]: ";
chomp ($gfile = <>);
print "What would you like to the call the new file: ";
chomp ($filename= <>);

$pattern = glob('C:\debuglog\Automation\SyslogArchive\2010-06-30/*.txt');
print $files;
my $PREFIX = '1';   # Prexif for excel file
my $pattern = $ARGV[0];  # Or prompt as before
my @file_names = glob $pattern;
foreach my $gfile (@file_names) {
    next if ( $gfile !~ /my kind of file/); # Supply a sensible test.
    my $filename = $PREFIX . $gfile;

#opens up the File that grep has to look into.
open (my $fh, '<', $gfile);

#Uses grep to find FTS in the file specified by the user.
my @file = @fts = grep(/FTS/, <$fh>);

#opens up and excel sheet and paste the data that grep has gathered in the step above
sysopen (GREP, $filename, O_RDWR|O_EXCL|O_CREAT, 0755);
print GREP @fts;
close (GREP);
Avatar of wilcoxon
wilcoxonFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers