Re: unit messages



On 4/30/07, oryann9 <oryann9@xxxxxxxxx> wrote:
snip
my $regexp =
qr/(host:\w+)|(onlinejfs.*)|(jfs\sversion.*)/is;
snip

Why are you creating this regex so far from where it is being used?
Why are you using three captures when this expression can only return one?

snip
if (/$regexp/) {
($host,$swlist,$kernel) = ($1, $2, $3);
print "\n$1";
print "\t$2";
print "$3\n";
}
snip

Why are you using three prints instead of one (print "\n$1\t$2$3\n")?

The three print lines are where your warnings are coming from. Only
one of $1, $2, $3 is set at a time (since they are all alternatives).

This script demonstrates what is going on:

#!/usr/bin/perl

use strict;
use warnings;

my @a = qw(abc def ghi);

for my $s (@a) {
$s =~ /(b)|(e)|(h)/;
print "1 => [$1] 2 => [$2] 3 => [$3]\n";
}

I would rewrite your code:

#!/usr/bin/perl

use strict;
use warnings;

while (<DATA>) {
s/^\s+|\s+$//g;
next unless length;
if (/(host:\w+)/is) {
print "\n$1";
} elsif (/(onlinejfs.*)/is) {
print "\t$1";
} elsif (/(jfs\sversion.*)/is) {
print "$1\n";
}
}

__DATA__

---------------------------
HOST:axyz
---------------------------

You have mail.
logout

# OnlineJFS B.11.11
Online features of the VxFS File System
OnlineJFS.VXFS-ADV-RUN B.11.11
VXFS-ADV-RUN
# PHCO_25831 1.0
SCSI Ultra160 driver Online Addition script
SW-DIST.SD-JPN-E-HELP B.11.11.0212
Japanese EUC Online Help for SD
SW-DIST.SD-JPN-S-HELP B.11.11.0212
Japanese SJIS Online Help for SD
X11.X11-RUN-CL-MAN B.11.11
Online manual pages for X11 clients
X11.X11-RUN-CT-MAN B.11.11
Online manual pages for X11 contrib clients
X11.X11-RUN-MAN B.11.11
Online manual pages for X11 clients


OnlineDiag B.11.11.09.11 HPUX
11.11 Support Tools Bundle, Dec 2002


JFS version loaded in Kernel: $Revision: libvxfs.a:
CUPI80_BL2000_1108_2 Wed Nov 8 10:59:22 PST 2000 $
Connection to closed.

---------------------------
HOST:xyxxx
---------------------------

__DesiredOutput__

HOST:xyzzz

OnlineJFS B.11.11 Online features of the VxFS File
System

OnlineJFS.VXFS-ADV-RUN B.11.11 VXFS-ADV-RUN

JFS version loaded in Kernel: $Revision: libvxfs.a:
CUPI80_BL2000_1108_2 Wed Nov 8 10:59:22 PST 20
00 $
.



Relevant Pages

  • Re: G.M.T. Thursday 29th December 2005
    ... No wonder shops are losing sales to online shopping, ... Or when it gets dark. ...
    (uk.people.silversurfers)
  • Re: Pocket Kingdom impressions
    ... > imagine I'll have the opportunity to find a human opponent online (or even ... Movies, emulators, putting Ngage games on an MMC so you don't ... But I'd hurry up and buy an MMC if I were you; ...
    (rec.games.video.sega)
  • Re: an update from jms
    ... > I'll post another message when they officially go online at ... Now here is that spreadsheet for tracking guesses????? ... Are we going to need other traking for each project? ...
    (rec.arts.sf.tv.babylon5.moderated)
  • Re: Steganography in ASCII text
    ... > in online challenges, I often have to solve stego-based texts like this one: ... > The plaintext message is hidden within this text, but I can't seem to find ...
    (sci.crypt)
  • Re: Attitude of Plusnet reps on ADSL Guide
    ... bit further down the link to where it said, Additional 155 segment lit. ... Further reading on the forums would also inform you that central 5 comes online in May. ... For goodness sake it's there in black and white, are you saying they are lying? ...
    (uk.telecom.broadband)