comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
March 2008
motuwethfrsasuw
     12 9
3456789 10
10111213141516 11
17181920212223 12
24252627282930 13
31       14
2008
 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
  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)         


Author: tadmc
Date: Mar 20, 2008 23:17

Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information ...
Show full article (16.63Kb)
no comments
  append to file         


Author: Petr Vileta
Date: Mar 20, 2008 18:11

I have two simple scripts

------- script1.pl--------
#!/usr/bin/perl
use strict;
open O,">> x.txt";
print O "111\n";
sleep 10;
print O "111\n";
close O;
------- script1.pl--------

------- script2.pl--------
#!/usr/bin/perl
use strict;
open O,">> x.txt";
print O "222\n";
sleep 10;
print O "222\n";
close O;
------- script2.pl--------
Show full article (0.81Kb)
3 Comments
  FAQ 7.8 How do I declare/create a structure?         


Author: PerlFAQ Server
Date: Mar 20, 2008 18:03

This is an excerpt from the latest version perlfaq7.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

7.8: How do I declare/create a structure?

In general, you don't "declare" a structure. Just use a (probably
anonymous) hash reference. See perlref and perldsc for details. Here's
an example:

$person = {}; # new anonymous hash
$person->{AGE} = 24; # set field AGE to 24
$person->{NAME} = "Nat"; # set field NAME to "Nat"

If you're looking for something a bit more rigorous, try perltoot.

--------------------------------------------------------------------
Show full article (1.46Kb)
no comments
  generic declaration of variables         


Author: Ela
Date: Mar 20, 2008 17:14

I am declaring the following variables at the beginning:

@usage='cg.pl afile gfile ffile outname gensf genqcf genpf';
die "Usage: @usage\n" if $#ARGV < @usage;

my ($afile, $gfile, $ffile, $outname, $gensf, $genqcf, $genpf);

I have 2 more questions here, the first, instead of copying the @usage to
the my(), how can I better write the codes to avoid typo and work? I will
use exactly the same name indeed and don't know how many more I will add. I
don't like config file because it usually makes program no longer work after
a period of maintenance (config file gets lost etc).
The second question is, how to allow the user input the arguments without
restricting them in a specific order? e.g. gfile ahead of afile...?
I find that some of the arguments are necessary, while some others, such as
flags, may be optional. How can I write it in a better way to check whether
all the necessary arguments are provided instead of fixing $#ARGV < @usage?
9 Comments
  64 Bit integer display         


Author: Deepu
Date: Mar 20, 2008 13:04

Hi All,

Can somebody give some ideas on how to display 64bit integer.

I tried,

#!/usr/bin/perl -w

use bigint;

$test = 0x123456789abcdef;

print "$test \n";

But when i run:

Hexadecimal number > 0xffffffff not portable

Thanks!
2 Comments
  FAQ 7.9 How do I create a module?         


Author: PerlFAQ Server
Date: Mar 20, 2008 12:03

This is an excerpt from the latest version perlfaq7.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

7.9: How do I create a module?

(contributed by brian d foy)

perlmod, perlmodlib, perlmodstyle explain modules in all the gory
details. perlnewmod gives a brief overview of the process along with a
couple of suggestions about style.

If you need to include C code or C library interfaces in your module,
you'll need h2xs. h2xs will create the module distribution structure and
the initial interface files you'll need. perlxs and perlxstut explain
the details.

If you don't need to use C code, other tools such as
ExtUtils::ModuleMaker and Module::Starter, can help you create a
skeleton module distribution.
Show full article (1.83Kb)
no comments
  Strange syntex: beginner         


Author: Nagrik
Date: Mar 20, 2008 09:07

Hello Group,

I am new to learning Perl and am struggling with a syntex encountered
in the code. It looks like

< a.txt b.pl > signature

My question is

what does the first character (<) mean.

What b.pl is doing with a.txt.

I guess the output of the program goes to signature.

BTW: The line I mentioned was in a bash script file.

Can someone help.

Thanks.

nagrik
5 Comments
  get the matching regex pattern         


Author: Ram Prasad
Date: Mar 20, 2008 06:16

I have a somewhat strange requirement
I want to find if a regex matched what exactly matched

to reproduce this

------------------
my @x;
$x[0] = 'chi+ld*';
$x[1] = '\sjoke';

$_=getinput(); # for test assume $_="This is a joke";

if(/($x[0]|$x[1])/){
print "Matched '$1' \n";
}
-----------------

I want to know if $x[0] matched or $x[1] matched
What is the most efficient way of doing this ?

Thanks
Ram
Show full article (0.51Kb)
3 Comments
  FAQ 6.21 What's wrong with using grep in a void context?         


Author: PerlFAQ Server
Date: Mar 20, 2008 06:03

This is an excerpt from the latest version perlfaq6.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

6.21: What's wrong with using grep in a void context?

The problem is that grep builds a return list, regardless of the
context. This means you're making Perl go to the trouble of building a
list that you then just throw away. If the list is large, you waste both
time and space. If your intent is to iterate over the list, then use a
for loop for this purpose.

In perls older than 5.8.1, map suffers from this problem as well. But
since 5.8.1, this has been fixed, and map is context aware - in void
context, no lists are constructed.

--------------------------------------------------------------------
Show full article (1.54Kb)
11 Comments
  better design of spreadsheet generation         


Author: Ela
Date: Mar 20, 2008 04:58

A spreadsheet of *n* fields is to be generated. For debugging purpose,
confidentiality and so on reasons, sometimes some of the fields are not to
be generated.

Using a series of "if" or "?" can solve the problem, but it makes the codes
very clumsy and not generic. Is perl capable of handling this situation?

e.g.

print a header by:

field1 f2 f3 .... fn-1 fn
r11 r12 r13 ... r1n-1 r1n
...

or

field1 f3 .... fn-1
r11 r13 ... r1n-1
...
4 Comments
 
1 2