develooper Front page | perl.beginners | Postings from January 2002

silly beginners problem :)

Thread Next
From:
Martin A. Hansen
Date:
January 15, 2002 09:29
Subject:
silly beginners problem :)
Message ID:
Pine.LNX.4.40.0201151810480.1078-100000@homer
hi

im trying to make a script to read a textfile with the following format:"

TITLE
Welcome to Carcinoma in Situ

"
i want my script to recognice the TITLE tag and save the following line(s) in $TITLE:

heres what i have done:

while (<>) {
  chomp;
	if (/TITLE\s*([A-Za-z]+)/) {
	   $TITLE=$1;
  }
}
print $TITLE;

upon script textfile.txt > outputfile i get this error:
Use of uninitialized value in concatenation (.) or string in line (the one with print $TITLE in it)

i think my regex is not doing what i want it to do??? why?

:/

martin


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About