Your regexp is liiking for the string TITLE anywhere on a line, followed by
zero or more whitespace characters, followed by one or more letters.

Your example data has no characters following TITLE on that line, and so $1
is uninitialised.

I imagine you want to suppress the imput record separator, and look for all
characters after TITLE\s* -

$/ = '';
my $input = <>;
$input =~ /TITLE\s*(.+)/;
print $1;

- Roger -
----- Original Message -----
From: "Martin A. Hansen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 15, 2002 5:23 PM
Subject: silly beginners problem :)


> 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
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to