Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Any idea how to pass a variable there ?

by Sombrerero_loco (Beadle)
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!

Replies are listed 'Best First'.
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 ....


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


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


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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1040618]
Front-paged by Arunbear
[Discipulus]: rain? i dont remember it..
[marto]: and good news all round, Flash will die come 2020!
[Corion]: So who will be the saviour of the universe, then?!
[marto]: Corion++, asking the right questions
[marto]: the rain is back

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2017-07-26 10:55 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (390 votes). Check out past polls.