Is there a way to obtain the C++ equivalent of Perl's PREMATCH ($`) and POSTMATCH ($') from pcrecpp? I would be happy with a string, a char *, or pairs indices/startpos+length that point at this.
StringPiece seems like it might accomplish part of this, but I'm not certain how to get it.
in perl:
$_ = "Hello world";
if (/lo\s/) {
$...
I need to create Perl code which allows counting paragraphs in text files. I tried this and doesn't work:
open(READFILE, "<$filename")
or die "could not open file \"$filename\":$!";
$paragraphs = 0;
my($c);
while($c = getc(READFILE))
{
if($C ne"\n")
{
$paragraphs++;
}
}
close(READFILE);
print("Paragraphs: $paragraphs\n");
...
I have a ksh script that calls a Perl program. The Perl program creates some important data that the ksh script needs to act on. Example:
My ksh program:
#!/usr/bin/ksh
abc.pl > $logFile
# perl pgm creates variable $importantData See below.
# HOW DO I GET THE .KSH SCRIPT TO SEE $importantData ???
def.ksh $importantData # send impo...
Hello, I want to perform an HTTP redirect, but the way I am currently doing it isn't working. When I try redirect it just prints the status code, and the location header:
my $q = new CGI;
q->redirect(" http://www.google.com ");
...
Hello, is there a way to get with printf colored output?
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
printf "%4.4s\n", colored( '0123456789', 'magenta' );
Output: (only newline)
...
I want to convert a code from perl to c++, and my problem is multi key map in perl!
example:
perl:
$address{name}{familyName} = $someAddress;
and keys are not unique.
I want similar data structure in c++ using map or ...!?
also I want to search and obtain values with first key for example I want such %keys{name} in c++ .
edited: I ...
I hope this is something straightforward that I'm doing wrong. I saw something online about "variable suicide" that looked good, but it was for an older version and I'm on 5.10.1.
Anyway - a variable that I declared - $RootDirectory - just suddenly loses its value, and I can't figure out why.
Here's a script to reproduce the problem....
Using the example code included in the man page for DateTime::Astro::Sunrise, I'm getting back ~14:00 for the sunrise and ~2:00 for the sunset.
My machine's time and timezone are set correctly (AFAIK).
Am I reading something wrong? 2am and 2pm are just so brutually wrong.
use DateTime;
use DateTime::Astro::Sunrise;
my $dt = DateTime-...
I was wondering if it was possible to read a text file that was located in a directory called
"/home/user/files"
I wanted to read it from my cgi-bin which is located in /home/user/cgi-bi/
Below is my code,
#!/usr/bin/perl
use strict;
use CGI;
#Virtual Directory
#Steffan Harris
eval
{
use constant PASSWORD => 'perl';
use constant U...
Hi,
I have a Perl script running in mod_perl that needs to write a large amount of data to the client, possibly over a long period. The behavior that I observe is that once I print and flush something, the buffer memory is not reclaimed even though I rflush (I know this can't be reclaimed back by the OS).
Is that how mod_perl operates...
I just want to transfer (send or receive) a hash from client to server.
Can you tell me which is a preferable way in Perl or can you suggest any CPAN modules?
...
What is the best and useful debug tool in Linux environment for Perl and C++ scripts?
In related to that, does anyone know the differences between Eclipse to DDD tools?
Thank you,
YoDar.
...
I have a Perl script that launches 2 threads,one for each processor. I need it to wait for a thread to end, if one thread ends a new one is spawned. It seems that the join method blocks the rest of the program, therefore the second thread can't end until everything the first thread does is done which sort of defeats its purpose.
I tried...
I need suggestions on how can I download attachments from my IMAP mails which have attachments and current date in subject line i.e. YYYYMMDD format and save the attachments to a local path.
I went through the Perl module Mail::IMAPClient and am able to connect to the IMAP mail server, but need help on other tasks. One more thing to no...
I am parsing command line options in Perl using Getopt::Long. I am forced to use prefix - (one dash) for short commands (-s) and -- (double dash) for long commands (e.g., --input=file).
My problem is that there is one special option (-r=<pattern>) so it is long option for its requirement for argument, but it has to have one dash (-) pre...
I want to do permutation in Perl. For example I have three arrays: ["big", "tiny", "small"] and then I have ["red", "yellow", "green"] and also ["apple", "pear", "banana"].
How do I get:
["big", "red", "apple"]
["big", "red", "pear"]
..etc..
["small", "green", "banana"]
I understand this is called permutation. But I am not sure how ...
When I try to run my Perl CGI program, the returned web page tells me:
Software error: For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.
Here is my code in one of the file:
#!/usr/bin/perl
use lib "/home/ecoopr/ecoopr.com/CPAN";
use CGI;
use CGI::FormBuil...
if($title =~ s/(\s|^|,|\/|;|\|)$replace(\s|$|,|\/|;|\|)//ig)
$title can be a set of titles ranging from President, MD, COO, CEO,...
$replace can be (shareholder), (Owner) or the like.
I keep getting this error. I have checked for improperly balanced '(', ')', no dice :(
Unmatched ) in regex; marked by <-- HERE in m/(\s|^|,|/|;|\|)Ow...
Are there good example codes of implementations of factor graph sum-product scheduling? I am new to the concept, and would like to see how it gets implemented.
...
I'm seeking a solution to splitting a string which contains text in the following format:
"abcd efgh 'ijklm no pqrs' tuv"
which will produce the following results:
['abcd', 'efgh', 'ijklm no pqrs', 'tuv']
In other words, it splits by whitespace unless inside of a single quoted string. I think it could be done with .NET regexps usi...