user-pic

Tony Cook

  • Commented on Learning XS - Closures
    That should work, you might want to set any_ptr to NULL. An option to automatically manage the lifetime of your self object would be to store it in MAGIC. See https://metacpan.org/release/PEVANS/Future-XS-0.13/source/hax/cv_set_anysv_refcounted.c.inc for an example for code that uses CvREFCOUNTED_ANYSV_on() when...
  • Commented on Learning XS - Closures
    Another interesting post. HV * stash = newHV(); hv_store(stash, "name", 4, newSVsv(name), 0); hv_store(stash, "happiness", 9, items > 1 ? newSVsv(ST(1)) : newSViv(5), 0); hv_store(stash, "hunger", 6, items > 2 ? newSVsv(ST(2)) : newSViv(5), 0); CvXSUBANY(kitty).any_ptr = (void *)stash; where...
  • Commented on Writing a 1GB file in perl
    close $fhandl; system 'sync', 'somefile'; # alternatively use File::Sync on cpan, Or flush and sync the file before closing: $fhandle->flush; $fhandle->sync; $fhandle->close;...
  • Commented on Once more unto the Wide character (U+XXXX) in substitution (s///)
    $ perl -Mlocale -MPOSIX=setlocale,LC_ALL \ -We 'setlocale(LC_ALL, "en_AU.iso8859-1"); $_ = "\x{100}"; s/\w//' Wide character (U+100) in substitution (s///) at -e line 1. Wide character (U+100) in substitution (s///) at -e line 1. It warns because the locale in this case...
  • Commented on When Laziness Isn't
    The $$ in $$ARGV[0] is being replaced when the alias is created: tony@venus:~$ alias u="perl -le 'system q(uuidgen) for 1..$$ARGV[0]'" tony@venus:~$ alias alias u='perl -le '\''system q(uuidgen) for 1..95370ARGV[0]'\''' The shell doesn't use @ here so @ARGV[0] works. The single...
  • Commented on The Day Perl Stood Still: Unveiling A Hidden Power Over C
    Perl uses malloc() to allocate PVs for SVs. If you're using constants with "x" to create the PVs: my $x = "x" x 10000; # constants then that's done at compile-time, and assigning to another SV: my $x = "x"...
  • Commented on Perl 5 Porters Mailing List Summary: October 5th-11th
    The issue with globbing isn't that File::Glob shells out, but with miniperl (which can't load File::Glob) or -DPERL_EXTERNAL_GLOB builds, which use csh or perlglob.exe on Win32 to perform glob(). Unfortunately the subject for #126271 is misleading. For #31923, the issue...
  • Commented on Imager from Image::Magick: Trial Run
    Could you please open an Imager rt.cpan ticket with the output of: perl Makefile.PL --verbose with some details about the environment variables you had pointing at the headers and libraries? Thanks. WRT ellipses - it's mosly a case of me...
  • Posted Perl 5.18: getline and $/ = \N to Tony Cook

    Perl 5.18 will ship with a change in behaviour when using getline() (aka the <$handle> operator) on handles marked as returning Unicode where $/ is a reference to an integer.

  • Commented on Perl I/O on scalars for 5.18
    This is intended to be part of 5.18 (and I've updated the title). See https://rt.perl.org/rt3/Ticket/Display.html?id=109828 for the discussion....
  • Commented on A perl devops mailing list
    There's already one, see: http://lists.perl.org/list/perl-devops.html...
  • Posted Perl I/O on scalars for 5.18 to Tony Cook

    From perl 5.17.9, the following:

    my $scalar;
    ...
    open my $fh, "<", \$scalar or die;
    

    will fail unless $scalar contains only code points 0xFF or lower - ie. they can be represented as bytes.

    Perl's I/O …

Subscribe to feed Recent Actions from Tony Cook

  • Sawyer X commented on Perl 5 Porters Mailing List Summary: October 5th-11th

    Thank you for the corrections, Tony!

  • Aristotle commented on Once more unto the Wide character (U+XXXX) in substitution (s///)

    Thank you!! I asked about this on #p5p at the time but nobody who happened to be around at that moment could solve the mystery for me either.

    So the only thing I missed was that it’s necessary to set LC_ALL to something suitable to trigger the warning. And since I do have code in my project to set that to C, that explains why exactly the warning was getting triggered. And also lends itself to an even shorter and more portable repro:

    LC_ALL=C perl -Mlocale -We '$_ = "\x{100}"; s/\w//'
  • Robert Acock commented on Learning XS - Closures

    I have only been learning C/XS for a short period of time, I have touched typemaps but would need to 'experiment' with them more before I could write a post. My current understanding to what they allow you todo is more transparently handle C data types with your XSUBs. For an example you can return your type and then the PTR2IV and INT2PTR logic is done 'automagically' for you.
    Cat *
    cat_name
    Cat *kitty
    CODE:
    char *name = kitty->name;
    ...

    As for the flaws in my code I guess I need to explicitly destroy the…

  • Robert Acock commented on Learning XS - Closures

    Is this the correct way to free the HV?

    ```
    void
    euthanase(kitty)
    CV * kitty
    CODE:
    SvREFCNT_dec(CvXSUBANY(kitty).any_ptr);
    ```

  • Leon Timmermans commented on Learning XS - Closures

    I agree with Tony, using typemaps can make handling C datatypes much easier.

Subscribe to feed Responses to Comments from Tony Cook

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.