|
|
Up |
|
|
  |
Author: MMMM
Date: Feb 13, 2008 20:00
Hi all,
I am trying to write a perl script to do some simple modifications to a text
file. Amongst other things it has to delete a few lines. Here is a relevant
part of my script:
LINE: while ($line = ) {
if ((/END_ADDRESS_SPACE/) && ($count2 < 3)) {
$count2 += 1;
$line = ;
do {
$line = ;
} until ($line == /ADDRESS_SPACE/);
next LINE;
}
print NF $line;
}
The lines that I am trying to skip contain forward slashes and that seems to
confuse the match in the until statement...
END_ADDRESS_SPACE;
|
| Show full article (0.98Kb) |
|
| |
3 Comments |
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: Feb 13, 2008 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.9: Is there a ctags for Perl?
(contributed by brian d foy)
Ctags uses an index to quickly find things in source code, and many
popular editors support ctags for several different languages, including
Perl.
Exuberent ctags supports Perl: http://ctags.sourceforge.net/
You might also try pltags: http://www.mscha.com/pltags.zip
--------------------------------------------------------------------
|
| Show full article (1.33Kb) |
|
| |
no comments
|
|
  |
Author: George AdamsGeorge Adams
Date: Feb 13, 2008 14:25
Hi, all. I'm trying to make a simple backup program for myself that
will check to see if certain files have been modifed before backing them
up. (It's got to be portable to multiple OSes that have Perl, but
possibly not other handy tools like, say, rsync or some such).
Anyway, I had originally planned to use the Windows archive bit, or else
file modification dates to determine if a file had been changed. That
turned out to be unreliable, though (and, in the case of the archive
bit, impossible on Linux). So I decided instead to create a checksum of
the original file, then compare future versions of the file with the
stored checksum to see if it's changed (and hence needs to be backed up).
This works... except it's really, really slow. I started with SHA-1,
but it was taking just too long. I switched to MD5 and then CRC32, but
even that was fairly slow. And when the backup directory contains
several gigs of files to check, it was just too much.
|
| Show full article (1.37Kb) |
|
15 Comments |
|
  |
Author: Swapnajit MitraSwapnajit Mitra
Date: Feb 13, 2008 13:48
Here is the code fragments:
==============================================================
# Parser command
my $parser = new XML::Parser (ErrorContext => 2);
$parser->setHandlers(Start => \&start_handler
, Char => \&char_handler
, End => \&end_handler
, Default => \&default_handler
);
$retVal = $parser->parsefile($file);
...
sub char_handler {
my ($p, $data) = @_;
print "char_handler: data = *$data*\n";
==============================================================
The last print statement always prints '1' with the following input
(even for NAME or VALUE fields). Subroutines for Start or End seem to
work just fine.
|
| Show full article (1.04Kb) |
|
3 Comments |
|
  |
Author: GaryGary
Date: Feb 13, 2008 13:02
Trying to understand what the -> does please.
Cannot find it in the perl docs etc.
Gary
|
| |
|
1 Comment |
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: Feb 13, 2008 12: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
|
|
  |
Author: SergioQSergioQ
Date: Feb 13, 2008 11:00
Hello all,
Am having some very serious problems reading the POST data that is
being sent to my Perl script. The full code (minus my email address
is below). And essentially what I am getting back via email reports
is that that there is data being sent via POST, and tht it has a
length of 1431. Yet all my attempts to read it are failing
miserably. If anyone can help me out, I would soooo appreciate it.
Thank you so much.
Here is the FULL CODE:
#!/usr/bin/perl
use strict;
use MainMod;
use HTTP::Request;
use LWP::UserAgent;
use CGI qw(:standard);
my $out_msg = "";
my %%variable;
my $serg_bffr;
read STDIN, $serg_bffr, $ENV{'CONTENT_LENGTH'};
|
| Show full article (1.14Kb) |
|
7 Comments |
|
  |
Author: Amy LeeAmy Lee
Date: Feb 13, 2008 06:48
Hello,
I'm a sysadmin, I wanna write a small script to show information about
/proc directory. For example, I wanna show the cpuinfo file and just two
items "vendor_id" and "model name".
Here's the file (part):
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 8
model name : Pentium III (Coppermine)
stepping : 10
cpu MHz : 1000.045
..........
I suppose that I should use grep command to do that. However, I don't know
how to accomplish it.
Could you give me some tips?
Thank you very much.
Amy Lee
|
| |
|
9 Comments |
|
  |
Author: Tomasz ChmielewskiTomasz Chmielewski
Date: Feb 13, 2008 06:03
How can I do multiple database modifications without writing too much code?
For a single modification, I would write:
$SQL = "INSERT INTO aaaaa..";
$db->do($SQL);
How can I do it without repeating "$db->do($SQL);" each time?
Something like this throws an error, so obviously I must be missing
something.
$SQL = "INSERT INTO aaaaa... ;
INSERT INTO bbbbb... ;
INSERT INTO bbbbb... ;";
$db->do($SQL);
|
| |
|
5 Comments |
|
  |
|
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: Feb 13, 2008 06: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.22: How can I get "#!perl" to work on [MS-DOS,NT,...]?
For OS/2 just use
extproc perl -S -your_switches
as the first line in "*.cmd" file ("-S" due to a bug in cmd.exe's
"extproc" handling). For DOS one should first invent a corresponding
batch file and codify it in "ALTERNATE_SHEBANG" (see the dosish.h file
in the source distribution for more information).
|
| Show full article (2.54Kb) |
|
no comments
|
|
|
|
|
|
|