parthodas has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to Perl Scripting. If this question is answered, please point me to the right thread.
As for my requirement, I need to grep two strings from a file and need to process them. I'm not able to do so. I cannot do split as they are separated by space. The file would look something like this --
FileName   FilePath   FileDir
FileName2   FilePath2   FileDir2
FileName3   FilePath3   FileDir3

So, I'll take FileName and put that in FileDir. I'll have to do this for the whole file.

Thanks, Partho

Update

Hi,
Thanks for the tip. It did worked.

Thanks, Partho

Replies are listed 'Best First'.
Re: How to grep two strings from a File
by hippo (Archbishop) on Jul 24, 2015 at 09:15 UTC
    I cannot do split as they are separated by space.

    That is precisely why you would use split. eg:

    #!/usr/bin/perl use strict; use warnings; while (<DATA>) { my @fields = split; print "Name = $fields[0], Dir = $fields[2]\n"; } __DATA__ FileName FilePath FileDir FileName2 FilePath2 FileDir2 FileName3 FilePath3 FileDir3