At work (on windows) I was trying to install File::Flat via cpan, and ran into an issue in the make test where it was expecting certain operations to fail if the installing user wasn't root (or perhaps the other way around, that exact point isn't important at the moment), and was of course making that determination (root v. non-root UID) based on the value of $>. I knew I had administrative rights on the machine, which ought to translate into root-like privileges from the world of unix. My first attempt to update the failing test was something like this: (previously)

$root = $> == 0 ? 1 : 0;
(my change)
$> = eval "use Win32" || ! $@ ? Win32::IsAdminUser() ? 1 : 0 : $>; # or something like that $root = $> == 0 ? 1 : 0;

Which I could never get to work.

On a unix (or unix-like OS such as my Mac), I guess I can understand and accept why I can't change "$>"...

$ perl -e '$> = 0; print "$!\n"; print "$>\n"' Operation not permitted 501 $

But should these same constraints apply to Windows/cygwin? Especially in the following case?

$ perl -e 'use Win32;print Win32::IsAdminUser(),"\n";$>=0; print $!,"\ +n"; print $>,"\n"' 1 Invalid Argument 4638 $

Does $> have a little extra magic that even applies across the great Win32 divide?

I've since thought that perhaps this might work (not trying to set $> at all), and looks like it ought to work:

$root = eval "use Win32" || ! $@ ? Win32::IsAdminUser() ? 1 : 0 : $> = += 0 ? 1 : 0;

At any rate, what's going on with $>? :)



--chargrill
$,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}

In reply to Does $> have a little extra magic? by chargrill

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.