[29612] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 856 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 17 03:09:39 2007

Date: Mon, 17 Sep 2007 00:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 17 Sep 2007     Volume: 11 Number: 856

Today's topics:
    Re: Challenge: CPU-optimized byte-wise or-equals (for a xhoster@gmail.com
    Re: Challenge: CPU-optimized byte-wise or-equals (for a <m@rtij.nl.invlalid>
    Re: Challenge: CPU-optimized byte-wise or-equals (for a <hjp-usenet2@hjp.at>
    Re: FAQ 4.18 Does Perl have a Year 2000 problem? Is Per <usenet@larseighner.com>
    Re: FAQ 4.18 Does Perl have a Year 2000 problem? Is Per <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: HTTP Filtering and Threads... <danett18@yahoo.com.br>
    Re: Installing XS Modules on Windows -- Like Pulling Te <bik.mido@tiscalinet.it>
        looking at parsing procedures <zaxfuuq@invalid.net>
        Module::Install can't locate required modules <matteo.corti@gmail.com>
        new CPAN modules on Mon Sep 17 2007 (Randal Schwartz)
    Re: Newbie question: load data to array <m@rtij.nl.invlalid>
    Re: Question on input password on ssh prompt <mluvw47@gmail.com>
        Send Carriage return <dietrich.speer@gmail.com>
    Re: Send Carriage return <paduille.4061.mumia.w+nospam@earthlink.net>
        Thank you for Perl <electrician@electrician2.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 16 Sep 2007 23:22:32 GMT
From: xhoster@gmail.com
Subject: Re: Challenge: CPU-optimized byte-wise or-equals (for a meter of beer)
Message-Id: <20070916192235.807$qn@newsreader.com>

Martijn Lievaart <m@rtij.nl.invlalid> wrote:
> On Sat, 15 Sep 2007 23:22:29 +0000, xhoster wrote:
>
> > Martijn Lievaart <m@rtij.nl.invlalid> wrote:
> >> On Thu, 13 Sep 2007 18:46:55 +0000, xhoster wrote:
> >>
> >> > For my own effort, I perhaps cheated by using Inline C, and
> >> > depending on the C representations of both strings being null
> >> > terminated.
> >>
> >> But s1 contains null characters, so this won't work.
> >
> > Did you try it?
> >
> > If s1 did *not* contain null characters, then there would be no point.
> > The fact that s1 does contain null characters is what this is all
> > about. The point is that it also needs to end with a null character,
> > regardless of what null it has in the middle.
>
> No I did not try it.

Or, apparently, understand it.

> I don't have to. this C implementation stops at the
> first null character.

Sure, it stops at the first null in s2.  But not the first null in s1.
Well, the *inner* loop does stop at the first null in s1, but then it
restarts. And restarts again. And again. It doesn't stop for good until it
hits the "first" (and last) null in s2.

> Why do you think it'll behave otherwise?

Because I wrote it that way on purpose, and because I tested it.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


------------------------------

Date: Sun, 16 Sep 2007 23:23:02 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Challenge: CPU-optimized byte-wise or-equals (for a meter of beer)
Message-Id: <pan.2007.09.16.21.18.49@rtij.nl.invlalid>

On Sat, 15 Sep 2007 23:22:29 +0000, xhoster wrote:

> Martijn Lievaart <m@rtij.nl.invlalid> wrote:
>> On Thu, 13 Sep 2007 18:46:55 +0000, xhoster wrote:
>>
>> > For my own effort, I perhaps cheated by using Inline C, and depending
>> > on the C representations of both strings being null terminated.
>>
>> But s1 contains null characters, so this won't work.
> 
> Did you try it?
> 
> If s1 did *not* contain null characters, then there would be no point.
> The fact that s1 does contain null characters is what this is all about.
> The point is that it also needs to end with a null character, regardless
> of what null it has in the middle.

No I did not try it. I don't have to. this C implementation stops at the 
first null character. Why do you think it'll behave otherwise?

M4


------------------------------

Date: Mon, 17 Sep 2007 00:24:29 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Challenge: CPU-optimized byte-wise or-equals (for a meter of beer)
Message-Id: <slrnferb8t.b1r.hjp-usenet2@zeno.hjp.at>

On 2007-09-16 21:23, Martijn Lievaart <m@rtij.nl.invlalid> wrote:
> On Sat, 15 Sep 2007 23:22:29 +0000, xhoster wrote:
>> Martijn Lievaart <m@rtij.nl.invlalid> wrote:
>>> On Thu, 13 Sep 2007 18:46:55 +0000, xhoster wrote:
>>>
>>> > For my own effort, I perhaps cheated by using Inline C, and depending
>>> > on the C representations of both strings being null terminated.
>>>
>>> But s1 contains null characters, so this won't work.
>> 
>> Did you try it?
>> 
>> If s1 did *not* contain null characters, then there would be no point.
>> The fact that s1 does contain null characters is what this is all about.
>> The point is that it also needs to end with a null character, regardless
>> of what null it has in the middle.
>
> No I did not try it. I don't have to.

You may not have to try it, but you have to read the code more
carefully.

> this C implementation stops at the first null character. Why do you
> think it'll behave otherwise?

Because that's how he programmed it?

(BTW, the use of NULL is wrong - that should be 0 or '\0').

	hp


-- 
   _  | Peter J. Holzer    | I know I'd be respectful of a pirate 
|_|_) | Sysadmin WSR       | with an emu on his shoulder.
| |   | hjp@hjp.at         |
__/   | http://www.hjp.at/ |	-- Sam in "Freefall"


------------------------------

Date: 16 Sep 2007 20:04:46 GMT
From: Lars Eighner <usenet@larseighner.com>
Subject: Re: FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
Message-Id: <slrnfer32e.1tip.usenet@debranded.larseighner.com>

In our last episode, <68b0s4-0ii.ln1@blue.stonehenge.com>, the lovely and
talented PerlFAQ Server broadcast on comp.lang.perl.misc:

> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?

Isn't it about time to give this FAQ its gold watch and send it off to the
home?


-- 
Lars Eighner     <http://larseighner.com/>     <http://myspace.com/larseighner>
                         Countdown: 491 days to go.
                    What do you do when you're debranded?


------------------------------

Date: Sun, 16 Sep 2007 15:34:49 -0500
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
Message-Id: <13erbj61d68gmf4@corp.supernews.com>

On 09/16/2007 03:04 PM, Lars Eighner wrote:
> In our last episode, <68b0s4-0ii.ln1@blue.stonehenge.com>, the lovely and
> talented PerlFAQ Server broadcast on comp.lang.perl.misc:
> 
>> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
> 
> Isn't it about time to give this FAQ its gold watch and send it off to the
> home?
> 
> 

No, it's still needed for historical reference, and there are a few 
people who will have to deal with pre-2000-written scripts.

The discussion of some date issues is also important.



------------------------------

Date: Sun, 16 Sep 2007 18:13:00 -0700
From:  Dan <danett18@yahoo.com.br>
Subject: Re: HTTP Filtering and Threads...
Message-Id: <1189991580.760508.230200@22g2000hsm.googlegroups.com>

Hi Ben,

How are you?

First of all, thank you for the help and fast reply. :)

>You are trying to parse HTML with regular expressions. This is a very
>bad idea. I would strongly recommend using HTML::Parser, or another
>module capable of actually parsing HTML.

Hummm, thank you for the suggestion. I will look at it.

Anyway, I fixed the problem, it was so dumb. To fix I just done it:

my ($value) = $_ =~ /input name="$mdName" type=.* value="(.*)">/i;

And all worked. My problem was:

- Using two variables to recieve responses (my ($value, $name)...).

- Use the * regex operator as you spoted. :)

>> (my $ruid, @userIDs) = &GetUserList($start, $end);

>Don't call subs with &. It was a Perl 4 practice, and has some strange side-effects in Perl 5.

Fixed. Thank you for tip.

Anw what about if someone try to run this script in a old box with
perl 4? It will fail without the & before call stubs?

>Also, it seems to be getting the value of the user ID from a global
>variable: again, it would be better to pass it to the function.

Ok, I fixed it. Now the variables are local and passed as arguments
via functions and values returned via functions.:)

>Note that this may well not make it run faster. Unless you have 8
>processors (lucky you ;) ), it will just make things slower.

>One thing that may be slowing things down is if you are fetching and
>parsing the same page many times. You may want to look at the Memoize
>module as an easy way of avoiding that.

Hehehe, my slow problem is not exactly related with processing power,
but with only do one connection by each time, and it take much time to
do all the job. So I would like to do some (6, 7, 8) connections in
parallel, I'm sure my machine with 1 processor will not decept me in
work just with 8 simultaneous connections. :)

>The simplest way to multi-thread the above is something like

>use threads;

>foreach $userID (@userIDs) {
>    async {
>        my ($name, $middlename, $lname, $bdate) =
>            GetUserData($userID);
>
>        print "$userID\t: $name, $middlename, $lname, $bdate";
>
>        # Some irrelevant code stuff...
>    }
>
>}

>This will run each request in a new thread; but as you have identified,
>the output will come out any which way.

Humm... but in this example, how I define the number of threads (6, 7,
8) to spawn? :)

>If you really want to use threads, you want to use something like Thread::Queue to pass the
>results back to the parent thread, which can then deal with printing them.

This code appear veryyy simple, I loved it. :)

Unhaply it doesn`t  meet the needs, I will look for this
Thread::Queue.

Wait, maybe I can use it. There are exist lock()/mutex() in perl?

So I can do something like this:

use threads;

foreach $userID (@userIDs) {
    async { # I need to learn define number of threads :)
        my ($name, $middlename, $lname, $bdate) =
            GetUserData($userID);
    }


    lock($name);
    lock($middlename);
    lock($lname);
    lock($bdate);

    # Some irrelevant code stuff...

    print "$userID\t: $name, $middlename, $lname, $bdate";

    unlock($name);
    unlock($middlename);
    unlock($lname);
    unlock($bdate);

    # Some irrelevant code stuff...

}

Is it possible? Or something equivalent?

In this way, I can grant the output will not be printed out of order,
but I can grant the value of variables will not be overwritten by
other threads before I manipulate and print it. :)


>This is not an issue in Perl. Threads have completely separate
>variables: threads in Perl are more like Unix' fork than like
>traditional C threading.

Humm...

>I've never used perl2exe (I understand it's not free?),


Don't know what is the license, but everybody can download from:

http://www.indigostar.com/perl2exe.htm#Download

Maybe a freeware?

>but I have had success with PAR, which you can install from CPAN.

Nice, I never had seen it before. Really good. :)

I installed it via cpan, but it doesn't installed the "pp" binary used
to convert packages.

I tryed via Perl as documentation say:

perl -MPAR=packed.exe other.pl

But it doesn`t work. Instead of generate a packed.exe, it only execute
my perl script (exactly as if I had called perl other.pl).

Well, anyway, Debian have a package (libpar-perl) with "pp"
included. :)

So I generated a executable from it:

pp -o packed.exe source.pl

Lol! My code in perl is around 10k and the output .exe is around
2.7MB, insane. hehehe

Does exist any optimization option for PAR? ;)

I belive it should had generated a executable for Windows (PE), right?
How I define if the output is for Linux (ELF) or Windows (PE)?

Couldn't locate it in documentation....

My binary definitive is for Linux, as file say:

Other.exe: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for GNU/
Linux 2.4.1, stripped

And in Linux it run well. If I copy to windows, as expected it doesn't
work. :/

E:\>other.exe
Program too big to fit in memory

Any idea how to solve it?

>That's fine: there's nothing wrong with writing bad code when you are
>first learning :). The code you posted isn't half as bad as some we see
>in this group, anyway...

Thank you! You are really friendly.

>Not off-topic at all, and not dumb neither.

:)

>Ben

Thank you again.

Cheers



------------------------------

Date: Sun, 16 Sep 2007 20:55:58 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Installing XS Modules on Windows -- Like Pulling Teeth
Message-Id: <qvuqe3ld1nii7964s91pd92thjm0cud8o7@4ax.com>

On Sun, 16 Sep 2007 15:28:30 -0000, FeelLikeANut@gmail.com wrote:

>I'm running on Windows with ActivePerl, and I'm trying to install
>XML::LibXML. It's not in the PPM repository, so that's out of the
>question. I downloaded MinGW, so I have gcc, and I downloaded both

Did you try other repositories?

http://win32.perl.org/wiki/index.php?title=PPM_Repositories


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Mon, 17 Sep 2007 00:41:10 -0700
From: "merl the perl" <zaxfuuq@invalid.net>
Subject: looking at parsing procedures
Message-Id: <0tKdnQDBi4kFvHPbnZ2dnUVZ_h6vnZ2d@comcast.com>

I have posted in the memorable past about using the Perl Programming 
Language to make a unBuckeyesque yikes.

Instead of something thnt has to do with Ohio; im looking to develop my 
first if statemnet.  Hot here in the desert.

I would lijke to use tppl to test for a condition.

The condition for which I would like to test is whether the dude ho sends it 
is 'Wade Ward'.

This person must use perl programming .  Sometimes blind.

, and, for good measure, tja.
-- 
tja
and 




------------------------------

Date: Sun, 16 Sep 2007 21:20:24 -0000
From:  Teo <matteo.corti@gmail.com>
Subject: Module::Install can't locate required modules
Message-Id: <1189977624.786838.31640@d55g2000hsg.googlegroups.com>

Hi,

I just tried to write my first Makefile.PL as follows:

  # Load the Module::Install bundled in ./inc/
  use inc::Module::Install;

  # Define metadata (we read it from the script)
  name          'dprofpp_grapher';
  abstract_from 'dprofpp_grapher';
  author_from   'dprofpp_grapher';
  version_from  'dprofpp_grapher';
  license_from  'dprofpp_grapher';

  # Specific dependencies
  require 'Data::Dumper' => 0;
  # other requirements stripped

  install_script  'dprofpp_grapher';

  auto_install;

  WriteAll;

All the required modules are available: I can run

  perl -e "use Data::Dumper;"

for all the required modules without any problem.

When I run

  perl Makefile.PL

I get

  include /Users/corti/svn/nethz/tools/dprofpp_grapher/inc/Module/
Install.pm
  include inc/Module/Install/Metadata.pm
  include inc/Module/Install/Base.pm
  Can't locate Data::Dumper in @INC (@INC contains: inc /sw/lib/
perl5/5.8.6/darwin-thread-multi-2level
  /sw/lib/perl5/5.8.6 /sw/lib/perl5 /sw/lib/perl5/darwin
  /System/Library/Perl//5.8.6/darwin-thread-multi-2level /System/
Library/Perl//5.8.6
  /System/Library/Perl/ /System/Library/Perl/5.8.6//darwin-thread-
multi-2level
  /System/Library/Perl/5.8.6/ /System/Library/Perl/5.8.6/darwin-thread-
multi-2level/
  /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/
Library/Perl/5.8.6
  /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /
Library/Perl
  /Network/Library/Perl/5.8.6/darwin-thread-multi-2level /Network/
Library/Perl/5.8.6 /Network/Library/Perl
  /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level /System/
Library/Perl/Extras/5.8.6
  /Library/Perl/5.8.1/darwin-thread-multi-2level /Library/Perl/
5.8.1 .) at Makefile.PL line 16.

How can I make Modules::Install find the same modules as the perl
executable?

Many thanks for any hint.

Matteo



------------------------------

Date: Mon, 17 Sep 2007 04:42:20 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Sep 17 2007
Message-Id: <JoHx2K.6y8@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Archive-Tar-1.36
http://search.cpan.org/~kane/Archive-Tar-1.36/
module for manipulations of tar archives 
----
Atompub-0.1.3
http://search.cpan.org/~takeru/Atompub-0.1.3/
Atom Publishing Protocol implementation 
----
BDB-1.1
http://search.cpan.org/~mlehmann/BDB-1.1/
Asynchronous Berkeley DB access 
----
Bundle-Perl-Critic-1.01
http://search.cpan.org/~elliotjs/Bundle-Perl-Critic-1.01/
A CPAN bundle for Perl::Critic and related modules 
----
CGI-Multiscript-0.72
http://search.cpan.org/~morgothii/CGI-Multiscript-0.72/
Perl extension for Multiscript programming 
----
CGI-Multiscript-0.73
http://search.cpan.org/~morgothii/CGI-Multiscript-0.73/
Perl extension for Multiscript programming 
----
Catalyst-Controller-Atompub-0.1.3
http://search.cpan.org/~takeru/Catalyst-Controller-Atompub-0.1.3/
A Catalyst controller for the Atom Publishing Protocol 
----
Catalyst-Controller-LeakTracker-0.01
http://search.cpan.org/~nuffin/Catalyst-Controller-LeakTracker-0.01/
Inspect leaks found by Catalyst::Plugin::Leaktracker 
----
Catalyst-Model-Search-0.01
http://search.cpan.org/~mramberg/Catalyst-Model-Search-0.01/
----
Catalyst-Plugin-LeakTracker-0.01
http://search.cpan.org/~nuffin/Catalyst-Plugin-LeakTracker-0.01/
Use Devel::Events::Objects to track object leaks in the Catalyst request cycle. 
----
Color-Library-0.01
http://search.cpan.org/~rkrimen/Color-Library-0.01/
An easy-to-use and comprehensive named-color library 
----
Devel-Events-0.03
http://search.cpan.org/~nuffin/Devel-Events-0.03/
Extensible instrumentation framework. 
----
Devel-Events-Generator-ClassPublisher-0.01
http://search.cpan.org/~nuffin/Devel-Events-Generator-ClassPublisher-0.01/
Relay events from Class::Publisher 
----
Devel-Events-Objects-0.02
http://search.cpan.org/~nuffin/Devel-Events-Objects-0.02/
Object tracking support for Devel::Events 
----
Devel-PerlySense-0.01_18
http://search.cpan.org/~johanl/Devel-PerlySense-0.01_18/
IntelliSense for Perl 
----
Devel-STDERR-Indent-0.04
http://search.cpan.org/~nuffin/Devel-STDERR-Indent-0.04/
Indents STDERR to aid in print-debugging recursive algorithms. 
----
Encode-RAD50-0.005
http://search.cpan.org/~wyant/Encode-RAD50-0.005/
Convert to and from the Rad50 character set. 
----
File-CreationTime-2.04
http://search.cpan.org/~jrockway/File-CreationTime-2.04/
Keeps track of file creation times 
----
Getopt-Long-2.36_02
http://search.cpan.org/~jv/Getopt-Long-2.36_02/
Extended processing of command line options 
----
Kvasir-0.03
http://search.cpan.org/~claesjac/Kvasir-0.03/
Generic rule based processing engine 
----
Kvasir-0.04
http://search.cpan.org/~claesjac/Kvasir-0.04/
Generic rule based processing engine 
----
Module-Compile-TT-0.02
http://search.cpan.org/~nuffin/Module-Compile-TT-0.02/
Preprocess Perl code with Template Toolkit and Module::Compile. 
----
MooseX-AttributeHelpers-0.03
http://search.cpan.org/~nuffin/MooseX-AttributeHelpers-0.03/
Extend your attribute interfaces 
----
Net-GPSD-0.36
http://search.cpan.org/~mrdvt/Net-GPSD-0.36/
Provides an object client interface to the gpsd server daemon. 
----
Net-Jaiku-0.0400
http://search.cpan.org/~rickm/Net-Jaiku-0.0400/
A perl interface to jaiku.com's API 
----
Net-XMPP2-0.09
http://search.cpan.org/~elmex/Net-XMPP2-0.09/
An implementation of the XMPP Protocol 
----
Ogre-0.28
http://search.cpan.org/~slanning/Ogre-0.28/
Perl binding for the OGRE C++ graphics library 
----
Task-Perl-Critic-v1.003
http://search.cpan.org/~elliotjs/Task-Perl-Critic-v1.003/
Install everything Perl::Critic. 
----
Test-TableDriven-0.02
http://search.cpan.org/~jrockway/Test-TableDriven-0.02/
write tests, not scripts that run them 
----
Time-Decimal-0.07
http://search.cpan.org/~pfeiffer/Time-Decimal-0.07/
Pritraktu franc-revoluciajn dek horajn tagojn 
----
WWW-Mechanize-Meta-0.01
http://search.cpan.org/~gugu/WWW-Mechanize-Meta-0.01/
The great new WWW::Mechanize::Meta! 
----
WWW-Mechanize-Meta-0.02
http://search.cpan.org/~gugu/WWW-Mechanize-Meta-0.02/
Adds HEAD tag parsing to WWW::Mechanize 
----
Web-Scraper-0.15
http://search.cpan.org/~miyagawa/Web-Scraper-0.15/
Web Scraping Toolkit inspired by Scrapi 
----
Weewar-0.01
http://search.cpan.org/~jrockway/Weewar-0.01/
get data from the weewar.com XML API 
----
XML-Atom-0.26
http://search.cpan.org/~miyagawa/XML-Atom-0.26/
Atom feed and API implementation 
----
XML-Atom-0.27
http://search.cpan.org/~miyagawa/XML-Atom-0.27/
Atom feed and API implementation 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sun, 16 Sep 2007 21:40:24 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Newbie question: load data to array
Message-Id: <pan.2007.09.16.19.36.12@rtij.nl.invlalid>

On Sun, 16 Sep 2007 15:20:30 +0000, philbo30 wrote:

> I have a file with data like this:
> 
> 123
> 456
> 789
> 010
> 987
> 654
> 321
> 
> I want to load these values into an array called "$data". How do I make
> this happen?

open my $fh, "<", $filename or die "Cannot open $file: $!";
my @data;
while (<$fh>) {
	push @data, $_;
}
close $fh;

or use File::Slurp.

HTH,
M4


------------------------------

Date: Mon, 17 Sep 2007 06:02:44 -0000
From:  Mav <mluvw47@gmail.com>
Subject: Re: Question on input password on ssh prompt
Message-Id: <1190008964.130196.37600@57g2000hsv.googlegroups.com>

On Sep 16, 2:31 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Mav <mluv...@gmail.com>:
>
>
>
> > Hi, all
> >    I am writing a perl script running on the XP, the machine already
> > have openssh installed. The script would call ssh command and send a
> > command to the remote host.
> > The code like.
> <snip>
>
> > However right after I made the system call for ssh, it prompts for the
> > password.
>
> >   c:\>perl my.pl
> >   Invoke command on host : somehost
> >   enter password:   <---  my program stopped right here waiting.
>
> >   I understood that perl provides pm packages (in this case SSH) to
> > get this work done, but the script I am going to run, only will get
> > the perl installed and perl.dll, not extra module.
>
> You can use PAR (from CPAN) to package a script plus all dependant
> modules up into a single file that can be run with just perl installed.
> It's really not worth avoiding the use of modules.
>
> >   My question is:
> >   1) Is that a way I can feed it the password without install any
> > module?, if so, how?
>
> No. However, you can switch to public-key authentication, which doesn't
> require you enter the password.
>
> >   2) Or where I can find out more regarding input after prompt
> > waiting?
>
> Err... under Unix, the answer is 'use a pty'. I don't know if it is even
> possible to emulate this under Win32: it depends on exactly how ssh
> prompts for the password.
>
> Ben

Ben, Thanks for your input. I will look into PAR. I guess when after
the system call like
system("myapp.exe"), however, if myapp.exe is prompting for input, I
don't think perl will able to feed in the input then.

> No. However, you can switch to public-key authentication, which doesn't
> require you enter the password.

In fact, The actual script I am working actually first generates the
public key on the PC side(for that PC), then append the public key
into linux (.ssh/authorized_key) entry thru ssh command. So next time,
if the PC invokes a command from the PC to linux side thru ssh, it
will not prompt the password. Any suggestion?

Thanks,
Mav




------------------------------

Date: Mon, 17 Sep 2007 02:01:26 -0000
From:  280SEL <dietrich.speer@gmail.com>
Subject: Send Carriage return
Message-Id: <1189994486.541616.115890@57g2000hsv.googlegroups.com>

Hello:

I hope that someone can set me on the right track with this:

I am trying to establish a Heartbeat with a remote machine using Perl.
I am sending a string like so:

print $socket "$output";

In order to keep the line open, the remote machine wants a carriage
return at the end (HEX 0D).

I have tried the perl \n, I have tried all kinds of ways , including:

$output=$string.hex'0D';
print $socket "$output";

This, of course, translates the hex carriage return into Decimal 13
and sends that number which doesn't help.

Does anybody know how to do this?

Any help would be greatly appreciated!



------------------------------

Date: Sun, 16 Sep 2007 21:26:28 -0500
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Send Carriage return
Message-Id: <13erscjgqfsfi46@corp.supernews.com>

On 09/16/2007 09:01 PM, 280SEL wrote:
> [...]
> In order to keep the line open, the remote machine wants a carriage 
> return at the end (HEX 0D).
> [...]

print $socket "$output\x0D";


------------------------------

Date: Sun, 16 Sep 2007 17:44:37 -0700
From:  Jerry <electrician@electrician2.com>
Subject: Thank you for Perl
Message-Id: <1189989877.060540.79540@o80g2000hse.googlegroups.com>

Over the last 8 years Perl has made me about $400,000.  Without it I
would never have done it.  I am not a Perl programmer but have managed
to hack my way through a few programs using 14 books that I bought
new.  I also purchased several Perl programs.  At age 63 this was
quite an accomplishment proving that anyone with a determination can
make their way through Perl.  As a college student I learned Basic and
Fortran, then later, about 35 years later,  learned JavaScript.  What
I did not realize for a long time was that what Fortran is to the
number cruncher, Perl is to the text processor and data manipulator.
It is also the workhorse of the Internet and is a real money maker.
Learn Perl!!!



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 856
**************************************


home help back first fref pref prev next nref lref last post