[31289] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2534 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 3 18:09:41 2009

Date: Mon, 3 Aug 2009 15:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 3 Aug 2009     Volume: 11 Number: 2534

Today's topics:
        C api to implement perl storable (freeze) <qwu2008@gmail.com>
    Re: C api to implement perl storable (freeze) <nospam-abuse@ilyaz.org>
    Re: C api to implement perl storable (freeze) <clauskick@hotmail.com>
    Re: FAQ 7.27 How can I comment out a large block of per <kst-u@mib.org>
    Re: FAQ 7.27 How can I comment out a large block of per <uri@stemsystems.com>
        problem with fork <hirenshah.05@gmail.com>
        Problem with procentage character when reading BAT file <wxdeveloper@gmail.com>
    Re: Problem with procentage character when reading BAT  <tadmc@seesig.invalid>
        substitution with computed replacements <fred78980@yahoo.com>
    Re: substitution with computed replacements <tadmc@seesig.invalid>
        T20 champions league schedule <shahzad021@gmail.com>
        the solution to the world's big problems <robin1@cnsp.com>
        Unicode: Strings marked 'utf8'. Can they be converted t sln@netherlands.com
        Using Excel without Macros <ratazong@yahoo.com>
    Re: Using Excel without Macros <tadmc@seesig.invalid>
    Re: Using Excel without Macros <mail@bananas-playground.net>
    Re: Using Excel without Macros <brian.helterline@hp.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 2 Aug 2009 21:10:18 -0700 (PDT)
From: Qiang <qwu2008@gmail.com>
Subject: C api to implement perl storable (freeze)
Message-Id: <06125989-bb44-4539-9b1b-0218f5a35ed8@k13g2000prh.googlegroups.com>

I have a perl client server program to exchange data using perl
Storable module. Now I wanted to convert the server program to c++.
Does anyone know is there a C API to implement something similar to
perl freeze?   Or anyone knows how does perl freeze works in details?

thanks,
Qiang


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

Date: Mon, 3 Aug 2009 05:24:11 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: C api to implement perl storable (freeze)
Message-Id: <slrnh7csll.i5e.nospam-abuse@chorin.math.berkeley.edu>

On 2009-08-03, Qiang <qwu2008@gmail.com> wrote:
> I have a perl client server program to exchange data using perl
> Storable module. Now I wanted to convert the server program to c++.
> Does anyone know is there a C API to implement something similar to
> perl freeze?   Or anyone knows how does perl freeze works in details?

Did you look into Storable.xs?  XS is C.

Hope this helps,
Ilya


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

Date: Mon, 3 Aug 2009 07:21:23 -0700 (PDT)
From: "claus.kick@googlemail.com" <clauskick@hotmail.com>
Subject: Re: C api to implement perl storable (freeze)
Message-Id: <7eab0c7f-d03e-42ba-996d-7c99e688b057@32g2000yqj.googlegroups.com>

On 3 Aug., 06:10, Qiang <qwu2...@gmail.com> wrote:
> I have a perl client server program to exchange data using perl
> Storable module. Now I wanted to convert the server program to c++.
> Does anyone know is there a C API to implement something similar to
> perl freeze? =A0 Or anyone knows how does perl freeze works in details?

If your data is not too difficult to grasp, how about using xml as
exchange format?



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

Date: Sun, 02 Aug 2009 18:52:39 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: FAQ 7.27 How can I comment out a large block of perl code?
Message-Id: <lnzlahpst4.fsf@nuthaus.mib.org>

PerlFAQ Server <brian@stonehenge.com> writes:
> 7.27: How can I comment out a large block of perl code?
>
>     You can use embedded POD to discard it. Enclose the blocks you want to
>     comment out in POD markers. The <=begin> directive marks a section for a
>     specific formatter. Use the "comment" format, which no formatter should
>     claim to understand (by policy). Mark the end of the block with <=end>.
[snip]

IHMO it's also worth mentioning that you can simply insert a '#'
character at the beginning of each line.  This has the advantage
that you can see which lines are commented out without having to
scan for POD directives that might be some distance away.  It's
also easy to do with any decent editor.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


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

Date: Sun, 02 Aug 2009 23:47:33 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FAQ 7.27 How can I comment out a large block of perl code?
Message-Id: <873a89pnhm.fsf@quad.sysarch.com>

>>>>> "KT" == Keith Thompson <kst-u@mib.org> writes:

  KT> PerlFAQ Server <brian@stonehenge.com> writes:
  >> 7.27: How can I comment out a large block of perl code?
  >> 
  >> You can use embedded POD to discard it. Enclose the blocks you want to
  >> comment out in POD markers. The <=begin> directive marks a section for a
  >> specific formatter. Use the "comment" format, which no formatter should
  >> claim to understand (by policy). Mark the end of the block with <=end>.
  KT> [snip]

  KT> IHMO it's also worth mentioning that you can simply insert a '#'
  KT> character at the beginning of each line.  This has the advantage
  KT> that you can see which lines are commented out without having to
  KT> scan for POD directives that might be some distance away.  It's
  KT> also easy to do with any decent editor.

and any decent editor (e.g. emacs :), has an un/comment block of code
feature. cperl mode in emacs has that and it works great. bind it to a
key (i use ^C#) and you can use it to comment and uncomment as desired.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 3 Aug 2009 07:37:38 -0700 (PDT)
From: "friend.05@gmail.com" <hirenshah.05@gmail.com>
Subject: problem with fork
Message-Id: <1bb2c5d7-3197-4e62-b68b-55fe029ea596@32g2000yqj.googlegroups.com>

My scipt is using fork so there are child processes. Sometimes my
script runs properly and output is correct. But sometime my script
gets stuck just after exiting child process. And this does happen
always.

I am not sure why is this happening. Any suggestion or how can I debug
my script.

Below is psudo code. (not sure if this helps, it is juist snap shot)



foreach my $w (keys %worklist) {
	my $child;
	unless ($child = fork()) {
	die("connot for: $!") unless defined $child;

                foreach my $file (@{$worklist{$w}}) {
                          #reading files processing of data and
creating hash tables.
                }

               #ouput files from hash tables. outfile files will be
for each child.

                        print "Worker $w exiting\n";          #child
exiting
(#it gets stuck after printing this statement)

                        exit;
	}
           push(@workers, $child);             #array of child PID
}

#wating for each child to finish.
foreach my $pid (@workers) {
                 $s = waitpid($pid, 0);
	print "$s finished\n";
}



Thanks.


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

Date: Mon, 3 Aug 2009 01:31:27 -0700 (PDT)
From: wxdeveloper <wxdeveloper@gmail.com>
Subject: Problem with procentage character when reading BAT file to perl array
Message-Id: <45b908ac-9db1-4fcb-84cd-c02317af9473@f37g2000yqn.googlegroups.com>

Hello

I want to read a BAT file to some array and then process it line by
line.
The problem is that the BAT file has some DOS variables inside (for
example, %VARIABLE%).

I read the file to an array like this:
@my_array = <FILEHANDLE>

Then I want to process each line

foreach (@my_array)
{
 printf "$_";
}

The problem is that perl somehow assums that %V is a variable and
tries to replace it with a value.
The result is that I get string 0ARIABLE%.
Is there any way to prevent this?

Thank you
J. Grabis




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

Date: Mon, 03 Aug 2009 06:03:49 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Problem with procentage character when reading BAT file to perl array
Message-Id: <slrnh7dgj8.6lo.tadmc@tadmc30.sbcglobal.net>

wxdeveloper <wxdeveloper@gmail.com> wrote:


> I want to read a BAT file to some array and then process it line by
> line.


Stop wanting that.

If you are going to process the data line by line, then read the
data line by line!


> The problem is that the BAT file has some DOS variables inside (for
> example, %VARIABLE%).
>
> I read the file to an array like this:
> @my_array = <FILEHANDLE>
>
> Then I want to process each line
>
> foreach (@my_array)
> {
>  printf "$_";
> }


    while ( <FILEHANDLE> ) {
        print;
    }

See also:

    perldoc -f vars

        What's wrong with always quoting "$vars"?


> The problem is that perl somehow assums that %V is a variable and
> tries to replace it with a value.


No, the problem is that printf() treats % specially.


> Is there any way to prevent this?


Don't use printf!


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 3 Aug 2009 07:57:20 -0700 (PDT)
From: fred <fred78980@yahoo.com>
Subject: substitution with computed replacements
Message-Id: <94bfe988-170c-40f9-8b78-9e3026b85c1d@l31g2000vbp.googlegroups.com>

I took this from Minimal perl by Tim Maher.

s/\d+ /$& * 1.6/ge

I am trying to add numbers instead of converting miles to KM.

input
2 3 4 1
3 4 6

output
2 3 4 1 = 10
2 4 6 = 12

1. What would the replacement part be ?
2. What should the seach part be if we have ten numbers instead of
four?

Thanks


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

Date: Mon, 03 Aug 2009 10:58:27 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: substitution with computed replacements
Message-Id: <slrnh7e1rl.gtb.tadmc@tadmc30.sbcglobal.net>

fred <fred78980@yahoo.com> wrote:
> I took this from Minimal perl by Tim Maher.
>
> s/\d+ /$& * 1.6/ge


That substitutes km for mi.


> I am trying to add numbers instead of converting miles to KM.


If you do not want to substitute then s/// is not the right operator.


> output
> 2 3 4 1 = 10
> 2 4 6 = 12


----------------
#!/usr/bin/perl
use warnings;
use strict;

foreach my $str ( '2 3 4 1', '2 4 6' ) {
    my $sum;
    $sum += $_ for split /\s+/, $str;

    print "$str = $sum\n";
}
----------------


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 2 Aug 2009 22:45:22 -0700 (PDT)
From: shahi <shahzad021@gmail.com>
Subject: T20 champions league schedule
Message-Id: <c9d67788-598f-46fe-a77f-730faa3c914e@f18g2000prf.googlegroups.com>

Dec 3rd =96 Middlesex Crusaders vs Victoria Bushrangers in Mumbai
Dec 4th =96 Sialkot Stallions vs Western Rambal Warriors in Banglore

Dec 4th =96 Chennai Super Kings vs Victoria Bushrangers in Mumbai

for more details visit on
http://shahzad-cricket.blogspot.com/


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

Date: Mon, 3 Aug 2009 12:23:03 -0600
From: "Robin" <robin1@cnsp.com>
Subject: the solution to the world's big problems
Message-Id: <h579u6$drf$1@aioe.org>

The solution to the world's big problem:
http://robin15.001webs.com
http://robin12.001webs.com
http://graphicalcures.001webs.com

-- 
Robin

--
robin1@cnsp.com






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

Date: Mon, 03 Aug 2009 13:35:33 -0700
From: sln@netherlands.com
Subject: Unicode: Strings marked 'utf8'. Can they be converted to 'byte' without going the vec() route?
Message-Id: <i2ie75lqr104toev2cn40n39tthqfsmm4m@4ax.com>

Below is my sample code. This works but if I could just get
a byte string from a *possible* utf8 string with anything simpler
than this, I would be a happy camper.

In the real app, I have no control over how the sample is generated.
Its likely read from PerlIO with whatever encoding layers are applied.
I don't want to have to worry about that, just get it back to a byte
string for analysis.

Thanks alot.
-sln

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

use strict;
use warnings;

my $sample = "unicode->\x{feff}\x{21000}\x{21000}";

print "\nUTF string, length = ".length($sample).", '$sample' :\n  ";
for (map {ord $_} split //, $sample) {
	printf ("%x ",$_);
}
print "\n";

my ($bytes, $offset) = ('',0);
for (map {ord $_} split //, $sample)
{
	my @ar = ();
	while ($_ > 0) {
		push @ar, $_ & 0xff;
		$_ >>= 8;
	}
	for (reverse @ar) {
		vec ($bytes, $offset++, 8) = $_;
	}
}

print "\nByte converted, length = ".length($bytes).", '$bytes' :\n  ";
for (map {ord $_} split //, $bytes) {
	printf ("%02x ",$_);
}
print "\n";

__END__

Wide character in print at btest.pl line 6.

UTF string, length = 12, 'unicode->n++=íÇÇ=íÇÇ' :
  75 6e 69 63 6f 64 65 2d 3e feff 21000 21000

Byte converted, length = 17, 'unicode->¦ ?? ?? ' :
  75 6e 69 63 6f 64 65 2d 3e fe ff 02 10 00 02 10 00




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

Date: Mon, 3 Aug 2009 01:07:38 -0700 (PDT)
From: Henning <ratazong@yahoo.com>
Subject: Using Excel without Macros
Message-Id: <e1734579-bf2d-4787-8b8b-5f35c86dc9dc@k30g2000yqf.googlegroups.com>

Hello!
I have "inherited" the following code:

use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;
$Excel = Win32::OLE->new('Excel.Application', 'Quit');  # get a new
excel
$Book1 = $Excel->Workbooks->Open("$abs_file_name");     # open Excel
file

When opening Excel (line 4) excel tries to start any macros associated
with the file.
Is there a way to avoid this (meaning: force excel to open the file
with disabled macros)?
And how to do so?

Thanks a lot
Henning


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

Date: Mon, 03 Aug 2009 06:05:26 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Using Excel without Macros
Message-Id: <slrnh7dgm9.6lo.tadmc@tadmc30.sbcglobal.net>

Henning <ratazong@yahoo.com> wrote:

> $Book1 = $Excel->Workbooks->Open("$abs_file_name");     # open Excel
                                   ^              ^
                                   ^              ^
    perldoc -q vars

        What's wrong with always quoting "$vars"?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 03 Aug 2009 13:23:54 +0200
From: =?ISO-8859-1?Q?johannes_ke=DFler?= <mail@bananas-playground.net>
Subject: Re: Using Excel without Macros
Message-Id: <h56hcc$nu1$02$1@news.t-online.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Henning wrote:
> Hello!
> I have "inherited" the following code:
> 
> use Win32::OLE::Const 'Microsoft Excel';
> $Win32::OLE::Warn = 3;
> $Excel = Win32::OLE->new('Excel.Application', 'Quit');  # get a new
> excel
> $Book1 = $Excel->Workbooks->Open("$abs_file_name");     # open Excel
> file
> 
> When opening Excel (line 4) excel tries to start any macros associated
> with the file.
> Is there a way to avoid this (meaning: force excel to open the file
> with disabled macros)?
> And how to do so?
> 
> Thanks a lot
> Henning
Hello,

first I think this is a user level problem, which can't be solved at programming
level.
Since the user can set if he want's to run those macros or not.

Then I fond someting in addtion to the standart way to remove macros:

http://www.eng-tips.com/faqs.cfm?fid=48

regards,
johannes keßler
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)

iEYEARECAAYFAkp2yMoACgkQE++2Zdc7EtdztwCff0LlN4DX+07+sQj5vz6Bvxxm
TyoAnRbZ164f+faz/JzRAfyCvlH3xOJ7
=zaSu
-----END PGP SIGNATURE-----


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

Date: Mon, 03 Aug 2009 12:46:30 -0700
From: Brian Helterline <brian.helterline@hp.com>
Subject: Re: Using Excel without Macros
Message-Id: <h57eqn$4u5$1@usenet01.boi.hp.com>

Henning wrote:
> Hello!
> I have "inherited" the following code:
> 
> use Win32::OLE::Const 'Microsoft Excel';
> $Win32::OLE::Warn = 3;
> $Excel = Win32::OLE->new('Excel.Application', 'Quit');  # get a new
> excel
> $Book1 = $Excel->Workbooks->Open("$abs_file_name");     # open Excel
> file
> 
> When opening Excel (line 4) excel tries to start any macros associated
> with the file.
> Is there a way to avoid this (meaning: force excel to open the file
> with disabled macros)?
> And how to do so?
> 
> Thanks a lot
> Henning

for Excel 2007, this is controlled with the AutomationSecurity property 
of the application.  The help gives an example of how to do exactly what 
you are asking (in VB, not perl)

--
-brian


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2534
***************************************


home help back first fref pref prev next nref lref last post