I was trying to follow your post as I think triangulating this question with C makes complete sense. Have I missed a step?

$ touch 1.bliako.pl $ chmod +x 1.bliako.pl $ gedit 1.bliako.pl &

I paste in your code and set it to execute. First I need Inline.pm:

$ ./1.bliako.pl Can't locate Inline.pm in @INC (you may need to install the Inline mod +ule) ... BEGIN failed--compilation aborted at ./1.bliako.pl line 13. $ sudo cpan ... cpan[1]> install Inline Reading '/home/bob/.cpan/Metadata' Database was generated on Tue, 29 May 2018 20:29:03 GMT Fetching with LWP: http://www.cpan.org/authors/01mailrc.txt.gz Reading '/home/bob/.cpan/sources/authors/01mailrc.txt.gz' ...................................................................... +......DONE ... Installing /usr/local/share/perl/5.22.1/Inline/Foo.pm ... /usr/bin/make install -- OK cpan[2]> q Terminal does not support GetHistory. Lockfile removed. ^[^C $ ./1.bliako.pl Error. You have specified 'C' as an Inline programming language. I currently only know about the following languages: Foo, foo If you have installed a support module for this language, try deleting + the config-x86_64-linux-gnu-thread-multi-5.022001 file from the following +Inline DIRECTORY, and run again: /home/bob/1.scripts/_Inline (And if that works, please file a bug report.)

What am I missing?

$ cat 1.bliako.pl #!/usr/bin/perl # setenv from within perl to effect parent shell # actually parent should be more appropriately # called "adopted" or "step-parent", re execl # there is one little requirement: # you should run this program via shell's exec: # % exec <scriptname> # # author: bliako # date: 09/07/2018 use Inline C => DATA; # ... # this should be the last statement in your script # because nothing else will be executed after that # not even the 'or die ...' mysetenv("test", "TURE") or die "mysetenv() failed"; __END__ __C__ #include <stdio.h> #include <unistd.h> #include <stdlib.h> int mysetenv(const char *K, const char *V){ if( K==NULL || V==NULL ){ return 0; } char *shell = getenv("SHELL"); if( setenv(K, V, 1) ){ fprintf(stderr, "mysetenv() : call to setenv() has fai +led.\n"); return 1; } // replace caller shell with a new shell which now has // set this new env var //printf("shell to exec is %s\n", shell); execl(shell, NULL, NULL); perror("execl failed, "); return 1; } $

In reply to Re: YES you can! Re: setenv in perl by Aldebaran
in thread setenv in perl by dideod.yang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.