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
  find a matching pattern in file and find it in another file too         


Author: nani
Date: Mar 12, 2008 22:13

Problem Def: copy the pattern which before ",(comma)" and find a
matching pattern in another file.

status: i wrote following code. but it is not working properly. plz
help me.

#! C:\Perl\bin\perl.exe

print "hello\n";

print "Please Enter Input File name(Give the complete path):";
$infile=; #give the input file name here
chomp($infile);
open ($in, "<", $infile) or die "Cannot open file for reading\n";
#Check whether the file can be opened for reading

while (<$in>)
{
if(/,/) {print "before match: $`\t and after match: $'\n\n";};
$x=$';
$y=$`;
&mysubroutine($x,$y);
}
Show full article (1.08Kb)
2 Comments
  FAQ 5.23 All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?         


Author: PerlFAQ Server
Date: Mar 12, 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.23: All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?

If you are on a system that correctly implements flock() and you use the
example appending code from "perldoc -f flock" everything will be OK
even if the OS you are on doesn't implement append mode correctly (if
such a system exists.) So if you are happy to restrict yourself to OSs
that implement flock() (and that's not really much of a restriction)
then that is what you should do.

If you know you are only going to use a system that does correctly
implement appending (i.e. not Win32) then you can omit the seek() from
the code in the previous answer.
Show full article (2.61Kb)
no comments
  trouble with CPAN using strawberry perl         


Author: dummy
Date: Mar 12, 2008 16:53

After installing strawberry I ran CPAN::FirstTime, allowing the program
to do all the initialization. After a blindingly scrolling screen, on
which I could read nothing, I saw a message telling me to make a
urllist, which I did.

Then I tried this:

--------------- copied from screen ---------------
cpan> install WWW::Mechanize
Database was generated on Tue, 11 Mar 2008 22:35:31 GMT
Updating database file ...
Gathering information from index files...
Show full article (1.98Kb)
no comments
  Fastest way to find a match?         


Author: bukzor
Date: Mar 12, 2008 16:34

Hi,

I'm trying to find the fastest way in perl to see if a name contains
another.

I've a list of 2704 names (aka "A")

I've another name (aka "B")

I need to know if any of A is contained in B.

A = foo foo1 foo2 foo3 foo45 ....
B = INCASE_foo2_YOUWANT
is a match

B = INCASE_YOURDONOTWANT
is not a match.

what would be the fastest way to check the 2704 possible values of
"A" ?

Thanks,

so far, I'm using
Show full article (0.53Kb)
10 Comments
  help with a regex         


Author: donebrowsers
Date: Mar 12, 2008 12:31

I have the following dataset:
zoo-2.10.1p1
mutt-1.4.2.3-compressed
lha-1.14i.ac20050924.1
mysql-server-5.0.45
p5-Archive-Tar-1.30
php5-gd-5.2.3-no_x11

There are package listings on an OpenBSD machine. I want to parse the
package name, the version, and if there is a flavor, that too. I want
the following:
[zoo] [2.10.1p1]
[mutt] [1.4.2.3] [compressed]
[lha] [1.14i.ac20050924.1]
[mysql-server] [5.0.45]
[p5-Archive-Tar] [1.30]
[php5-gd] [5.2.3] [no_x11]

I currently have this regex (which is close but doesn't quite work):
/(^.*)-(.*)($-\w)?/
Show full article (0.85Kb)
16 Comments
  FAQ 5.30 How can I read a single character from a file? From the keyboard?         


Author: PerlFAQ Server
Date: Mar 12, 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.30: How can I read a single character from a file? From the keyboard?

You can use the builtin "getc()" function for most filehandles, but it
won't (easily) work on a terminal device. For STDIN, either use the
Term::ReadKey module from CPAN or use the sample code in "getc" in
perlfunc.

If your system supports the portable operating system programming
interface (POSIX), you can use the following code, which you'll note
turns off echo processing as well.
Show full article (3.22Kb)
no comments
  What is weak references?         


Author: mynews
Date: Mar 12, 2008 08:17

The document
(http://search.cpan.org/~rgarcia/perl-5.9.3/pod/perl593delta.pod#Core_Enhancements)
say that "Weak references are cheaper...".
But what is the weak references?
1 Comment
  FAQ 6.2 I'm having trouble matching over more than one line. What's wrong?         


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

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

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

6.2: I'm having trouble matching over more than one line. What's wrong?

Either you don't have more than one line in the string you're looking at
(probably), or else you aren't using the correct modifier(s) on your
pattern (possibly).

There are many ways to get multiline data into a string. If you want it
to happen automatically while reading input, you'll want to set $/
(probably to '' for paragraphs or "undef" for the whole file) to allow
you to read more than one line at a time.

Read perlre to help you decide which of "/s" and "/m" (or both) you
might want to use: "/s" allows dot to include newline, and "/m" allows
caret and dollar to match next to a newline, not just at the end of the
string. You do need to make sure that you've actually got a multiline
string in there.
Show full article (3.37Kb)
no comments
  FAQ 5.15 How come when I open a file read-write it wipes it out?         


Author: PerlFAQ Server
Date: Mar 12, 2008 00: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.15: How come when I open a file read-write it wipes it out?

Because you're using something like this, which truncates the file and
*then* gives you read-write access:

open(FH, "+> /path/name"); # WRONG (almost always)

Whoops. You should instead use this, which will fail if the file doesn't
exist.

open(FH, "+< /path/name"); # open for update

Using ">" always clobbers or creates. Using "<" never does either. The
"+" doesn't change this.

Here are examples of many kinds of file opens. Those using sysopen() all
assume

use Fcntl;

To open file for reading:
Show full article (3.78Kb)
no comments