|
Possible Duplicates:
How can I use a variable’s value as a Perl variable name?
How can I use a variable as a variable name in Perl?
I will show an example of what I need:
@a_1=(1..10); @a_2=(11..20); $index=1; print "@{a_$index}\n";
I need it to print...
Started by guy ergas on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I'd recommend using....
How can I use a variable as a variable name in Perl?
The top answer to that question points to the Perl FAQ: How can I use a variable as a variable name?
Using symbolic references (constructing to go wrong.
To an array.
|
|
How can I find the source location of a print statement in Perl?
#!/usr/bin/perl foo(); bar(); sub foo { print "foo\n"; } sub bar { print "bar\n"; }
The output being:
>perl test.pl foo bar
I'd like to somehow find be able to see (or something like)...
Started by Matthew Watson on
, 9 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
C:\Temp> perl -d:Trace t.pl >> t.pl:10: T::test(); >> T.pm:5: print "in T::test\n"; in T::test >> c:/opt/perl/lib/Config.pm:63, World\n";
Which....
Redirect to a file and then grep for the offending output .
|
|
I'm running a Perl script (both with 5.8.4) on two different machines (one Solaris 5.10, the other OpenSolaris 5.11). The output of the two scripts differs in the following way:
Solaris 5.10
$ perl myscript.pl is' £ ä º <ä ¼ sa ... ³ ä º žÃ ......
Started by ankimal on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
If you could show us the perl -V from each of them, we might be able to give you date from the perl side....
The perls (lowercase perl, I'm talking about the executable here, Perl fans ;) ) could be compiled differently.
|
Ask your Facebook Friends
|
I have a shell script, pretty big one. Now my boss says I must rewrite it in Perl. Is there any way to write a Perl script and use the existing shell code as is in my Perl script. Something similar to Inline::C .
Is there something like Inline::Shell?...
Started by not-exactly-a-unixhater on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want positional columns, you can use:
while(<>) { print substr($_, 5, 10Well…
You could start your "Perl" script with:
#!/bin/bash
Then, assuming bash was installed at that location, perl would automatically....
And only that.
|
|
I'm just curious why one would choose to use an anonymous subroutine, versus a named one, in Perl. Thanks.
Answer Snippets (Read the full thread at stackoverflow):
Is a sub reference $zz=1; sub....
My $thing=sub...
", $i, $doubler->($i), $tripler->($i); } __END__ C:\Temp> v 1 2 3 2 4 6 3 6 9 4 8 12 5 10 15 6 12 18 7 14 21 8 16 24 9 18 27 10 20 30
First: sub thing is a sub.
|
|
What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript?
Answer Snippets (Read the full thread at stackoverflow):
Various operators in Perl are context sensitive and produce different results in list ....
Array: 1 2 4 8 16 first: 1 copy1: 1 2 4 8 16 copy2: 1 2 4 8 16 count: 5
Now:
$first contains 1 i've used has similar concepts.
|
|
You sometimes hear it said about Perl that there might be 6 different ways to approach the same problem. Good Perl developers usually have well-reasoned insights for making choices between the various possible methods of implementation.
So an example ...
Started by keparo on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
File::Find in this case works....
Edit: It could also be 'find.
Days_ago(10) ) ->name( qr/^batch[_-]\d{8}-\d{4}\.run\.txt' from perl code through shell, returning results to an array or hash.
Find::Rule->new ->mtime( '<'.
|
|
How can I do a for() or foreach() loop in Python and Perl, respectively, that only prints every third index? I need to move every third index to a new array.
Answer Snippets (Read the full thread at stackoverflow):
;
@array = qw(1 2 3 4 5 6 7 8 9); print @array[(grep { ($_ + 1) % 3 == 0 } (1..$#array))];
Perl provide a list of elements to slice:
my @every_third = @list[ 2, 5, 8 ]; # returns 3rd, 5th & 9th items ]; # Print it.....
|
|
Perl 6 has really shaped up in terms of which features we can expect to see implemented in the final language, when it comes. Some of them are already available through Perl 6 modules for Perl 5 from CPAN. So which features are most compelling, exciting...
Started by Adam Bellaire on
, 23 posts
by 14 people.
Answer Snippets (Read the full thread at stackoverflow):
I don't thinkNot a feature of Perl 6....
Perl 5's parameter handling is one of its weakest points say it would be very nice to have the // and //= operators even in Perl 5.
Parameter lists.
Typing--is one cool feature.
|
|
What's the best technique for handling US Dollar calculations in Perl?
Especially: the following needs to work:
$balance = 10; $payment = $balance / 3; # Each payment should be 3.33. How best to round amount? $balance -= $payment * 3; # assert: $balance...
Started by Larry K on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Balances = (10, 1, .50, 5, 7, 12, 3, 2, 8, 1012); for my $balance (@balances) { my @stream = get:
C:\Temp> p 10 : 3.33 3.33 3.34 : 10 1 : 0.33 0.33 0.34 : 1 0.5 : 0.16 0.16 0.18 : 0.5 5 : 1.66 for output.....
|