comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
September 2007
motuwethfrsasuw
     12 35
3456789 36
10111213141516 37
17181920212223 38
24252627282930 39
2007
 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
  Odd regex behavior         


Author: Mintcake
Date: Sep 30, 2007 20:37

I wouldd be grateful to anyone who can shed some light on the
unexpected
results from the regex in the following program.

#!/usr/local/bin/perl -l

use strict;

my $y = ' href="/foo/bar?d=1&c=2&f=1&cards=1" x="123"';

for ($y =~ /(\s+\w+=['"](.*?)["'])/gs)
{
print "1) $_";
print "2) [$1][$2]";

my $x = /(\w+)=['"](.*)["']/;
print "3) [$x] [$1][$2]";

my $x = /(\w+)=['"](.*)["']/;
print "4) [$x] [$1][$2]";

my $x = /(\w+)=['"](.*)["']/;
print "5) [$x] [$1][$2]";

print "";
}
__END__
Show full article (2.06Kb)
11 Comments
  cheap sell wholesale sandals gucci prada dior chanel fendi louisD&G         


Author: cheapestsell
Date: Sep 30, 2007 19:38

Dear my friend
It is our pleasure to meet you here.
we are ale International Trade Co.,Ltd in Fujian of China.
our website: http://www.cheapest-sell.cn
our email:cheapests...@hotmail.com
We are professional and honest wholesaler of all kinds of brand
sneaks and apparel.the products
our company supply are as follows:
1.jordan1-21shoes
2.airmax(95/97/360/2003/TN...)shoes
3.airforce1(airforce1/bape/dunk...)shoes
4.Shoes(R3/R4/NZ/turbo/t13/monster...)shoes
5.Shoes/Shoes/Shoes/rift/Sports shoes
6.fashion branded hoodies/jeans/caps/handbag/t-shirts and
others
7.because the space of the website is limited,we can also supply many
other products which be not showed out in our site. if you have the
photos of the products you need , we are pleasure to supply for your
orders.
And our company can supply for our customers ,as follow: ...
Show full article (1.77Kb)
no comments
  FAQ 3.26 Where can I learn about object-oriented Perl programming?         


Author: PerlFAQ Server
Date: Sep 30, 2007 18:03

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

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

3.26: Where can I learn about object-oriented Perl programming?

A good place to start is perltoot, and you can use perlobj, perlboot,
perltoot, perltooc, and perlbot for reference.

A good book on OO on Perl is the "Object-Oriented Perl" by Damian Conway
from Manning Publications, or "Intermediate Perl" by Randal Schwartz,
brian d foy, and Tom Phoenix from O'Reilly Media.

--------------------------------------------------------------------
Show full article (1.37Kb)
no comments
  FAQ 4.52 How do I sort an array by (anything)?         


Author: PerlFAQ Server
Date: Sep 30, 2007 12:03

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

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

4.52: How do I sort an array by (anything)?

Supply a comparison function to sort() (described in "sort" in
perlfunc):

@list = sort { $a <=> $b } @list;

The default sort function is cmp, string comparison, which would sort
"(1, 2, 10)" into "(1, 10, 2)". "<=>", used above, is the numerical
comparison operator.

If you have a complicated function needed to pull out the part you want
to sort on, then don't do it inside the sort function. Pull it out
first, because the sort BLOCK can be called many times for the same
element. Here's an example of how to pull out the first word after the
first number on each item, and then sort those words case-insensitively.
Show full article (2.80Kb)
4 Comments
  FAQ 4.66 How can I make my hash remember the order I put elements into it?         


Author: PerlFAQ Server
Date: Sep 30, 2007 06:03

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

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

4.66: How can I make my hash remember the order I put elements into it?

Use the "Tie::IxHash" from CPAN.

use Tie::IxHash;

tie my %%myhash, 'Tie::IxHash';

for (my $i=0; $i<20; $i++) {
$myhash{$i} = 2*$i;
}

my @keys = keys %%myhash;
# @keys = (0,1,2,3,...)

--------------------------------------------------------------------
Show full article (1.34Kb)
no comments
  FAQ 3.21 How can I compile my Perl program into byte code or C?         


Author: PerlFAQ Server
Date: Sep 30, 2007 00:03

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

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

3.21: How can I compile my Perl program into byte code or C?

(contributed by brian d foy)

In general, you can't do this. There are some things that may work for
your situation though. People usually ask this question because they
want to distribute their works without giving away the source code, and
most solutions trade disk space for convenience. You probably won't see
much of a speed increase either, since most solutions simply bundle a
Perl interpreter in the final product (but see "How can I make my Perl
program run faster?").

The Perl Archive Toolkit ( http://par.perl.org/ ) is Perl's analog to
Java's JAR. It's freely available and on CPAN (
http://search.cpan.org/dist/PAR/ ).
Show full article (2.21Kb)
no comments
  in what array do all the $1,$2,... live?         


Author: jidanni
Date: Sep 29, 2007 19:03

What is the name of the array where all the $1,$2,... live?
Or do I really need to gather them up manually:
@all_the_matches=($1,$2,$3,$4,$5,...);
man perlvar doesn't mention it.
3 Comments
  FAQ 4.31 How can I split a [character] delimited string except when inside [character]?         


Author: PerlFAQ Server
Date: Sep 29, 2007 18:03

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

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

4.31: How can I split a [character] delimited string except when inside [character]?

Several modules can handle this sort of parsing--"Text::Balanced",
"Text::CSV", "Text::CSV_XS", and "Text::ParseWords", among others.

Take the example case of trying to split a string that is
comma-separated into its different fields. You can't use "split(/,/)"
because you shouldn't split if the comma is inside quotes. For example,
take a data line like this:

SAR001,"","Cimetrix, Inc","Bob Smith","CAM",N,8,1,0,7,"Error, Core Dumped"

Due to the restriction of the quotes, this is a fairly complex problem.
Thankfully, we have Jeffrey Friedl, author of *Mastering Regular
Expressions*, to handle these for us. He suggests (assuming your string
is contained in $text):
Show full article (2.42Kb)
no comments
  Perl/unix script to convert a fixed width file to a tab delimited file         


Author: Srikant
Date: Sep 29, 2007 06:35

Hi all,
I have a situtation here. We have a script that reads two
delimited (comma or tab or pipe or semicolon or any other) files and
compares them returnig the list of records/rows unique to file1,
unique to file2 and the mismatches records.
Now, we also have to get this going for fixed width files. I
know that the inbuilt excel tool, Text to columns, does this. However
we need to get this process automated on the unix box.
Any suggestions? If someone can help me with the scipt itself,
that'll be awesome.

Thanks a lot.

Regards
Srikant
3 Comments
  FAQ 4.3 Why isn't my octal data interpreted correctly?         


Author: PerlFAQ Server
Date: Sep 29, 2007 06:03

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

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

4.3: Why isn't my octal data interpreted correctly?

Perl only understands octal and hex numbers as such when they occur as
literals in your program. Octal literals in perl must start with a
leading 0 and hexadecimal literals must start with a leading "0x". If
they are read in from somewhere and assigned, no automatic conversion
takes place. You must explicitly use "oct()" or "hex()" if you want the
values converted to decimal. "oct()" interprets hexadecimal (0x350),
octal (0350 or even without the leading 0, like 377) and binary
("0b1010") numbers, while "hex()" only converts hexadecimal ones, with
or without a leading "0x", such as 0x255, "3A", "ff", or "deadbeef". The
inverse mapping from decimal to octal can be done with either the <%%o>
or %%O "sprintf()" formats.
Show full article (2.56Kb)
no comments
1 2 3 4 5 6 7 8 9