SEARCH RESULTS

FAQ

"How do I fetch a news article or the active newsgroups?" in perlfaq9

How do I fetch a news article or the active newsgroups? ... ::NNTPClient->new->list("newsgroups")'

"How do I substitute case insensitively on the LHS while preserving case on the RHS?" in perlfaq6

} else { substr($new, $i, 1) = uc(substr($new, $i, 1)); ... } elsif ($state == 2) { substr($new, $oldlen) = uc(substr($new, $oldlen

"How can I reliably rename a file?" in perlfaq5

) or system("mv", $old, $new); It may be more portable to use the File::Copy module instead. ... You just copy to the new file to the new name (checking return values), then delete the old one.

"How can I split a [character] delimited string except when inside [character]?" in perlfaq4

He suggests (assuming your string is contained in $text): @new = (); push(@new, $+ ... module (part of the standard Perl distribution) lets you say: use Text::ParseWords; @new

"How do I use MIME to make an attachment to a mail message?" in perlfaq9

use MIME::Lite; ### Create a new multipart message: $msg = MIME::Lite->new( ... =>'multipart/mixed' ); ### Add parts (each "attach" has same arguments as "new

"What's the difference between dynamic and lexical (static) scoping? Between local() and my()?" in perlfaq7

local($x) saves away the old value of the global variable $x and assigns a new value for the duration ... my($x) creates a new variable that is only visible in the current subroutine.

"How stable is Perl?" in perlfaq1

Production releases, which incorporate bug fixes and new functionality, are widely tested before release ... invalidate a program written for an earlier version of perl (barring accidental bug fixes and the rare new

"What was Ponie?" in perlfaq1

(contributed by brian d foy) Ponie stands for "Perl On the New Internal Engine", started by Arthur Bergman ... Instead of using the current Perl internals, Ponie aimed to create a new one that would provide a translation

"What's wrong with always quoting "$vars"?" in perlfaq4

Think of it this way: double-quote expansion is used to produce new strings. ... If you get used to writing odd things like these: print "$var"; # BAD $new

"How do I convert between numeric representations/bases/radixes?" in perlfaq4

", -8))); Using the CPAN module Bit::Vector: use Bit::Vector; $vec = Bit::Vector->new_Hex ... dec = oct("33653337357"); Using Bit::Vector: use Bit::Vector; $vec = Bit::Vector->new

"How do I shuffle an array randomly?" in perlfaq4

splice, randomly picking another element to swap the current element with srand; @new ... = (); @old = 1 .. 10; # just a demo while (@old) { push(@new, splice

"Can I use perl to run a telnet or ftp session?" in perlfaq8

handshaking, then the standard dual-process approach will suffice: use IO::Socket; # new ... in 5.004 $handle = IO::Socket::INET->new('www.perl.com:80') or die "can't connect

"How do I change, delete, or insert a line in a file, or append to the beginning of a file?" in perlfaq5

; open my $out, '>', "$file.new" or die "Can't write new file: $!" ... open my $out, '>', "$file.new" or die "Can't write new file: $!"

"How come when I open a file read-write it wipes it out?" in perlfaq5

; To open file for writing, create new file if needed or else truncate old file: open(FH, " ... See also the new perlopentut if you have it (new for 5.6).

"What is variable suicide and how can I prevent it?" in perlfaq7

foobarbarbar Finally foo The $f that has "bar" added to it three times should be a new ... $f my $f should create a new lexical variable each time through the loop.

"How do I make a temporary file name?" in perlfaq5

If you don't have a modern enough Perl installed, use the new_tmpfile class method from the IO::File ... () or die "Unable to make new temporary file: $!"

"How do I modify the shadow password file on a Unix system?" in perlfaq8

To change the file, make a new shadow password file (the format varies from system to system--see passwd

"How do I declare/create a structure?" in perlfaq7

Here's an example: $person = {}; # new anonymous hash $person->{AGE

"How can I copy a file?" in perlfaq5

use File::Copy; copy( $original, $new_copy ) or die "Copy failed: $!"

"How do I edit my .htpasswd and .htgroup files with Perl?" in perlfaq9

Here's an example: use HTTPD::UserAdmin (); HTTPD::UserAdmin ->new(DB => "/foo/.htpasswd

"How do I redefine a builtin function, operator, or method?" in perlfaq7

:-) If you want to override a predefined function, such as open(), then you'll have to import the new

"What are the Perl newsgroups on Usenet? Where do I post questions?" in perlfaq2

While that group may still be found on some news servers, it is unwise to use it, because postings there ... will not appear on news servers which honour the official list of group names.

"Who supports Perl? Who develops it? Why is it free?" in perlfaq1

See perlhist (new as of 5.005) for Perl's milestone releases. ... www.xray.mpe.mpg.de/mailing-lists/perl5-porters/ and http://archive.develooper.com/perl5-porters@perl.org/ or the news

"Where can I get perl-mode for emacs?" in perlfaq3

You are probably using "main::foo" in new Perl code anyway, so this shouldn't be an issue.

"How can I comment out a large block of perl code?" in perlfaq7

You must put a pod directive where the parser is expecting a new statement, not just in the middle of

"What's the difference between calling a function as &foo and foo()?" in perlfaq7

When you call your function as &foo(), then you do get a new @_, but prototyping is still circumvented

"How do I install a module from CPAN?" in perlfaq8

without dynamic loading, then you just need to replace step 3 (make) with make perl and you will get a new

"How can I use Perl's -i option from within a program?" in perlfaq5

all the .c files in the current directory, leaving a backup of the original data from each file in a new

"How do I remove consecutive pairs of characters?" in perlfaq4

my $str = 'Haarlem'; # in the Netherlands $str =~ tr///cs; # Now Harlem, like in New

"How do I automate an HTML form submission?" in perlfaq9

use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = LWP::UserAgent->new(); my

"How do I fetch an HTML file?" in perlfaq9

defined $html or die "Can't fetch HTML from http://www.perl.com/"; $ascii = HTML::FormatText->new

"What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org?" in perlfaq2

There are also many other sub-domains for special topics like learning Perl, Perl news, jobs in Perl,

"Where do I get the include files to do ioctl() or syscall()?" in perlfaq8

MakeMaker for more information (in brief, just use make perl instead of a plain make to rebuild perl with a new

"I put a regular expression into $/ but it didn't work. What's wrong?" in perlfaq6

use File::Stream; my $stream = File::Stream->new( $filehandle,

"How do I find which modules are installed on my system?" in perlfaq3

use ExtUtils::Installed; my $inst = ExtUtils::Installed->new(); my @modules = $inst

"How do I decode a CGI form?" in perlfaq9

use CGI; my $cgi = CGI->new(); my $total = $cgi->param( 'price' ) + $cgi->param( 'shipping

"How can I capture STDERR from an external command?" in perlfaq8

IPC::Open3; use Symbol qw(gensym); use IO::File; local *CATCHOUT = IO::File->new_tmpfile ... ; local *CATCHERR = IO::File->new_tmpfile; my $pid = open3(gensym, ">&CATCHOUT", ">&CATCHERR

"How can I convince others to use Perl?" in perlfaq1

If Perl is new (and thus scary) to them, find something that Perl can do to solve one of their problems

"How do I handle linked lists?" in perlfaq4

to the list this way: my ($head, $tail); $tail = append($head, 1); # grow a new

"How do I send mail?" in perlfaq9

might be able use the CPAN module Mail::Mailer: use Mail::Mailer; $mailer = Mail::Mailer->new

"How can I use a filehandle indirectly?" in perlfaq5

bless-able) $fh = *SOME_FH{IO}; # blessed IO::Handle from *SOME_FH typeglob Or, you can use the new ... use IO::Handle; # 5.004 or higher $fh = IO::Handle->new(); Then use any

"How can I lock a file?" in perlfaq5

For more information on file locking, see also "File Locking" in perlopentut if you have it (new for

"How can I read a single character from a file? From the keyboard?" in perlfaq5

echo, $noecho, $fd_stdin); $fd_stdin = fileno(STDIN); $term = POSIX::Termios->new

"Which version of Perl should I use?" in perlfaq1

If things aren't broken, upgrading perl may break them (or at least issue new warnings).

"How do I pad a string with blanks or pad a number with zeroes?" in perlfaq4

Left and right padding with any character, creating a new string: $padded = $pad_char x ( $pad_len

"How do I permute N elements of a list?" in perlfaq4

d'; my $p_iterator = Algorithm::Permute->new ( \@array ); while (my @perm = $p_iterator

"How do I flush/unbuffer an output filehandle? Why must I do this?" in perlfaq5

my $sock = IO::Socket::INET->new( 'www.example.com:80' ); $sock->autoflush(); You can also

"What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?" in perlfaq2

wide web support; server and daemon utilities; archiving and compression; image manipulation; mail and news

"How do I read just one key without waiting for a return key?" in perlfaq8

$echo, $noecho, $fd_stdin); $fd_stdin = fileno(STDIN); $term = POSIX::Termios->new

"How do I manipulate arrays of bits?" in perlfaq4

. $+[0] * 8; } Or use the CPAN module Bit::Vector: $vector = Bit::Vector->new

"Is there an IDE or Windows Perl Editor?" in perlfaq3

in trying it out, firstly because strictly speaking it is not a vi clone, it is the real vi, or the new