CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
using sed command in perl

 



regex2012
User

May 22, 2017, 11:11 AM

Post #1 of 2 (1056 views)
using sed command in perl Can't Post

I have this command
where I am trying to print the file in reverse

Code
open($FH1, "|sed '1!G;h;$!d' /tmp/inventory.txt"); 
while (<$FH1>) {
print "$_\n";
}

I am not able to get sed to print the file in reverse; I get an error.
How should I run this command within perl properly?


BillKSmith
Veteran

May 22, 2017, 1:03 PM

Post #2 of 2 (1051 views)
Re: [regex2012] using sed command in perl [In reply to] Can't Post

Your sed command is a perl double quoted string. The symbol '$' has special meaning. Your use is ambiguous. Perl does not know if you mean "${!}" (The special variable) or "\$!d" (the sed command). Use a backslash as an escape ("\$" instead of "$").

I recommend that you use a perl module rather than a shell command. Refer File::ReadBackwards
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives