Re: Indexing return value from split directly without explicit temporary variable?

2010-09-30 Thread John W. Krahn
siegfried wrote: I posted this on the news group comp.lang.perl yesterday and since I have not received a response (and it does not look very active) I am cross posting it here. This works: @p= split "\\.", @ARGV[0]; That is usually written as: @p = split /\./, $ARGV[0]; Why use an array sl

Re: Indexing return value from split directly without explicit temporary variable?

2010-09-30 Thread Uri Guttman
> "s" == siegfried writes: s> I posted this on the news group comp.lang.perl yesterday and since I have s> not received a response (and it does not look very active) I am cross s> posting it here. that group was removed over a decade ago. your news feed shouldn't even have it. the gro

Indexing return value from split directly without explicit temporary variable?

2010-09-30 Thread siegfried
I posted this on the news group comp.lang.perl yesterday and since I have not received a response (and it does not look very active) I am cross posting it here. This works: @p= split "\\.", @ARGV[0]; print "$p[0]\n" I want to write it as a onliner. How so I do that? Here is my attempt:

Re: No Output in Terminal

2010-09-30 Thread Jim Gibson
At 11:26 PM -0400 9/30/10, Mark wrote: On 9/30/10 10:59 PM, Chas. Owens wrote: The only thing I can do to reproduce what you are seeing is to place a control-d (aka ASCII character 4) in the file. Try saying this echo 'print "hello\n"' | perl - If that works, then try this: perl -nle 'print

Re: No Output in Terminal

2010-09-30 Thread Chas. Owens
On Thu, Sep 30, 2010 at 23:21, Mark wrote: >  On 9/30/10 10:59 PM, Chas. Owens wrote: >> >> The only thing I can do to reproduce what you are seeing is to place a >> control-d (aka ASCII character 4) in the file.  Try saying this >> >> echo 'print "hello\n"' | perl - >> >> If that works > >    It

Re: Trap syntax error inside eval?

2010-09-30 Thread Jon Hermansen
On Thu, Sep 30, 2010 at 8:34 PM, C.DeRykus wrote: > On Sep 30, 7:37 pm, jon.herman...@gmail.com (Jon Hermansen) wrote: > > Hey all, > > I have this block of code: > > > > sub is_valid_xml { > > > > > my ($content) = @_; > > > > > eval { > > > my $xs = XML::Simple->new(); > > >

Re: perl net::ssh module

2010-09-30 Thread C.DeRykus
On Sep 30, 5:19 am, irfan_sayed2...@yahoo.com (Irfan Sayed) wrote: > Hi, > > I am using net::ssh module of Perl to connect to remote machine and execute > some > remote commands > i can connect using user-name and password hard coded in the script like > below: > > #!/usr/local/bin/perl > > use s

Re: No Output in Terminal

2010-09-30 Thread Parag Kalra
Thats ^M character. You can get rid of them using vi: :%s/^M//g Cheers, Parag On Thu, Sep 30, 2010 at 8:26 PM, Mark wrote: > On 9/30/10 10:59 PM, Chas. Owens wrote: > >> The only thing I can do to reproduce what you are seeing is to place a >> control-d (aka ASCII character 4) in the file.

Re: Trap syntax error inside eval?

2010-09-30 Thread C.DeRykus
On Sep 30, 7:37 pm, jon.herman...@gmail.com (Jon Hermansen) wrote: > Hey all, > I have this block of code: > > sub is_valid_xml { > > >     my ($content) = @_; > > >     eval { > >         my $xs = XML::Simple->new(); > >         my $ref = $xs->parse_string($content); > >     }; > > >     return 1

loading and comparing large hashes

2010-09-30 Thread Richard Green
Hi everyone, could use some advice on a perl script I wrote using hashes. I have three files ( each file is a list of indexes) my program loads these indexes into hashes and compares the differences and similarities between them. With smaller files it runs fine. problem is I now files have about 88

Re: No Output in Terminal

2010-09-30 Thread Mark
On 9/30/10 10:59 PM, Chas. Owens wrote: The only thing I can do to reproduce what you are seeing is to place a control-d (aka ASCII character 4) in the file. Try saying this echo 'print "hello\n"' | perl - If that works, then try this: perl -nle 'print for grep { $_< 31 or $_> 126 } map or

Re: No Output in Terminal

2010-09-30 Thread Mark
On 9/30/10 10:59 PM, Chas. Owens wrote: The only thing I can do to reproduce what you are seeing is to place a control-d (aka ASCII character 4) in the file. Try saying this echo 'print "hello\n"' | perl - If that works It did. then try this: perl -nle 'print for grep { $_< 31 or $_>

Re: No Output in Terminal

2010-09-30 Thread Chas. Owens
On Thu, Sep 30, 2010 at 22:48, Mark wrote: >  On 9/30/10 10:32 PM, Chas. Owens wrote: >> >> That is very odd, it should be working.  Just to make sure it is not >> some weirdness with iTerm (I use iTerm, so that shouldn't be the >> problem), try using Apple's Terminal.app instead. > > Same result

Re: No Output in Terminal

2010-09-30 Thread Mark
On 9/30/10 10:32 PM, Chas. Owens wrote: That is very odd, it should be working. Just to make sure it is not some weirdness with iTerm (I use iTerm, so that shouldn't be the problem), try using Apple's Terminal.app instead. Same result in Terminal.app. Also, I have Debian-Lenny running in Vir

Re: No Output in Terminal

2010-09-30 Thread Mark
On 9/30/10 10:38 PM, Parag Kalra wrote: Few questions/suggestions: Which shell are you on? i.e echo $SHELL /bin/bash whats the location of the perl binary: i.e which perl /usr/bin/perl Can you invoke the program using 'use strict' and let us know the output I've edited the test.

Re: No Output in Terminal

2010-09-30 Thread Parag Kalra
Few questions/suggestions: Which shell are you on? i.e echo $SHELL whats the location of the perl binary: i.e which perl Can you invoke the program using 'use strict' and let us know the output Can you try this: perl -e 'print "Hello World"' Cheers, Parag On Thu, Sep 30, 2010 at 7:25 PM, Mark

Trap syntax error inside eval?

2010-09-30 Thread Jon Hermansen
Hey all, I have this block of code: sub is_valid_xml { > my ($content) = @_; > > eval { > my $xs = XML::Simple->new(); > my $ref = $xs->parse_string($content); > }; > > return 1 unless ($@); > } > and when I pass in 'blahblahblah' as an argument, I get: syntax err

Re: No Output in Terminal

2010-09-30 Thread Chas. Owens
On Thu, Sep 30, 2010 at 22:25, Mark wrote: >  Hi. Perl newbie here. I'm on a MBP using Leopard (10.5.8). Perl is > pre-installed: /usr/bin/perl. > > I can't get a simple "Hello world" script to work. Here's the script (saved > as test.pl). > >    #!/usr/bin/perl -w >    print "Hello world!\n"; > >

No Output in Terminal

2010-09-30 Thread Mark
Hi. Perl newbie here. I'm on a MBP using Leopard (10.5.8). Perl is pre-installed: /usr/bin/perl. I can't get a simple "Hello world" script to work. Here's the script (saved as test.pl). #!/usr/bin/perl -w print "Hello world!\n"; Permissions are set to 755. In a terminal application

Re: Fwd: Re: How do I remove repreating lines from an array?

2010-09-30 Thread John W. Krahn
Rob Dixon wrote: John; please listen? ?? John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl

Fwd: Re: How do I remove repreating lines from an array?

2010-09-30 Thread Rob Dixon
John; please listen? -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-m

Re: How do I remove repreating lines from an array?

2010-09-30 Thread Octavian Rasnita
From: "venkates" > Hi all, > > I have written a piece of code which takes in to list of terms and > retrieves the intersection between the two list of terms. The code works > fine but it the intersection list has redundant in its terms. How do I > fix this? The code is given below. Try this:

Re: How do I remove repreating lines from an array?

2010-09-30 Thread John W. Krahn
venkates wrote: Hi all, Hello, I have written a piece of code which takes in to list of terms and retrieves the intersection between the two list of terms. The code works fine but it the intersection list has redundant in its terms. How do I fix this? perldoc -q intersection The code is

Re: How do I remove repreating lines from an array?

2010-09-30 Thread Shawn H Corey
On 10-09-30 10:56 AM, venkates wrote: I have written a piece of code which takes in to list of terms and retrieves the intersection between the two list of terms. The code works fine but it the intersection list has redundant in its terms. How do I fix this? The code is given below. See `perldo

How do I remove repreating lines from an array?

2010-09-30 Thread venkates
Hi all, I have written a piece of code which takes in to list of terms and retrieves the intersection between the two list of terms. The code works fine but it the intersection list has redundant in its terms. How do I fix this? The code is given below. #!/usr/bin/perl -w use Carp; use stri

RE: Alternative to while ()

2010-09-30 Thread Ken Slater
-Original Message- >From: Owen Chavez [mailto:owen.chavez314...@gmail.com] >Sent: Thursday, September 30, 2010 2:41 AM >To: beginners@perl.org >Subject: Alternative to while () > >Hey y'all, > >I suspect that I'm struggling with something that has a *really* >straightforward alternative, b

perl net::ssh module

2010-09-30 Thread Irfan Sayed
Hi, I am using net::ssh module of Perl to connect to remote machine and execute some remote commands i can connect using user-name and password hard coded in the script like below: #!/usr/local/bin/perl use strict; use Net::SSH::Perl; my $host="dna-ci2.data.corp.sp1.xxx.com"; my $cmd="ls"; my