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

uc $new | (uc $1 ^ $1) . ... # finish up with any remaining new (for when new is longer than old) if ($newlen > $oldlen) {

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

) or system("mv", $old, $new); It may be more compelling 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 do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file?" in perlfaq5

; open(NEW, "> $new") or die "can't open $new: $!" ... ; close(NEW) or die "can't close $new: $!"

"How can I split a [character] delimited string except when inside [character]? (Comma-separated files)" in perlfaq4

He suggests (assuming your string is contained in $text): @new = (); push(@new, $+) while ... | , }gx; push(@new, undef) if substr($text,-1,1) eq ','; If you want to represent quotation

"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's wrong with always quoting "$vars"?" in perlfaq4

Think of it this way: double-quote expansion is used to produce new strings. ... Those should (in 99.8% of the cases) be the simpler and more direct: print $var; $new = $old

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

also Usenet gateway to the mailing list used by the crack Perl development team (perl5-porters) at news ... ://news.perl.com/perl.porters-gw/ .

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

Use the new_tmpfile class method from the IO::File module to get a filehandle opened for reading and ... ) or die "Unable to make new temporary file: $!"

"What happens if I add or remove keys from a hash while iterating over it?" in perlfaq4

because that might cause a doubling of the hash table, in which half the entries get copied up to the new ... Even if the table doesn't double, there's no telling whether your new entry will be inserted before or

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

} } T; print "Finally $f\n"; The $f that has "bar" added to it three times should be a new ... $f (my $f should create a new local variable each time through the loop).

"How do I efficiently match many regular expressions at once?" in perlfaq6

As of the 5.005 release, there's a much better approach, one which makes use of the new qr// operator ... : # use spiffy new qr// operator, with /i flag even use 5.005; @popstates = qw(CO ON MI

"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') || die "can't connect to

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

$fh = new FileHandle "+<file"; ## Attach it to a "stream" object. ... use Net::Telnet; $file = new Net::Telnet (-fhopen => $fh); ## Search for the second line and

"How do I cross-reference my Perl programs?" in perlfaq3

The B::Xref module, shipped with the new, alpha-release Perl compiler (not the general distribution prior

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

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

"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, "> $path ... See also the new perlopentut if you have it (new for 5.6).

"Why doesn't open() return an error when a pipe open fails?" in perlfaq8

Because the pipe open takes place in two steps: first Perl calls fork() to start a new process, then ... this new process calls exec() to run the program you really wanted to open.

"How can I open a file with a leading ">" or trailing blanks?" in perlfaq5

; For more information, see also the new perlopentut if you have it (new for 5.6).

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

See perlhist (new as of 5.005) for Perl's milestone releases. ... You may snoop on pending developments via nntp://news.perl.com/perl.porters-gw/ and the Deja archive

"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} = 24

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

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

"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

"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 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

"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 automate an HTML form submission?" in perlfaq9

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

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

use FileHandle; $fh = FileHandle->new(); use IO::Handle; # 5.004 or higher ... $fh = IO::Handle->new(); Then use any of those as you would a normal filehandle.

"How can I convince my sysadmin/supervisor/employees to use version 5/5.005/Perl instead of some other language?" in perlfaq1

Support is usually just a news-posting away, if you can't find the answer in the comprehensive documentation ... In August 2000 in all Linux distributions a new security problem was found in the optional 'suidperl'

"When shouldn't I program in Perl?" in perlfaq1

The new, native-code compiler for Perl may eventually reduce the limitations given in the previous statement

"How do I debug my Perl programs?" in perlfaq3

It's full of gotchas for old and new Perl programmers and even has sections for those of you who are

"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

"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

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

such as http://bugs.perl.org/ http://history.perl.org/ http://lists.perl.org/ http://news.perl.org

"Is Perl difficult to learn?" in perlfaq1

Don't forget the new perl modules, either.

"How do I send mail?" in perlfaq9

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

"How do I handle linked lists?" in perlfaq4

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

"Does Perl have a Year 2000 problem? Is Perl Y2K compliant?" in perlfaq4

See http://language.perl.com/news/y2k.html for a longer exposition.

"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 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

"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

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

"How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles?" in perlfaq5

isn't light-weight: use FileHandle; foreach $filename (@names) { my $fh = FileHandle->new

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

$sock = IO::Socket::INET->new(PeerAddr => 'www.perl.com', PeerPort

"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

"How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?" in perlfaq7

get_rec { my $fh = shift; return scalar <$fh>; } If you're planning on generating 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

init