comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
December 2007
motuwethfrsasuw
     12 48
3456789 49
10111213141516 50
17181920212223 51
24252627282930 52
31       1
2007
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Re: split is not convinient         


Author: Todd
Date: Dec 12, 2007 22:55

John W. Krahn wrote:
> Todd wrote:
>> Seems nobody here mentioned the magic that
>> split ' ', expr
>> is same as
>> split /\s+/, expr
>
> No it is not:
>
> $ perl

#! /bin/perl -l

$_ = q[ a b c];

$,=q/,/;
print split ' ';
print split /\s+/;

__END__

a,b,c
,a,b,c
Show full article (0.42Kb)
no comments
  Re: Get values from hash "in order"         


Author: John Bokma
Date: Dec 12, 2007 09:40

still just me yahoo.com> wrote:
> Newbie hash question:
>
> I have a hash loaded with keys / values. I need to pull the values out
> in the same order I have them physically listed in the source program
> (or use some scheme to achieve that).
>
> I pulled them like this:
>
> my $tempValue="";
> foreach $tempValue (values %%outputFileHeadings)
> {
> $outputMessage = $outputMessage . $tempValue
> }
>
> They seem to come out in a random order. Is there some way to pull
> them in the same order they are physically listed in the program ?

perldoc -q order
Show full article (0.73Kb)
no comments
  When do I need to define a function with "use POSIX qw(.....)" and when not ?         


Author: Thomas Blabb
Date: Dec 12, 2007 03:45

I saw sometimes perl scripts where functions are defined in the POSIX line and others where not.
Example:

When should I write:

use POSIX qw(strftime);
.... strftime ..... ;

and when simply:

use POSIX;
.... strftime ..... ;

Tom
1 Comment
  (1)[0] ok but not 1[0]         


Author: Florian Kaufmann
Date: Dec 12, 2007 01:55

Hello

I am still after the answer to the old question whats the difference
between an array and a list. Yes, I read the faq, and I am reading
Programming Perl.

In my current understanding, the array subscript operator [] forces
its left operand to be an array. Thus, if that left operand is a list,
that list is converted to an array. Thus things like
$x = (1,2,3)[0];
$x = (3)[0];

work. But then again, why shoudn't that work?
$x = 3[0];

I thought it's the operator , which composes/constructs a list, not
parantheses. Parantheses are in this discussion only used for
overwriting precedence. Eg this works to create an array with just one
element
@a = 3;

I don't have to write
@a = (3);
Show full article (0.89Kb)
3 Comments