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
  substitution - variable in variable         


Author: Petr Vileta
Date: Mar 9, 2008 20:15

Please can anybody help me with this substitution? The example is described
well I hope ;-)

#!/usr/bin/perl
use strict;
my $string = 'click';
my $what = 'xxx.cgi'; # in reality readed from database (value is variable)
my $rx1=quotemeta($what);
my $rx2 = '^.+?$rx1\?(.+?)".+$';

# this not work
$string =~ s/$rx2/$1/;
print "$string\n";
# output is:
#click

# this work as expected
$rx2 =~ s/\$rx1/$rx1/; # how write s/// in next line without this line?
$string =~ s/$rx2/$1/;
print "$string\n";
# output is:
#parameter
Show full article (0.79Kb)
3 Comments
  FAQ 5.17 Is there a leak/bug in glob()?         


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

This is an excerpt from the latest version perlfaq5.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 .

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

5.17: Is there a leak/bug in glob()?

Due to the current implementation on some operating systems, when you
use the glob() function or its angle-bracket alias in a scalar context,
you may cause a memory leak and/or unpredictable behavior. It's best
therefore to use glob() only in list context.

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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.
Show full article (1.28Kb)
no comments
  Getting permissions using Win32::TieRegistry         


Author: Cosmic Cruizer
Date: Mar 9, 2008 12:20

I can get most of the registry info I need by using Win32::TieRegistry, but
I cannot figure out how to get the permissions for the keys. Is it possbile
to get the key permissions using TieRegistry? If not, is there a different
way to use Perl to get the registry key permissions?

Thanks
4 Comments
  FAQ 5.16 Why do I sometimes get an "Argument list too long" when I use <*>?         


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

This is an excerpt from the latest version perlfaq5.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 .

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

5.16: Why do I sometimes get an "Argument list too long" when I use <*>?

The "<>" operator performs a globbing operation (see above). In Perl
versions earlier than v5.6.0, the internal glob() operator forks csh(1)
to do the actual glob expansion, but csh can't handle more than 127
items and so gives the error message "Argument list too long". People
who installed tcsh as csh won't have this problem, but their users may
be surprised by it.

To get around this, either upgrade to Perl v5.6.0 or later, do the glob
yourself with readdir() and patterns, or use a module like File::KGlob,
one that doesn't use the shell to do globbing.

--------------------------------------------------------------------
Show full article (1.64Kb)
no comments
  Setting chmod         


Author: John
Date: Mar 9, 2008 09:26

$sec=open(TEKST,">test.txt");
chmod 0600,$sec;
binmode(TEKST);
print TEKST ""hello world";
close TEKST;

Why is the test.txt not chmodded to 0600 but to 0755
20 Comments
  Use of "return" in place of "last" (newbie question)?         


Author: Michael
Date: Mar 9, 2008 07:34

I am new to perl, and I am wondering whether it is a bad thing to jump out
of a foreach loop with return. I have a function which searches for a
value in one of several arrays. If the value is found in any of them,
then the whole function may as well terminate. At the moment I am setting
a flag when the value is found, which stops execution of the later loops.
Would it be safe / stylistically sound to do away with the flag by using
"return" rather than "last". Example code follows.

TIA

sub example{

my $found;
$found = 0;
Show full article (0.83Kb)
12 Comments
  FAQ 5.12 How can I open a filehandle to a string?         


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

This is an excerpt from the latest version perlfaq5.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 .

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

5.12: How can I open a filehandle to a string?

, , ,
(contributed by Peter J. Holzer, hjp-usenet2@hjp.at)

Since Perl 5.8.0, you can pass a reference to a scalar instead of the
filename to create a file handle which you can used to read from or
write to a string:

open(my $fh, '>', \$string) or die "Could not open string for writing";
print $fh "foo\n";
print $fh "bar\n"; # $string now contains "foo\nbar\n"

open(my $fh, '<', \$string) or die "Could not open string for reading";
my $x = <$fh>; # $x now contains "foo\n"

With older versions of Perl, the "IO::String" module provides similar
functionality.
Show full article (1.68Kb)
no comments
  know about the technology of intel procesor...         


Author: waugh682
Date: Mar 9, 2008 05:15

know about the technology of intel procesor...

http://intelsprocessor.googlepages.com
no comments
  Re: Net::SMTP - "Bad File Number" error ?         


Author: Joe Smith
Date: Mar 9, 2008 05:11

still just me wrote:
> I'm using Net::SMTP to send mail from a perl program running on a web
> server. Code is as follows:
>
> my $relay="smtp.example.com";
> my $smtp = Net::SMTP->new($relay);
> die "Could not open connection: $!" if (! defined $smtp);

The docs for Net::SMTP does not say that it sets $!, so don't rely on that.

Have you tried turning on debugging?

$smtp = Net::SMTP->new(
Host => 'smtp.example.com',
Hello => 'my.mail.domain'
Timeout => 30,
Debug => 1,
);
no comments
  printf doesn't do right justify         


Author:
Date: Mar 9, 2008 05:04

I thought that printf would allways right justify numbers, unless told
to do differently (with '-'). perlfunc doesn't tell.

#!perl
use strict;
use warnings;
printf("%%2.1f\n", 12.3);
printf("%%2.1f\n", 4.5);
printf("%%02.1f\n", 6.7);

The results are:
12.3
4.5
6.7

But I expected:
12.3
4.5
06.7

What am I missing?
Show full article (0.46Kb)
1 Comment
 
1 2 3 4 5 6 7 8 9