in reply to Writing current working directory to $variable

/(\d\d\d\d.\d\d\d\d)/ will match on "/home/limo/Perl/2000/0827/test_dir", but $1 won't have what you want (the . token matches any single character except \n, but it doesn't replace it with a period). Try this.
#!/usr/ug/bin/perl -w use strict; use Cwd; my $dir = getcwd; my $date_suffix; $dir =~ m!(\d{4})/(\d{4})! or die "In a bad directory: $dir"; $date_suffix = "$1.$2"; print "$date_suffix\n";

Replies are listed 'Best First'.
RE: Re: Writing current working directory to $variable
by Limo (Scribe) on Aug 27, 2000 at 04:01 UTC
    Works like a charm! Thanks!