Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Extract Data

by PilotinControl (Monk)
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1035828]
Approved by toolic
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2016-09-27 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (500 votes). Check out past polls.