Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003

    Unanswered: Wrapping a command in perl

    We are using the following command on LINUX servers to swith the fields in a file.

    perl -pi -e 's/(.*?)=\s+(.*?)\s+\#(.*?) Replace (.*?)\s+(.*)/$1= $4 \# $5 Replace $2 $3/' ${file}

    I am trying to wrap it in a perl script. Please help.

  2. #2
    Join Date
    Oct 2002
    Baghdad, Iraq
    What do you mean "wrap" it in a perl script?

    If you want to make it a standalone perl script, it's just:

    #!/usr/bin/perl -pi
    s/(.*?)=\s+(.*?)\s+\#(.*?) Replace (.*?)\s+(.*)/$1= $4 \# $5 Replace $2 $3/
    The command line parameters can go into the shebang (# is a sharp, ! is a bang) just fine. See perldoc perlrun to see why this works, and to see what -pi does.

    Also, change /usr/bin to whatever "which perl" tells you.

  3. #3
    Join Date
    Jul 2003

    Thank you.

    Sorry for the late response. Thanks for the worked.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts