0

The only difference between miniperl and perl is that miniperl cannot load XS-based perl modules as shared objects. So it can't load WIN32 or CWD modules.

Is it possible to get Current Working Directory in miniperl?

NoSkill
  • 718
  • 5
  • 15
  • Can it run external programs via backticks/`qx`? – Shawn Nov 08 '18 at 10:11
  • I don't want to use external programs. – NoSkill Nov 08 '18 at 10:28
  • Does your program use chdir internally? Could you read the working directory from %ENV maybe? – martin clayton Nov 08 '18 at 11:21
  • No `my $dir = qx/pwd/;` then? What OS is this for? – Shawn Nov 08 '18 at 11:26
  • OS = win32 And is it possible to get CWD internally, without external programs, environment variables, and etc. – NoSkill Nov 08 '18 at 11:47
  • Why do you not want to use external programs or anything like that? For that matter, why not a full Perl? – Shawn Nov 08 '18 at 12:30
  • Why can't you reference %ENV? Would a function call be acceptable? – martin clayton Nov 08 '18 at 12:35
  • 1
    Guyz, my question is "is it possible", and not "why do I not want". – NoSkill Nov 08 '18 at 14:17
  • 1
    And none of us want to waste time with an [XY problem](http://xyproblem.info/), which, given the odd requirements and lack of explanation, this sounds like. – Shawn Nov 08 '18 at 14:54
  • Re "*my question is "is it possible"*", No, it's not. You were told you it was possible, and you rejected it. So we're trying to figure out what your question really is. – ikegami Nov 08 '18 at 15:27
  • @Spawn I asking because the very old versions of miniperl was linked with win32 module and getcwd is worked there without any externals libs. Newer versions have not Win32. So I'm interesting are there alternate ways to get CWD in newer versions without external routines. Maybe there is a way to compile and build miniperl linked to Win32 or CWD module. You really should not waste your time if you have no idea. – NoSkill Nov 08 '18 at 17:07
  • @ikegami The old version of miniperl is used in old project where software size is very critical. We do not want to add additional executables. We do not want to use external environment. We want to update miniperl for some reasons, but we need to CWD routines that is not supported in new versions. SO IT'S YES - Questions is "is it possible". – NoSkill Nov 08 '18 at 17:14
  • The current directory is `.`. – Grinnz Nov 08 '18 at 20:47
  • Re "*Maybe there is a way to compile and build miniperl linked to Win32 or CWD module.*", You can definitely do that with `perl`. Don't know about `miniperl`. `miniperl` is a tool for building `perl`. – ikegami Nov 09 '18 at 10:42

1 Answers1

1

Yes, it's possible using the following:

chomp( my $cwd = `cd` );
ikegami
  • 367,544
  • 15
  • 269
  • 518