Perl parsing files




















If that's the case, you can read each file line by line:. Your specification has a few loose ends; for instance - what if there are more lines in file2 then there are total labels in file1? Do you want the spaces in the first input file ignored? Do you want the spaces in the output file specifically as shown? I've presumed "yes" to most of these questions.

My solution is driven by the second data file - which means that if there are more total labels then there are lines of data, they are going to be ignored.

It also means that if there are more data lines in file2 then there are labels in file1, the program will simply make up the label - No Label? Finally, just in case you want to add these numbers up at some point, I've included but commented the sum function from List::Util.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. File parsing using perl Ask Question. Asked 5 years, 9 months ago. Active 5 years, 9 months ago. Viewed times. I am stuck in middle , i need help. Hope this helps! Community Bot 1 1 1 silver badge. Kenosis Kenosis 6, 1 1 gold badge 14 14 silver badges 16 16 bronze badges.

Try this: grep -i -c -w -f input. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses.

Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings. Consider starting a new topic instead.

Otherwise, please be thoughtful, detailed and courteous, and adhere to our posting rules. Edit Preview. H1 H2. Post Reply. Broken Link. Go Back to the Post Continue Anyways. Share Post. Permanent Link.



0コメント

  • 1000 / 1000