Top 3 Products & Services


Dated: Aug. 28, 2004

Related Categories

Perl Programming

If you want to display the expected system delimiter to a user (ie hide the fact that you are using / internally) you can just do something like this:

my $perl_path = '/foo/bar/baz';
(my $win_path = $perl_path) =~ tr!/!!;
print "Perl still sees: $perl_pathn";
print "But we can print: $win_pathn";

If you need to do lots of conversions just write a sub like this:

my $perl_path = '/foo/bar/baz';
print "This is the Windows path: ", win_path
($perl_path), "n"

sub win_path {
(my $path = shift) =~ tr!/!;
return $path;

So there you have it. Paths in Perl. By using a / you make it much easier to port your code to another system.

  Page 2 of 2
  First | Previous | Next | Last

Now that you've gotten free know-how on this topic, try to grow your skills even faster with online video training. Then finally, put these skills to the test and make a name for yourself by offering these skills to others by becoming a freelancer. There are literally 2000+ new projects that are posted every single freakin' day, no lie!

Previous Article

Next Article

shubhangi's Comment
this article is very good
21 Sun Mar 2010
Admin's Reply:

Thanks Shubhangi.