[Melbourne-pm] nearly there...
Wesley Moore
wjmoore at gmail.com
Wed Dec 19 21:44:33 PST 2007
Another option, avoiding the regex entirely would be to use
Cwd::realpath to tidy the path up.
http://search.cpan.org/~kwilliams/PathTools-3.25/Cwd.pm#abs_path_and_friends
Wes
On Dec 20, 2007 4:05 PM, Jacinta Richardson <jarich at perltraining.com.au> wrote:
> Craig Sanders wrote:
>
> > if it bothers you, then strip out the extras yourself:
> >
> > my $full_path = "$dirname/$entry";
> > $full_path =~ s=//=/=g;
>
> Except, don't use = as your separator. It breaks people's brains. Use
> curly braces instead:
>
> $full_path =~ s{//}{/}g;
>
> or anything which doesn't already have a strong semantic map already
> (which is hard, because this is Perl, and Perl uses almost all the
> punctuation for something), and which can reasonably be assumed to be
> obvious to a 6 months Perl user.
>
> Curlies are great for pick-your-delimiter stuff:
>
> q{single quoted}
> qq{double quotes}
> qx{quoted executable}
> qr{precompiled regular expression}
> m{match}
> s{match}{replace}
>
> If absolutely necessary (for example the string/expression contains
> unmatched }s, I'll use ()s, []s, !s or at worst #s.
>
> All the best,
>
>
> J
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm
>
More information about the Melbourne-pm
mailing list