Re: why can't I collapse reference variable?

2009-11-28 Thread C.DeRykus
On Nov 24, 11:14 am, mark_galeck_spam_mag...@yahoo.com (Mark_Galeck) wrote: > If I can do this: > > $ref = \...@foobar; > print @$ref; > > then why can't I do this: > > print @\...@foobar; Because you're asking the parser to do too much. It needs to quickly identify the reference without ambiguity

reference to anonymous array, references last element instead??

2009-11-28 Thread Mark_Galeck
Why does $foobar = \("foo", "bar"); print $$foobar; print "bar" ?? Thank you for any insight. Mark -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: reference to anonymous array, references last element instead??

2009-11-28 Thread John W. Krahn
Mark_Galeck wrote: Why does $foobar = \("foo", "bar"); print $$foobar; print "bar" ?? Thank you for any insight. Mark Because \("foo", "bar") is really (\"foo", \"bar") and the comma operator in scalar context will return the last item listed so: $foobar = \("foo", "bar"); Is just: $

Re: reference to anonymous array, references last element instead??

2009-11-28 Thread John Refior
Just replying to add that you can use square brackets for an array literal: $foobar = ['foo', 'bar']; See http://perldoc.perl.org/perlref.html#Making-References . John On Sat, Nov 28, 2009 at 5:53 AM, John W. Krahn wrote: > Mark_Galeck wrote: > >> Why does >> >> $foobar = \("foo", "bar"); >>

Re: reference to anonymous array, references last element instead??

2009-11-28 Thread John Refior
Woops - meant to write "anonymous array" literal. $foobar will be a reference to the anonymous array that contains ('foo', 'bar'). - John On Sat, Nov 28, 2009 at 6:03 AM, John Refior wrote: > Just replying to add that you can use square brackets for an array literal: > > > $foobar = ['foo', 'b

reference to anonymous array, references last element instead??

2009-11-28 Thread Mark_Galeck
Why does $foobar = \("foo", "bar"); print $$foobar; print "bar" ?? Thank you for any insight. Mark -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Separating DB operations out of program code

2009-11-28 Thread Dermot
2009/11/27 Steve Bertrand : > Dermot wrote: >> 2009/11/26 Scott Pham : >>> Have you looked at DBIx::Class? >>> >> >> I'd 2nd that. DBIx is the way forward. You should be looking to stop >> writing SQL statements and moving towards ORM. Try the example at >> http://search.cpan.org/~frew/DBIx-Class-0

Re: remove directory from @INC

2009-11-28 Thread Huub van Niekerk
Thank you for your answer. I changed the beginning of my code to this: #!/usr/bin/perl no lib "/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/"; use lib "/usr/lib/perl5/5.10.0/i386-linux-thread-multi/"; use DBI; use strict; use warnings; use PostScript::Simple; No errors are given

Autovivification of hash from an array

2009-11-28 Thread Jeremiah Foster
Hi there! This may or may not be a beginners question. If not, please let me know where I ought to post. :-) I have a data structure, a simple array. It is made up of sections of files I have slurped; sub _build_packages { use Perl6::Slurp; my @p

Re: Autovivification of hash from an array

2009-11-28 Thread Jeremiah Foster
Edit: Added missing 'push' to code example. On Nov 28, 2009, at 14:13, Jeremiah Foster wrote: > Hi there! > > This may or may not be a beginners question. If not, please let me know > where I ought to post. :-) > > I have a data structure, a simple array. It is made up of sections

Re: Autovivification of hash from an array

2009-11-28 Thread Shawn H Corey
Jeremiah Foster wrote: >> my %versions; >>map { >> my $package = $_; >> # autovivfy a hash with versions of packages >> $versions{$package} = [ ] unless exists $versions{$package}; > push @{ $versions{$package} = $version >} @packages You don't

Re: Autovivification of hash from an array

2009-11-28 Thread Jeremiah Foster
On Nov 28, 2009, at 15:25, Shawn H Corey wrote: > Jeremiah Foster wrote: >>> my %versions; >>> map { >>> my $package = $_; >>> # autovivfy a hash with versions of packages >>> $versions{$package} = [ ] unless exists $versions{$package}; >> push @{ $versions{$

Re: Autovivification of hash from an array

2009-11-28 Thread John W. Krahn
Jeremiah Foster wrote: Hi there! Hello, This may or may not be a beginners question. If not, please let me know where I ought to post. :-) I have a data structure, a simple array. It is made up of sections of files I have slurped; sub _build_packages { use Perl6::Slurp; Do you reall

Re: Autovivification of hash from an array

2009-11-28 Thread Uri Guttman
> "JF" == Jeremiah Foster writes: JF> # autovivfy a hash with versions of packages JF> $versions{$package} = [ ] unless exists $versions{$package}; that is MANUALLY vivifying an array. if you just pushed to the slot with a dereference, that would be autovivifying. only p

Re: Assignment Operator

2009-11-28 Thread Jenda Krynicky
From: Marco Pacini Subject:Assignment Operator Date sent: Thu, 26 Nov 2009 12:31:54 +0100 To: beginners@perl.org > Hi All, > > I'm studying Perl since one week on "Learning Perl" written by L. Wall > and in the paragraph "Assignm

PRINT LAST ENTRY IN A FILE

2009-11-28 Thread raphael()
Hi, I want to print the last entry by record "" in this file "records.txt" The file is read in a subroutine and prints last line by the number in this example. # records.txt 25.11.2009 NAME_0 15.12.2006 NAME_3 20.10.2007 NAME_1 01.01.2008 NAME_3<-- This whole line sho

Re: PRINT LAST ENTRY IN A FILE

2009-11-28 Thread Dermot
2009/11/28 raphael() : > Hi, Hi, > # records.txt > 25.11.2009 NAME_0 > 15.12.2006 NAME_3 > 20.10.2007 NAME_1 > 01.01.2008 NAME_3    <-- This whole line should be printed. > 10.10.2008 NAME_4 > > Using while in a while loop matching ( m// ) I get all the entries > havin

Re: PRINT LAST ENTRY IN A FILE

2009-11-28 Thread Dermot
2009/11/28 raphael() : >> 2009/11/28 raphael() : >> > Hi, >> Hi, >> >> > # records.txt >> > 25.11.2009 NAME_0 >> > 15.12.2006 NAME_3 >> > 20.10.2007 NAME_1 >> > 01.01.2008 NAME_3    <-- This whole line should be printed. >> > 10.10.2008 NAME_4 >> > >> > Using while in a whi

Re: remove directory from @INC

2009-11-28 Thread Owen
> Thank you for your answer. > > I changed the beginning of my code to this: > > #!/usr/bin/perl > no lib > "/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/"; > use lib "/usr/lib/perl5/5.10.0/i386-linux-thread-multi/"; > use DBI; > use strict; > use warnings; > use PostScript::Simpl

Re: remove directory from @INC

2009-11-28 Thread Huub van Niekerk
> > Well I have no idea if it will solve your problem, but try one of these; > > a. make a symbolic link between libssl.so.8 and libssl.so.10 b. or > simply copy libssl.so.10 as lbssl.so.8 > Thank you. Didn't think of "ln -s". That works now. -- To unsubscribe, e-mail: beginners-unsubscr...@

Re: Separating DB operations out of program code

2009-11-28 Thread Shlomi Fish
Hi Dermot! On Saturday 28 Nov 2009 13:53:45 Dermot wrote: > 2009/11/27 Steve Bertrand : > > Dermot wrote: > >> 2009/11/26 Scott Pham : > >>> Have you looked at DBIx::Class? > >> > >> I'd 2nd that. DBIx is the way forward. You should be looking to stop > >> writing SQL statements and moving towards

Insecure $ENV{PATH} message

2009-11-28 Thread Huub van Niekerk
Hi, I started getting this error after upgrading from Fedora 11 to 12. The line of code hasn't been changed: open my $LPR, '|-', qw/lpr -PDeskJet940C/ or die "can't fork lpr: $!"; The error is: "Insecure $ENV{PATH} while running with -T switch at" pointing at the line above. From articles on