Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086534
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:44:23+00:00 2026-05-20T18:44:23+00:00

I am building a module which connects to a camera, takes a picture, and

  • 0

I am building a module which connects to a camera, takes a picture, and reads the data into a piddle. All of this takes place in an Inline::C command. Using the procedure in the PDL documentation I can create a pdl * and return it. However the camera could fail to take a picture in which case I would like to return 0 as per the usual covention my $pic_pdl = $Camera->TakePicture or die "Failed to take image". This seems to mean that I will need to use the Inline_Stack_Push mechanism but I am not sure how to properly convert the pdl * into an SV*. Also I would like to, if possible, set $! with the error code too. Can this be done in Inline?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:44:24+00:00Added an answer on May 20, 2026 at 6:44 pm

    The pdl* is converted to an SV by code found in the typemap.

    $ cat `perl -E'use PDL::Core::Dev; say PDL_TYPEMAP'`
    TYPEMAP
    pdl*    T_PDL
    pdl *   T_PDL
    Logical T_IV
    float   T_NV
    
    INPUT
    
    T_PDL
            $var = PDL->SvPDLV($arg)
    
    
    OUTPUT
    
    T_PDL
            PDL->SetSV_PDL($arg,$var);
    

    If I read that right, you should be able to do something like:

    SV* my_new {
        pdl* p = NULL;
    
        ...
    
        if (error) {
            if (p)
                free(p);  /* I think */
            return &PL_sv_undef;
        } else {
            SV* rv = newSV(0);
            PDL->SetSV_PDL(rv, p);
            return rv;
        }
    }
    

    As for $!, it’s simply an interface to C’s errno. Simply set errno.

    $ perl -E'use Inline C => "void f(int i) { errno = i; }"; f($ARGV[0]); say 0+$!; say $!;' 2
    2
    No such file or directory
    
    $ perl -E'use Inline C => "void f(int i) { errno = i; }"; f($ARGV[0]); say 0+$!; say $!;' 3
    3
    No such process
    
    $ perl -E'use Inline C => "void f(int i) { errno = i; }"; f($ARGV[0]); say 0+$!; say $!;' 4
    4
    Interrupted system call
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a Joomla module which will eventually pull data from an external
I am writing Catalyst application which uses Module::Install for module building. I keep all
We're building a module for generating HTML for email newsletters. We've looked into using
I'm building a module installer for my CMS and i have ran into a
I'm building modular application with 2 modules which share common vo: ShopRegionVO This vo
I'm building a Flex/Flash Builder 4 application that loads data using E4X/XML, like this:
I am building an ejabberd module. I require this module to perform RPC calls
I am building a complex AJAX based solution as a module into a Drupal
I currently have a simple menu_alter hook in a new module I'm building which
I am building an application which takes as it's input an executable , executes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.