in reply to remote perlscript

Here's a number of suggestions:

Start out by adding use strict; and use warnings; at the top of your code.  That will cause quite a few error messages to be displayed when you run it, so you should fix those next; add my to variables which haven't been declared (those will constitute the majority of the errors).

I don't know what $window->document->write is, so I've changed it to print everywhere.  But if it works for you, that's fine (I've only added it so that I could debug the rest of the program).

You can't create lists using barewords ...

$thisday = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday +)[$wday];

... instead, either put quotes (" ") around the words (apostrophes (' ') will also do), or use the qw function (in which case you need to remove the commas ",").  If you put the declaration outside of the subroutine, it may look a little more clear (and you have the benefit of allowing other subroutines to use it too).  So if you do that for both @days and @months, you get:

my @days = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); my @months = qw( January February March April May June July August September October November December );

It's often a good idea to chomp the results of `...`, so that the resulting lines don't have a newline at the end:

my @rec = `ipconfig /all`;

(though in your case, the output is HTML, so it doesn't matter so much in the grand scheme of things).

There's no need to concatenate lots of little strings together, and, IMO, it makes it a lot harder to read.  Since quotation marks allow variable-interpolation from inside, you might consider changing:

$datetime = $time.' '.$ampm.', '.$thisday.', '.$thismon.' '.$mday. +', '.$year;

to:

my $datetime = "$time $ampm, $thisday, $thismon $mday, $year";

Applying all of these changes, and fixing indentation up a bit, results in something like:

use strict; use warnings; my @days = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); my @months = qw( January February March April May June July August September October November December ); sub PrintWelcome { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime +(); my $thisday = $days[$wday]; my $thismon = $months[$mon]; if ($hour < 12) { print "Good morning! "; } elsif ($hour < 17) { print "Good afternoon! "; } else { print "Good evening! "; }; my $ampm = 'AM'; if ($hour > 12) { $hour -= 12; $ampm = 'PM'; } my $time = sprintf '%d:%2.2d:%2.2d',$hour,$min,$sec; $year += 1900; my $datetime = "$time $ampm, $thisday, $thismon $mday, $year"; print "Just in case you were wondering, it's<BR> "; print $datetime; print "<BR> <BR> Your username is $ENV{'USERNAME'} "; print "(it\'s in \$ENV{'USERNAME'}), "; print "the computername is $ENV{'COMPUTERNAME'} "; print "(it\'s in \$ENV{'COMPUTERNAME'}), "; print "and your OS is $ENV{'OS'} (it\'s in \$ENV{'OS'}).<BR> "; print "<BR> <BR> Here is everything in %ENV:<BR> "; foreach my $key (sort(keys %ENV)) { print "<BR> $key" . " = " . $ENV{$key} . "<BR> "; } chomp(my @rec = `ipconfig /all`); foreach my $itemmac (@rec) { # Loop through ipconfig output, and find MAC address line if ($itemmac =~ /Physical Address.*: (\S+)/) { my $macaddr = $1; # Capture MAC address string print "<BR> <BR>Your MAC(Media Access Control)/Physical Ad +dress "; print "in hexadecimal is: $macaddr<BR> "; } } } PrintWelcome();

which outputs HTML that seems at first glance to be fine.  I even saved it to a file, and it still looked okay when I browsed it as a webpage.

What happens when you try the above program -- do you get the output you expect?  If so, do you still get it when you change every occurrence of print to $window->document->write?

Update:  Looking at your code (and the output) again, I noticed that you weren't pulling out just the MAC address, but rather displaying every line from ipconfig.  Assuming that you want only the MAC address, I modified the code above to use a regular expression /Physical Address.*: (\S+)/, which does a capture on the MAC address string so you can print it when it's found.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/