Hi again, I have lots of files ( see my first post to this group :) ) they all have two lines simular to:
Ref.: 005803/11-SY (T45) Total Amount 685.00 Lead: ARDA/DILAN/MISS Total Paid 685.00 I want to rename the files with "Lead"-"Ref".txt When I run the script I get an error : Use of uninitialized value in concatenation (.) or string at rename.pl line 15, <DATA> line 70. and then the same error over 10,000 times before I pull the plug (ctl-c) sorry to be a pain but I cannot see the error of my ways. Thanks Brad My script: #! /usr/bin/perl use strict; use warnings; my $newname; my $end= '.txt'; my $refno; my $lead; my $newfile; my @files = <c:\\test\\*.txt>; my $MyWrkLoc = q[c:\\test\\test1\\]; foreach $arg(@files){ open DATA, "$arg"; opensub(); $newname = "$lead-$refno$end"; rename $arg, "$MyWrkLoc$newname"; } sub opensub { while (<DATA>) { chomp($_); if ($_ =~ m/^Ref.:(\S)/i) { # get Reference Number $refno=$1; $refno=~ s/[\/|-]/_/; print $refno; } if ($_ =~ m/^Lead:(\S)/i) { # get Lead Name $lead=$1; $lead=~ s/[\/|-]/_/; print $lead; } } } ## the two print statements are just debuging pls ignore ## -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/