You're not being very clear what it is you're trying to do. I can see
two ways of interpreting this.
Regular expressions are mostly for checking the format of text to see if
certain conditions match. You might be asking how to do this:
use strict;
use warnings;
by filename alone, you must add the path as a prefix)
-Original Message-
From: Curt Shaffer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 28, 2006 12:42 PM
To: Timothy Johnson; beginners@perl.org
Subject: RE: regular expression in a variable
Thanks for the response. Let me try to clear
your help!
-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 28, 2006 3:47 PM
To: Curt Shaffer; beginners@perl.org
Subject: RE: regular expression in a variable
So what part are you stuck on then? It looks like the first suggestion
gets you
28, 2006 3:47 PM
To: Curt Shaffer; beginners@perl.org
Subject: RE: regular expression in a variable
So what part are you stuck on then? It looks like the first
suggestion gets you the $filename you want. All you have to do after
that is move
it.
(you can change it so it isn't
PM
To: Curt Shaffer; Timothy Johnson; beginners@perl.org
Subject: RE: regular expression in a variable
Curt Shaffer wrote:
That appears to work! The part I am stuck on is how to I take that
value (which would now be $file in your example) and put it into a
variable that I can use through
;
}
##
-Original Message-
From: Curt Shaffer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 28, 2006 1:11 PM
To: Timothy Johnson; beginners@perl.org
Subject: RE: regular expression in a variable
That appears to work! The part I am stuck on is how to I take that value
(which would now
The $file is only valid inside the foreach scope. To get a global value
use:
use strict;
use warnings;
my $file # the variable is now global
opendir(DIR,.) or die(Couldn't open the current directory!\n);
my @files = readdir(DIR);
foreach $file(sort @files){ # The my has been removed in
, February 28, 2006 5:50 PM
To: Curt Shaffer; beginners@perl.org
Subject: RE: regular expression in a variable
If you declare a variable with my(), it only exists within the current
scope (NOTE: always add 'use strict' and 'use warnings' whenever you
can at the top of your scripts).
What you'll have