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

Re: Problem with regex passed to a hash

by toolic (Bishop)
on Oct 02, 2012 at 00:16 UTC ( #996776=note: print w/replies, xml ) Need Help??

in reply to Problem with regex passed to a hash

Try qr:
($prematch,$match) = $session->waitfor(match => qr/$username/, Timeout => 10);

Replies are listed 'Best First'.
Re^2: Problem with regex passed to a hash
by oldwarrior32 (Sexton) on Oct 02, 2012 at 00:54 UTC

    With qr doesn't appears the error, but there is no match(?)

    Gonna study the qr function. Thanks!

      Yeah, Net::Telnet is rather old and uses a weird method of passing regexes as arguments. For a more recent module qr// would be appropriate, but Net::Telnet requires a string that starts and ends with a slash.

      The other posters are right when they say you should double quote. Any method for building strings will work:

      '/'.$username.'/' "/$username/" sprintf('/%s/', $username)
      As an aside, if you're trying to log in, there's a login method in Net::Telnet.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996776]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2017-06-22 13:23 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (520 votes). Check out past polls.