Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Any idea how to pass a variable there ?

by Sombrerero_loco (Sexton)
on Jun 25, 2013 at 16:04 UTC ( #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!

Comment on Any idea how to pass a variable there ?
Download Code
Re: Any idea how to pass a variable there ?
by LanX (Abbot) 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! =)

Re: Any idea how to pass a variable there ?
by davido (Archbishop) 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

Log In?
Username:
Password:

What's my password?
Create A New User
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? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-04-16 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (434 votes), past polls