Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Any idea how to pass a variable there ?

by Sombrerero_loco (Beadle)
on Jun 25, 2013 at 16:04 UTC ( [id://1040618]=perlquestion: print w/replies, xml ) Need Help??

Sombrerero_loco has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks. Im doing a really weird program and i need to use Device::Modem::Gsm, to read the imei and make a ln on /dev. Ok, the problem is, i need to pass this to the constructor, but i dont wanna to hardcode every modem i want to have, i want to read a dir, parse the modems and try to connect to this modems.
use Device::Gsm; my $gsm = new Device::Gsm( port => '/dev/ttyS1', pin => 'xxxx' ); if( $gsm->connect() ) { print "connected!\n"; } else { print "sorry, no connection with gsm phone on serial port!\n"; }
Where it says '/dev/ttyS1' i need to put a $variable, but it doesnt read the variable, :( Any workaround or i should mess with the AT commands ? thanks!

Replies are listed 'Best First'.
Re: Any idea how to pass a variable there ?
by davido (Cardinal) on Jun 25, 2013 at 16:09 UTC

    Single quotes don't interpolate. Use double-quotes so that you get variable interpolation. Or no quotes at all if a variable by itself contains the entire field.

    my $gsm = new Device::Gsm( port => $variable ....

    ...or...

    my $gsm = new Device::Gsm( port => "stuff/plus/$interoplation"...

    Dave

Re: Any idea how to pass a variable there ?
by LanX (Saint) on Jun 25, 2013 at 16:08 UTC
    > Where it says '/dev/ttyS1' i need to put a $variable, but it doesnt read the variable

    Thats impossible!¹

    Your problem is somewhere else, but w/o showing us more we can't tell a lot!

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    update

    ¹) But davido's guess is not bad! =)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1040618]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2024-04-24 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found