#!/usr/bin/perl

use warnings;
use strict;

my $orig_argv0 = $0;

print "Original \$0: $0\n";
print "Original /proc/self/cmdline:\n";
system("cat /proc/$$/cmdline | hexdump -C");

$0 = join("\0", "test-program", @ARGV);

print "null-separated \$0: $0\n";
print "null-separated /proc/self/cmdline:\n";
system("cat /proc/$$/cmdline | hexdump -C");

$0 = join(' ', "test-program", @ARGV);
print "space-separated \$0: $0\n";
print "space-separated /proc/self/cmdline:\n";
system("cat /proc/$$/cmdline | hexdump -C");

# show that @ARGV is still intact
print "The complete argument list is: " . join(' ', @ARGV) . "\n";

# Local variables:
# mode: perl
# tab-width: 4
# indent-tabs-mode: nil
# end:
