Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Writing current working directory to $variable

by athomason (Curate)
on Aug 27, 2000 at 03:41 UTC ( [id://29839]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://29839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-19 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found