<< < 27 28 29 30 31 32 33 34 35 36 37 > >>   Sort: Rank

What's the difference between /^Foo/s and /^Foo/?
What's the difference between /^Foo/s and /^Foo/? The second would match Foo other than at the start of the record if $* were set. The deprecated $* flag does double duty, filling the roles of both /s and /m. By using /s, you suppress any settings of that spooky variable, and force your carets and d...
2013-09-12, 2092👍, 0💬

What value is returned by a lone `return;' statement?
What value is returned by a lone `return;' statement? The undefined value in scalar context, and the empty list value () in list context. This way functions that wish to return failure can just use a simple return without worrying about the context in which they were called.
2013-09-11, 2120👍, 0💬

How do you find the length of an array?
How do you find the length of an array? $@array
2013-09-11, 2118👍, 0💬

How to read file into hash array ?
How to read file into hash array ? open(IN, "&lt;name_file") or die "Couldn't open file for processing: $!"; while (&lt;IN&gt;) { chomp; $hash_table{$_} = 0; } close IN; print "$_ = $hash_table{$_}\n" foreach keys %hash_table;
2013-09-10, 2360👍, 0💬

How do I sort a hash by the hash value?
How do I sort a hash by the hash value? Here's a program that prints the contents of the grades hash, sorted numerically by the hash value: #!/usr/bin/perl -w # Help sort a hash by the hash 'value', not the 'key'. to highest). sub hashValueAscendingNum { $grades{$a} &lt;=&gt; $grades{$b}; } ...
2013-09-10, 2330👍, 0💬

What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)
What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.) $cur-&gt;new()-&gt;{LI NK}The indirect object syntax only has a single token lookahead. That means if new() is a method, it only grabs the very next token, not the entire following expression. Thi...
2013-09-09, 2148👍, 0💬

What does read() return at end of file?
What does read() return at end of file? 0 A defined (but false) 0 value is the proper indication of the end of file for read() and sysread().
2013-09-09, 1982👍, 0💬

Why does Perl not have overloaded functions?
Why does Perl not have overloaded functions? Because you can inspect the argument count, return context, and object types all by yourself. In Perl, the number of arguments is trivially available to a function via the scalar sense of @_, the return context via wantarray(), and the types of the argume...
2013-09-06, 2031👍, 0💬

What does `$result = f() .. g()' really return?
What does `$result = f() .. g()' really return? False so long as f() returns false, after which it returns true until g() returns true, and then starts the cycle again. This is scalar not list context, so we have the bistable flip-flop range operator famous in parsing of mail messages, as in `$in_bo...
2013-09-06, 1887👍, 0💬

Why is it hard to call this function: sub y { "because" }
Why is it hard to call this function: sub y { "because" } Because y is a kind of quoting operator. The y/// operator is the sed-savvy synonym for tr///. That means y(3) would be like tr(), which would be looking for a second string, as in tr/a-z/A-Z/, tr(a-z)(A-Z), or tr[a-z][A-Z].
2013-09-05, 1762👍, 0💬

How to read from a pipeline with Perl
How to read from a pipeline with Perl Example 1: To run the date command from a Perl program, and read the output of the command, all you need are a few lines of code like this: open(DATE, "date|"); $theDate = &lt;DATE&gt;; close(DATE); The open() function runs the external date command, the...
2013-09-05, 1853👍, 0💬

How do I send e-mail from a Perl/CGI program on a Unix system?
How do I send e-mail from a Perl/CGI program on a Unix system? Sending e-mail from a Perl/CGI program on a Unix computer system is usually pretty simple. Most Perl programs directly invoke the Unix sendmail program. We'll go through a quick example here. Assuming that you've already have e-mail info...
2013-09-04, 1826👍, 0💬

How do you print out the next line from a filehandle with all its bytes reversed?
How do you print out the next line from a filehandle with all its bytes reversed? print scalar reverse scalar &lt;FH&gt; Surprisingly enough, you have to put both the reverse and the &lt;FH&gt; into scalar context separately for this to work.
2013-09-04, 1965👍, 0💬

How do I sort a hash by the hash key?
How do I sort a hash by the hash key? Suppose we have a class of five students. Their names are kim, al, rocky, chrisy, and jane. Here's a test program that prints the contents of the grades hash, sorted by student name: #!/usr/bin/perl -w %grades = ( kim => 96, al => 63, rocky => 87, chrisy => 96, ...
2013-09-03, 1822👍, 0💬

How do I do &lt; fill-in-the-blank &gt; for each element in a hash?
How do I do &lt; fill-in-the-blank &gt; for each element in a hash? Here's a simple technique to process each element in a hash: #!/usr/bin/perl -w %days = ( 'Sun' =>'Sunday', 'Mon' => 'Monday', 'Tue' => 'Tuesday', 'Wed' => 'Wednesday', 'Thu' => 'Thursday', 'Fri' => 'Friday', 'Sat' => 'Satur...
2013-09-03, 1849👍, 0💬

Ms.
My browser says connection failed & at top of page it says empty page? It won't let me send or receive pictures, or download. Every thing work great for 2nite so it's not my location. I got a few songs blue toothed to my cell and few mins later it refused to go online. I have deleted those blue ...
2013-09-03, 2320👍, 0💬

What does Perl do if you try to exploit the execve(2) race involving setuid scripts?
What does Perl do if you try to exploit the execve(2) race involving setuid scripts? Sends mail to root and exits. It has been said that all programs advance to the point of being able to automatically read mail. While not quite at that point (well, without having a module loaded), Perl does at leas...
2013-09-02, 1854👍, 0💬

Why aren't Perl's patterns regular expressions?
Why aren't Perl's patterns regular expressions? Because Perl patterns have backreferences. A regular expression by definition must be able to determine the next state in the finite automaton without requiring any extra memory to keep around previous state. A pattern /([ab]+)c\1/ requires the state m...
2013-09-02, 1800👍, 0💬

What is the output of the following Perl program?
What is the output of the following Perl program? 1 $p1 = "prog1.java"; 2 $p1 =~ s/(.*)\.java/$1.cpp/; 3 print "$p1\n"; prog1.cpp
2013-08-30, 1847👍, 0💬

I want users send data by formmail but when they send nothing or call it from web site they will see error ....
I want users send data by formmail but when they send nothing or call it from web site they will see error. codes in PHP like this: if (isset($HTTP_POST_VARS)){ .......... } else{ echo ("error lalalalal") } How it will look in perl? In php it will be like if (isset($HTTP_POST_VARS)){ .... } In perl,...
2013-08-30, 1949👍, 0💬

Assuming $_ contains HTML, which of the following substitutions will remove all tags in it?
Assuming $_ contains HTML, which of the following substitutions will remove all tags in it? 1.s/&lt;.*&gt;//g; 2.s/&lt;.*?&gt;//gs; 3.s/&lt;\/?[A-Z]\w*(?:\s+[ A-Z]\w*(?:\s*=\s*(?:(["']).*?\ 1|[\w-.]+))?)*\s*&gt;//gsi x;You can't do that. If it weren't for HTML comments, imprope...
2013-08-29, 1810👍, 0💬

Why should I use the -w argument with my Perl programs?
Why should I use the -w argument with my Perl programs? Many Perl developers use the -w option of the interpreter, especially during the development stages of an application. This warning option turns on many warning messages that can help you understand and debug your applications. To use this opti...
2013-08-28, 1731👍, 0💬

What are scalar data and scalar variables?
What are scalar data and scalar variables? Perl has a flexible concept of data types. Scalar means a single thing, like a number or string. So the Java concept of int, float, double and string equals to Perl's scalar in concept and the numbers and strings are exchangeable. Scalar variable is a Perl ...
2013-08-28, 1813👍, 0💬

How to turn on Perl warnings? Why is that important?
How to turn on Perl warnings? Why is that important? Perl is very forgiving of strange and sometimes wrong code, which can mean hours spent searching for bugs and weird results. Turning on warnings helps uncover common mistakes and strange places and save a lot of debugging time in the long run. The...
2013-08-27, 1886👍, 0💬

<< < 27 28 29 30 31 32 33 34 35 36 37 > >>   Sort: Rank