develooper Front page | perl.perl5.porters | Postings from January 2008

[PATCH] *.pod: Change backticks into more readable qx()

Thread Next
From:
Jari Aalto
Date:
January 6, 2008 06:20
Subject:
[PATCH] *.pod: Change backticks into more readable qx()
Message ID:
1w8v11p5.fsf@blue.sea.net

The backtick character i quite tiny, especially in higher resolution
displays. It is also difficult to produce in forein keyboard.

I propose to use qx() in the manual pages insted. The patch
was made against rsync ftp.linux.activestate.com 2008-01-06 16:13

Jari

From 84f9593b95f826001295a98041fe3a5a8665e9a8 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto AT cante.net>
Date: Sun, 6 Jan 2008 16:10:47 +0200
Subject: [PATCH] *.pod: Change backticks into more readable qx()

Signed-off-by: Jari Aalto <jari.aalto AT cante.net>
---
 perlfaq4.pod    |    2 +-
 perlfaq8.pod    |    6 +++---
 perlfunc.pod    |   10 +++++-----
 perlop.pod      |    4 ++--
 perlopentut.pod |    2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/perlfaq4.pod b/perlfaq4.pod
index 3200e7a..d9c1723 100644
--- a/perlfaq4.pod
+++ b/perlfaq4.pod
@@ -1092,7 +1092,7 @@ syscall() function.
 
 Stringification also destroys arrays.
 
-	@lines = `command`;
+	@lines = qx(command);
 	print "@lines";     # WRONG - extra blanks
 	print @lines;       # right
 
diff --git a/perlfaq8.pod b/perlfaq8.pod
index 7def972..f7eda93 100644
--- a/perlfaq8.pod
+++ b/perlfaq8.pod
@@ -177,7 +177,7 @@ If you have to do this a lot, save the clear string
 so you can print it 100 times without calling a program
 100 times:
 
-	$clear_string = `clear`;
+	$clear_string = qx(clear);
 	print $clear_string;
 
 If you're planning on doing other screen manipulations, like cursor
@@ -588,14 +588,14 @@ the high 8 bits are the actual exit value).  Backticks (``) run a
 command and return what it sent to STDOUT.
 
 	$exit_status   = system("mail-users");
-	$output_string = `ls`;
+	$output_string = qx(ls);
 
 =head2 How can I capture STDERR from an external command?
 
 There are three basic ways of running external commands:
 
 	system $cmd;		# using system()
-	$output = `$cmd`;		# using backticks (``)
+	$output = qx($cmd);	# using readable backticks (``)
 	open (PIPE, "cmd |");	# using open()
 
 With system(), both STDOUT and STDERR will go the same place as the
diff --git a/perlfunc.pod b/perlfunc.pod
index dc340f1..16cf33f 100644
--- a/perlfunc.pod
+++ b/perlfunc.pod
@@ -757,16 +757,16 @@ If VARIABLE is a hash, it chomps the hash's values, but not its keys.
 
 You can actually chomp anything that's an lvalue, including an assignment:
 
-    chomp($cwd = `pwd`);
+    chomp($cwd = `qx(pwd));
     chomp($answer = <STDIN>);
 
 If you chomp a list, each element is chomped, and the total number of
 characters removed is returned.
 
 Note that parentheses are necessary when you're chomping anything
-that is not a simple variable.  This is because C<chomp $cwd = `pwd`;>
-is interpreted as C<(chomp $cwd) = `pwd`;>, rather than as
-C<chomp( $cwd = `pwd` )> which you might expect.  Similarly,
+that is not a simple variable.  This is because C<chomp $cwd = qx(pwd);>
+is interpreted as C<(chomp $cwd) = qx(pwd);>, rather than as
+C<chomp( $cwd = qx(pwd))> which you might expect.  Similarly,
 C<chomp $a, $b> is interpreted as C<chomp($a), $b> rather than
 as C<chomp($a, $b)>.
 
@@ -1238,7 +1238,7 @@ X<die> X<throw> X<exception> X<raise> X<$@> X<abort>
 
 Outside an C<eval>, prints the value of LIST to C<STDERR> and
 exits with the current value of C<$!> (errno).  If C<$!> is C<0>,
-exits with the value of C<<< ($? >> 8) >>> (backtick `command`
+exits with the value of C<<< ($? >> 8) >>> (backtick qx(command)
 status).  If C<<< ($? >> 8) >>> is C<0>, exits with C<255>.  Inside
 an C<eval(),> the error message is stuffed into C<$@> and the
 C<eval> is terminated with the undefined value.  This makes
diff --git a/perlop.pod b/perlop.pod
index 47184f3..d504900 100644
--- a/perlop.pod
+++ b/perlop.pod
@@ -1225,7 +1225,7 @@ properly supported when anchored at the very beginning of the pattern.
 Examples:
 
     # list context
-    ($one,$five,$fifteen) = (`uptime` =~ /(\d+\.\d+)/g);
+    ($one,$five,$fifteen) = (qx(uptime) =~ /(\d+\.\d+)/g);
 
     # scalar context
     $/ = "";
@@ -1494,7 +1494,7 @@ For example:
 
     open BLAM, "blam" || die "Can't open: $!";
     open STDIN, "<&BLAM";
-    print `sort`;
+    print qx(sort);
 
 will print the sorted contents of the file "blam".
 
diff --git a/perlopentut.pod b/perlopentut.pod
index 18bc369..4793964 100644
--- a/perlopentut.pod
+++ b/perlopentut.pod
@@ -281,6 +281,6 @@ call fopen(3S) or it might called popen(3S), depending on what its
 argument looks like; that's why it's sometimes called "magic open".
 Here's an example:
 
-    $pwdinfo = `domainname` =~ /^(\(none\))?$/
+    $pwdinfo = qx(domainname) =~ /^(\(none\))?$/
                     ? '< /etc/passwd'
                     : 'ypcat passwd |';
\ No newline at end of file
-- 
1.5.4-rc0.GIT



-- 
Welcome to FOSS revolution: we fix and modify until it shines

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About