Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 704405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:56:17+00:00 2026-05-14T03:56:17+00:00

Say I have a data file that I want to process; I want to

  • 0

Say I have a data file that I want to process; I want to take the maximum value of each of the column and append it to the end of each line.

INPUT:

T1 T2 T3
35.82 34.67 31.68
32.20 34.52 33.59
37.41 38.64 37.56

OUTPUT:

T1 T2 T3
35.82 34.67 31.68 35.82
32.20 34.52 33.59 34.52
37.41 38.64 37.56 38.64

I’m trying to implement this as a one-liner. So far, this is what I’ve come up with, although it complains that &main::max is undefined:

perl -MList::Util -ani.bak -e "print qq(@F).q( ).max(@F).qq(\n)" file1.txt

It seems that I haven’t loaded the List::Util module. What’s wrong? And is the header column an issue?

perlrun doesn’t have a decent example on how to do this (actually it does, my documentation was a little hard to read).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:56:18+00:00Added an answer on May 14, 2026 at 3:56 am

    You loaded List::Util, but the module doesn’t export symbols by default. Skip the header line by checking whether $. is 1.

    $ perl -MList::Util=max -ape 's/$/" " . max(@F)/e unless $.==1' input 
    T1 T2 T3
    35.82 34.67 31.68 35.82
    32.20 34.52 33.59 34.52
    37.41 38.64 37.56 38.64

    The perlrun documentation explains:

    A little builtin syntactic sugar means you can also say -mmodule=foo,bar or -Mmodule=foo,bar as a shortcut for -Mmodule qw(foo bar). This avoids the need to use quotes when importing symbols. The actual code generated by -Mmodule=foo,bar is use module split(/,/,q{foo,bar}). Note that the = form removes the distinction between -m and -M.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a for loop that reads from a data file and each
I have a time series(a csv file) data that looks like below. Each observation
Say I want to have a server that can accept 2GB file over network,
Lets say I have a data file with three columns. I want to be
Say I have data like this: <option value=abc >Test - 123</option> <option value=def >Test
Say that I have a data model called Widget . If I pick one
I have got around 800 files of maximum 55KB-100KB each where the data is
I just have a data file with one column of time series: '2012-02-01 17:42:44'
i have this file that i want to open, a csv file, and i
Lets say I have a view file that is built like this: <html> ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.