On 4/30/07, oryann9 <[EMAIL PROTECTED]> 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 $ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/