Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Extract Data

by PilotinControl (Scribe)
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

Comment on Extract Data
Download Code
Re: Extract Data
by toolic (Chancellor) 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 chilling in the Monastery: (5)
As of 2014-07-13 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (250 votes), past polls