SPUG:for help

John Subaykan cansubaykan at hotmail.com
Thu Feb 6 19:10:59 CST 2003

If you are already using an if statement to check the string with a regular 
expression, just use that to capture.  Like this:

if ($line =~ /^\s+(\d+)\s+(.+?)\s+(\d+)$/) {

    ($part1, $part2, $part3) = ($1,$2,$3);



----Original Message Follows----
From: "Liu, Zhu" <Liu.Zhu at mayo.edu>
To: "'spug-list at mail.pm.org'" <spug-list at mail.pm.org>
Subject: SPUG:for help
Date: Wed, 29 Jan 2003 22:19:57 -0600

Hi, everybody, I experienced a very stupid simple problem for three hours. I 
just want to extract three substrings from one string. In the beginning of 
the string there are two spaces  like

My part code is
if( $line =~ /^\s+\d+.*\d$/)
	($part, $part2, $part3) = /\s+(\d+)\s(.*)\s+(\d+)/;

it always tells me "Use of uninitialized value in pattern match (m//)", so 
if I use the following codes
if( $line =~ /^\s+\d+.*\d$/)
	($emptypart, $start, $part, $end) = split /\s+/, $line, 4;

This time I can get the items.

So my question is why parentheses can't catch the substrings?

zhu liu

Seattle Perl Users Group Mailing List
POST TO: spug-list at mail.pm.org
ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
MEETINGS: 3rd Tuesdays, U-District, Seattle WA
WEB PAGE: www.seattleperl.org

Protect your PC - get McAfee.com VirusScan Online  

More information about the spug-list mailing list