Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

Donations gladly accepted

If you're new here please read PerlMonks FAQ
and Create a new user.

New Questions
Currency symbols in variable names
2 direct replies — Read more / Contribute
by pme
on Aug 25, 2019 at 06:32
    Hi Monks,

    Can you tell me why this example below does not work in perl v5.28?

    use utf8; sub _to_ { ... } my $yen = _to_('1000');
    It is from book http://modernperlbooks.com/books/modern_perl_2016/03-perl-language.html#VW5pY29kZWFuZFN0cmluZ3M by chromatic.

    This is my tiny script and its output with diagnostics.

    #!/usr/bin/perl use strict; use warnings; use diagnostics; use utf8; use feature qw/say/; binmode STDOUT, ":utf8"; my $ = 1; say '------------------------';
    Output:
    Unrecognized character \x{20ac}; marked by <-- HERE after my $<-- HERE + near column 5 at ./uni2.pl line 10 (#1) (F) The Perl parser has no idea what to do with the specified char +acter in your Perl script (or eval) near the specified column. Perhaps +you tried to run a compressed script, a binary program, or a director +y as a Perl program. Uncaught exception from user code: Unrecognized character \x{20ac}; marked by <-- HERE after my $<-- +HERE near column 5 at ./uni2.pl line 10.
Puzzled by the ListUtil.xs in Scalar-List-Utils-1.52.tar.gz
2 direct replies — Read more / Contribute
by syphilis
on Aug 24, 2019 at 09:51
    Hi,
    In making some edits to the file mentioned in the subject line, I stumbled upon something that kept me occupied for way longer than I care to admit.
    I believe that it will prove to be readily reproducible, but I'd be delighted if that turns out to *not* be the case.
    Please feel free to test this.

    In this ListUtil.xs you will find the following:
    Line 1193: sv_setpvf(keysv, "%.15" NVgf, SvNV(arg)); Line 1194:#ifdef HV_FETCH_EMPTY_HE
    I find that the code becomes uncompilable if I insert an empty line between those 2 lines:
    Line 1193: sv_setpvf(keysv, "%.15" NVgf, SvNV(arg)); Line 1194: Line 1195:#ifdef HV_FETCH_EMPTY_HE
    On both Ubuntu and MS Windows (perl-5.30.0 and others) that modification quickly produces the following error (during the 'make' stage of the build):
    Code is not inside a function (maybe last function was ended by a blan +k line followed by a statement on column one?) in ListUtil.xs, line 1 +195 Makefile:360: recipe for target 'ListUtil.c' failed
    Can someone explain that behaviour to me ?
    Are XS files typically that sensitive to white space ? (I've struck nothing like it before.)

    Cheers
    Rob
Running interactive SSH session in windows
3 direct replies — Read more / Contribute
by srinidhi27
on Aug 24, 2019 at 03:53

    Team, i know this has been in discussion for long time. But i haven't got an answer searching entire web since yesterday. I need to run series of commands in windows after logging to an server running SSH server.

    The problem is as you might have guessed being interactive.....

    I can run one of commands bby lot of methods.. I will list what i have tried so that people can suggest something i don't know.

    1. Net::SSH2 -- not supported in windows

    2. Net:OpenSSH -- again not supported in windows

    3. Install openSSH in widnows itself and using System and backticks to run dos commands. Yes Openssh can be installed in windows

    without cgywin environment a discovery i made yesterday.

    4. IPC::Cmd, a tool similar to using system command but doesn't provide interactive session. Everytime you run new terminal session is spawned.

    5. Ofcourse tried plain system and exec and backticks also turned futile. Worked liked a charm for single command run and shutoff.

    6. IPC::Session, not avaiable in Active Perl i use and don't know how to install it currently. Supposedly provides for interactive session using terminal. Not been able to get it working..

    7. plink tool is also good failing to work even when list of commands is fed to it externally. Cisco Box i am trying to SSH to is throwing illegal characters error. Weird right?

    Any leads is appreciated..

DBI vs Apache::DBI
4 direct replies — Read more / Contribute
by DaisyLou
on Aug 23, 2019 at 08:25

    I have a bunch of scripts that "use DBI;" . One of the scripts, a particularly database intensive one, says "use Apache::DBI" (which incidentally fail to load).

    Is there a difference between Apache::DBI and DBI or can I just change this line to "use DBI" without impact?

Convert pem to ssh-rsa
1 direct reply — Read more / Contribute
by jpsaraiva
on Aug 23, 2019 at 08:06

    Hello

    On Windows, I'm using Crypt::PK::RSA to generate key pairs like this:

    use Crypt::PK::RSA; my $pk = Crypt::PK::RSA->new(); $pk->generate_key(256, 65537); my $private_pem = $pk->export_key_pem('private'); my $public_pem = $pk->export_key_pem('public');

    Private key format is fine. Public key is generated like this:

    -----BEGIN RSA PUBLIC KEY----- ... -----END RSA PUBLIC KEY-----

    Since I need to add this key to authorized_keys files it needs to be in a ssh-rsa format.

    Can easly be done using ssh-keygen to convert:

    $ ssh-keygen -y -f privatekey > publickey

    I found this thread explaining the process and having several solutions none perl based.

    And all end up being dependent on ssh-keygen or open-ssl both not natively available on Windows

    Does anyone know how to do this only in perl or if it is even possible?

net::ssh::perl Wrong key type
1 direct reply — Read more / Contribute
by jpsaraiva
on Aug 22, 2019 at 13:23
    Hello, I'm trying to write some code capable of authenticating with a private key on windows. I generate my key with no passphrase:
    c:\var\client>ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/user/.ssh/id_rsa): client_k +ey Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in client_key. Your public key has been saved in client_key.pub. The key fingerprint is: SHA256:eBU07eoloUWInreyZ2WkYMvBAhISc2OIsiE1gp+iS4E user@localhost The key's randomart image is: +---[RSA 3072]----+ |O=* . o+. | |X=.o . . .o. | |+= o o . ... | |E.o . B...+ . | |... +.=S* o | |.. +.+ = . | |.. o + o | |. . o . | | o | +----[SHA256]-----+
    The key can be used successfully to authenticate:
    c:\var\client>ssh -i client_key localhost Last login: Thu Aug 22 16:34:22 2019 $
    My perl code is very simple at the moment:
    use Net::SSH::Perl; my $server='localhost'; my %params = ( "protocol" => '2', "use_pty" => 0, "options" => ["stricthostkeychecking no"], "identity_files" => ["client_key"], "debug" => 1, ); $ssh = Net::SSH::Perl->new($server, %params); $ssh->login();
    But executing it returns Wrong key type.
    c:\var\client>perl test.pl localhost: Reading configuration data C:\Users\user\.ssh\config localhost: Reading configuration data C:\windows\ssh_config localhost: Connecting to localhost, port 22. localhost: Remote version string: SSH-2.0-OpenSSH_8.0 localhost: Remote protocol version 2.0, remote software version OpenSS +H_8.0 localhost: Net::SSH::Perl Version 2.14, protocol version 2.0. localhost: No compat match: OpenSSH_8.0. localhost: Connection established. localhost: Sent key-exchange init (KEXINIT), waiting for response. localhost: Using curve25519-sha256@libssh.org for key exchange localhost: Host key algorithm: ssh-ed25519 localhost: Algorithms, c->s: chacha20-poly1305@openssh.com <implicit> +none localhost: Algorithms, s->c: chacha20-poly1305@openssh.com <implicit> +none localhost: Generating ephemeral key pair. localhost: Entering Curve 25519 Key Exchange. localhost: Sent client public key, waiting for reply. localhost: Received host key, type 'ssh-ed25519'. localhost: Host 'localhost' is known and matches the host key. localhost: Verifying server signature. localhost: Send NEWKEYS. localhost: Waiting for NEWKEYS message. localhost: Enabling encryption/MAC/compression. localhost: Sending request for user-authentication service. localhost: SSH2_MSG_EXT_INFO received localhost: SSH Extension activated: server-sig-algs=ssh-ed25519,ssh-rs +a,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-ni +stp384,ecdsa-sha2-nistp521 localhost: Service accepted: ssh-userauth. localhost: Trying empty user-authentication request. localhost: Authentication methods that can continue: publickey,passwor +d,keyboard-interactive. localhost: Next method to try is publickey. localhost: Trying pubkey authentication with key file 'client_key' Wrong key type at C:/Strawberry/perl/site/lib/Net/SSH/Perl/Auth/Public +Key.pm line 83.
    I've tried generating DSA type keys and the error is the same. Googling it is not helping either.

    Any help appreciated!

    Regards.

Undef value in Template Toolkit
1 direct reply — Read more / Contribute
by DreamT
on Aug 20, 2019 at 10:13
    Hi,
    I want to set a value to undef in a TT template:
    [% hashref.value1 = undef %]
    , but this only produces an empty string.
    $VAR1 = { ... 'value1' => '' ... }

    Is there a way around this? From what I've read it seems to be a "feature" in Template Toolkit that undefs are treated as empty strings.
minimal superstrings/maximal substrings
6 direct replies — Read more / Contribute
by stevena
on Aug 19, 2019 at 20:23

    Given a lexicon with long words and short words (happening to be length 9 and up, and 8 and down, respectively), I am looking to enumerate all minimal extensions of a short by a long; that is, with no intervening word (either long or short) that extends the short and is extended by the long. (Extensions could also be called strict superstrings.)

    I.e., if   'w > x' means word w extends word x, I want to find all pairs (L, S), such that:

    * L > S

    * there's no W with L > W > S,

    where L, S, W are restricted to lexicon words.

    For example, (NUMERICAL, NUMERIC) is desired, but not (SOCIOBIOLOGIST, OLOGIST) because SOCIOBIOLOGIST > BIOLOGIST > OLOGIST.

    I am looking for transparent code conducive to my adding less interesting constraints. (Fine if you guide me without writing the code. Also happy to see code.)

    Not homework or work -- solely hobby-related. Thanks!

New Meditations
Help with my crap
4 direct replies — Read more / Contribute
by stevieb
on Aug 22, 2019 at 20:59

    Esteemed Monks and fellow travelers,

    I'm in a position where I've got a tad bit too much to handle, so I'm putting out a request.

    For years, I've supported Perl in ways that nearly defied logic relative to my real life. Came from nothing, did something, blah blah blah.

    Many have done that. What I appreciate is the attentive use and comprehensive addition to Perl that so many Monks and others have contributed to my favourite language over the last near-20-years.

    Now, I'm not as dynamic. I'm not as fluid and liquid to bounce from one thing to the other by the minute. I can't maintain my library of software myself anymore.

    For that, and for many other reasons, I'm hoping to liquidate or at least get help with some of my Open Source Software projects.

    I'm STEVEB on the CPAN, and my repo stash is here. Take a look and let me know if there's anything you'd like to grab or take part in.

    berrybrew, as well as a few CPAN dists I favour I'd like to oversee, but mostly, take a look and let me know if you want to overtake anything.

    License retention, DVCS experience (repos stay in a freely-available and accessible location), and a proven love for Perl are absolute requirements. I put my love into what I've done. I would hope someone would take my silly code and keep it something that's usable.

    One last statement... don't take job offers seriously without doing extreme and exceptional due diligence. I got fucked up the ass while I had head injuries. Sickening, yep, fucking angering, yep, don't accept any job if you don't get paid in advance. This world is a different place anymore. I am just too tired to be raped without appreciation.

    Street-smart linguistic troublemaker who didn't see a fabricated theft coming right at him. I'm ashamed.

    -stevieb

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2019-08-25 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?