Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Extract Data

by PilotinControl (Pilgrim)
on May 29, 2013 at 12:36 UTC ( #1035828=perlquestion: print w/replies, xml ) Need Help??
PilotinControl has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks! My question and code below I am trying to extract data from two files at once. I need to pull data from different fields from each file. My code is below when executed the output is blank. Thanks in advance!

open(MYINPUTFILEONE, "DATA/dataone.txt"); # open for input open(MYINPUTFILETWO, "DATA/datatwo.txt"); # open for input $| = 1; my @linesone = <MYINPUTFILEONE>; # read file into list my @linestwo = <MYINPUTFILETWO>; # read file into list close (MYINPUTFILEONE); close (MYINPUTFILETWO); printf (" =================\n\n"); printf (" | VERIFY NAME |\n\n"); printf (" =================\n\n"); my $verify = <STDIN>; $verify = <STDIN> until defined $verify; chomp($verify); printf (" =================\n\n"); printf (" | VERIFY OWNER |\n\n"); printf (" =================\n\n"); my $ownerverify = <STDIN>; $ownerverify = <STDIN> until defined $ownerverify; chomp($ownerverify); my $found = 0; foreach my $verify2 (@linesone, @linestwo) { chomp; my @fieldone = split(":"); my @fieldtwo = split(":"); if (($verify2 =~ /(?<![\w-])$verify(?![\w-])/i) && ($verify2 =~ /(?<![ +\w-])$ownerverify(?![\w-])/i)) { printf ($fieldone[0], $fieldtwo[1], $fieldone[3]); $found =1; } } # END FILE LOOP

Replies are listed 'Best First'.
Re: Extract Data
by toolic (Bishop) on May 29, 2013 at 12:42 UTC

      Hello Toolic, I made the following changes:

      my @fieldone = split(":", $_); # Does not retrieve data my @fieldtwo = split(":", $verify2); # Returns the correct data
        Has $_ been assigned a value?
        print ">>>$_<<<";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1035828]
Approved by toolic
Front-paged by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-04-21 06:18 GMT
Find Nodes?
    Voting Booth?