[23551] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5759 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 6 18:05:58 2003

Date: Thu, 6 Nov 2003 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 6 Nov 2003     Volume: 10 Number: 5759

Today's topics:
        bit sequence match <edady2002@yahoo.com>
    Re: Bug in 5.8.0? . op is very slow <asu1@c-o-r-n-e-l-l.edu>
    Re: Bug in 5.8.0? . op is very slow <thepoet_nospam@arcor.de>
    Re: Bug in 5.8.0? . op is very slow <matthias_weckman@hotmail.com>
    Re: Bug in 5.8.0? . op is very slow <kalinaubears@iinet.net.au>
    Re: Bug in 5.8.0? . op is very slow <kalinaubears@iinet.net.au>
    Re: Bug in 5.8.0?. op is very slow Default@User.net
    Re: Bug in 5.8.0?. op is very slow <mgjv@tradingpost.com.au>
    Re: Converting a list join to a scaler/string <footnipple@indiatimes.com>
    Re: Converting a list join to a scaler/string (Anno Siegel)
    Re: Converting a list join to a scaler/string <footnipple@indiatimes.com>
    Re: Converting a list join to a scaler/string <glex_nospam@qwest.invalid>
    Re: Converting a list join to a scaler/string <footnipple@indiatimes.com>
        DBD::Oracle docs? <ggershSNACK@CAKEctc.net>
    Re: embedding perl within perl.... (James Richardson)
    Re: equivalent perl for sed command ..newbie question <xx087@freenet.carleton.ca>
    Re: equivalent perl for sed command ..newbie question <usenet@morrow.me.uk>
    Re: Execute JavaScript from within Perl (Malcolm Dew-Jones)
        how to access a (global) variable across files (Newbie)
    Re: how to access a (global) variable across files <noreply@gunnar.cc>
    Re: how to access a (global) variable across files <usenet@morrow.me.uk>
    Re: how to access a (global) variable across files <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Nov 2003 08:33:05 +1100
From: Edo <edady2002@yahoo.com>
Subject: bit sequence match
Message-Id: <3FAABE11.1040009@yahoo.com>

Hello

my @a1 = qw (1 000001 2 000010 3 000100);
my @a2 = qw (1 110001 2 110011 3 000001 4 000010 5 000100 6 111000 7 
111110 8 000000 9 111111 10 111011);

my (%h1, %h2) = (@a1, @a2); #convert array to hash

after sorting keys in both hashes, I need to seach %h2 for the sequence 
of keys which match a sorted-key %h1. e.g. seach the %h2 for 000001 
followed by 00010 followed by 000100. once found place the results in 
another %h3 which is then a hoh with the first result taking the number 
1 and the second result 2 ... in that new %h3.

any hint of directions.

thanks alot







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

Date: 6 Nov 2003 14:23:19 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <Xns942B5F823E373asu1cornelledu@132.236.56.8>

Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote in
news:bodgen$bvj$1@south.jnrs.ja.net: 


> I can confirm this on my Win32 boxes.
> 
> 5.8.0 (AS Build 806) 23 wallclock secs
> 5.6.1 (AS Build 635)  1 wallclock sec

Just FYI: I can't.

System: 1 Ghz Celeron w 512 Mb RAM Win XP Pro Sp 1
AS perl v.5.8.0 build 806

Result:

10 loops of concat took: 2 wallclock secs ( 1.76 usr +  0.01 sys =  1.77 
CPU) @ 5.64/s (n=10)

Sinan
-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Thu, 6 Nov 2003 16:31:49 +0100
From: "Christian Winter" <thepoet_nospam@arcor.de>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <3faa6966$0$24770$9b4e6d93@newsread2.arcor-online.net>

"Simon Andrews" <simon.andrews@bbsrc.ac.uk> wrote:
> I can confirm this on my Win32 boxes.
> 
> 5.8.0 (AS Build 806) 23 wallclock secs
> 5.6.1 (AS Build 635)  1 wallclock sec
>

I can reproduce this only on our W2K Servers,
ServicePack 3. No Problem on W2K Prof SP4.
So maybe it depends on ServicePack or Prof/Server
versions? Don't have any SP3 Workstations or
SP4 Servers here to test at the moment, so I
can't investigate this any further.

Cheers
-Chris



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

Date: Thu, 06 Nov 2003 22:02:44 +0100
From: Matthias Weckman <matthias_weckman@hotmail.com>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <3faab6f1$0$142$e4fe514c@dreader7.news.xs4all.nl>

Christian Winter wrote:

> "Simon Andrews" <simon.andrews@bbsrc.ac.uk> wrote:
> 
>>I can confirm this on my Win32 boxes.
>>
>>5.8.0 (AS Build 806) 23 wallclock secs
>>5.6.1 (AS Build 635)  1 wallclock sec
>>
> 
> 
> I can reproduce this only on our W2K Servers,
> ServicePack 3. No Problem on W2K Prof SP4.
> So maybe it depends on ServicePack or Prof/Server
> versions? Don't have any SP3 Workstations or
> SP4 Servers here to test at the moment, so I
> can't investigate this any further.

Well, I've tried it on some other machines as well, and didn't see the 
effect on W2K Server SP3 or SP4, nor on W2003 Server.

Very strange.

Anyway, thank you for your input! Glad to see it isn't just me, and 
sorry to see that this really is an issue.

Does anyone know how I would go about finding info in the various bug 
databases? Searching Activestate's one on 'memory' didn't show me 
anything relevant (I think).
Would it make sense to file a bug report?


> Cheers
> -Chris
> 

Matthias


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

Date: Fri, 07 Nov 2003 09:09:37 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <3faac761$0$1748$5a62ac22@freenews.iinet.net.au>

A. Sinan Unur wrote:
> Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote in
> news:bodgen$bvj$1@south.jnrs.ja.net: 
> 
> 
> 
>>I can confirm this on my Win32 boxes.
>>
>>5.8.0 (AS Build 806) 23 wallclock secs
>>5.6.1 (AS Build 635)  1 wallclock sec
> 
> 
> Just FYI: I can't.
> 
> System: 1 Ghz Celeron w 512 Mb RAM Win XP Pro Sp 1
> AS perl v.5.8.0 build 806
> 
> Result:
> 
> 10 loops of concat took: 2 wallclock secs ( 1.76 usr +  0.01 sys =  1.77 
> CPU) @ 5.64/s (n=10)
> 
> Sinan

That's still pretty slow compared to my 1 Ghz Pentium with 5.6.1 which 
takes 0.8 seconds .... still, it's a big improvement on 23 seconds :-)

Perhaps there's something in the later 2k service packs that makes the 
situation worse.

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: Fri, 07 Nov 2003 09:18:43 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Bug in 5.8.0? . op is very slow
Message-Id: <3faac982$0$1748$5a62ac22@freenews.iinet.net.au>

Matthias Weckman wrote:
> Christian Winter wrote:
> 
>> "Simon Andrews" <simon.andrews@bbsrc.ac.uk> wrote:
>>
>>> I can confirm this on my Win32 boxes.
>>>
>>> 5.8.0 (AS Build 806) 23 wallclock secs
>>> 5.6.1 (AS Build 635)  1 wallclock sec
>>>
>>
>>
>> I can reproduce this only on our W2K Servers,
>> ServicePack 3. No Problem on W2K Prof SP4.
>> So maybe it depends on ServicePack or Prof/Server
>> versions? Don't have any SP3 Workstations or
>> SP4 Servers here to test at the moment, so I
>> can't investigate this any further.
> 
> 
> Well, I've tried it on some other machines as well, and didn't see the 
> effect on W2K Server SP3 or SP4, nor on W2003 Server.
> 
> Very strange.
> 
> Anyway, thank you for your input! Glad to see it isn't just me, and 
> sorry to see that this really is an issue.
> 
> Does anyone know how I would go about finding info in the various bug 
> databases? Searching Activestate's one on 'memory' didn't show me 
> anything relevant (I think).
> Would it make sense to file a bug report?
> 

Maybe raise it first on ActiveState's 'perl-win32-users' mailing list. 
Jan Dubois could likely provide some relevant input - AS might even 
already know about it. Mark the post 'ATTN: Jan' or something like that 
to make sure he sees it.

Cheers,
Rob


-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: Thu, 06 Nov 2003 17:06:13 GMT
From: Default@User.net
Subject: Re: Bug in 5.8.0?. op is very slow
Message-Id: <9cvqb.43$y95.11@nwrdny01.gnilink.net>

Im ran that script on a W2K server with sp4 installed.
ROFL its mad slow Hahahaha.  Very high cpu usage.

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>cd perl

C:\Perl>test
10 loops of concat took:151 wallclock secs (82.93 usr + 56.19 sys = 139.12 CPU)
@  0.07/s (n=10)

C:\Perl>tlist 968
 968 perl.exe
   CWD:     C:\PERL\
   CmdLine: "C:\Perl\bin\perl.exe" "C:\PERL\test.plx"
   VirtualSize:    37048 KB   PeakVirtualSize:    37984 KB
   WorkingSetSize:  7060 KB   PeakWorkingSetSize:  8888 KB
   NumberOfThreads: 1
    592 Win32StartAddr:0x00401016 LastErr:0x00000000 State:Ready
      5.8.0.806 shp  0x00400000  perl.exe
  5.0.2195.6685 shp  0x77f80000  ntdll.dll
     6.1.9844.0 shp  0x78000000  MSVCRT.dll
  5.0.2195.6688 shp  0x7c4e0000  KERNEL32.dll
      5.8.0.806 shp  0x28000000  perl58.dll
  5.0.2195.6688 shp  0x77e10000  USER32.dll
  5.0.2195.6660 shp  0x77f40000  GDI32.DLL
  5.0.2195.6710 shp  0x7c2d0000  ADVAPI32.dll
  5.0.2195.6802 shp  0x77d30000  RPCRT4.DLL


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

Date: 06 Nov 2003 21:45:18 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Bug in 5.8.0?. op is very slow
Message-Id: <slrnbqlg7f.5ah.mgjv@verbruggen.comdyn.com.au>

On Thu, 06 Nov 2003 17:06:13 GMT,
	Default@User.net <Default@User.net> wrote:

Do you work for the people who own the user.net domain, or do you have
their permission to use an email address there? If not, and you
intended to provide a "fake" email address, you should use an invalid
domain name. Note that in some jurisdictions it is an offense to use
someone else's domain name in an email address without permission.

> Im ran that script on a W2K server with sp4 installed.
> ROFL its mad slow Hahahaha.  Very high cpu usage.

Why is that funny to the point that you feel you need to roll around
on the floor?

Martien
-- 
                        | 
Martien Verbruggen      | Never hire a poor lawyer. Never buy from a
Trading Post Australia  | rich salesperson.
                        | 


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

Date: Thu, 06 Nov 2003 14:05:35 GMT
From: "sdfgsd" <footnipple@indiatimes.com>
Subject: Re: Converting a list join to a scaler/string
Message-Id: <Pysqb.173327$ox6.2415355@twister.tampabay.rr.com>


"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnbqjlkk.79p.sholden@flexal.cs.usyd.edu.au...
> On Thu, 06 Nov 2003 04:23:29 GMT, sdfgsd <footnipple@indiatimes.com>
wrote:
> >
> > The end goal is to build an SQL INSERT:
> >
> > my @fields = qw(Name Address City State Zip Phone);
> > my @quoted = map {"'$_', "} @fields;
> > my $insert = join ' ', @quoted;
> >
> > The problem is that I need $insert to be an actual string so that I can
> > concatenate it with a set of parenthesis and the rest of the INSERT. I
then
> > need to push these INSERTS into a file for later use.
> >
> > The expected output if I were to print $insert:   ('name', 'address',
 ...)
>
> And that's what you'll get (well you want get the parenthesis and you'll
> have a trailing comma - which can be fixed by moving the comma to the
> join.
>
> Tack:
> print "$insert\n";
> after those four lines of code and you'll get:
>
> 'Name',  'Address',  'City',  'State',  'Zip',  'Phone',
>
> I can't see how that is not an "actual string".
>
> As I said in my first reply:
>
> What result do you want?

I want to strip the trailing comma and to be able to add to the string.

Given:
$mystring = "Hello there,";
$mystring =~ s/.$//s;
print $mystring;    #Hello there  <- No comma

my @fields = qw(Name Address City State Zip Phone);
my @quoted = map {"'$_', "} @fields;
my $insert = join ' ', @quoted;     # This line does leave a trailing comma
$insert =~ s/.$//s;
print $insert;     # 'Name', 'Address', 'City', 'State', 'Zip', 'Phone',  <-
comma remains!

This leads me to believe that $insert is "not really a string".

> What result did you get?

The comma could not be stripped from the string produced by the join

> --
> Sam Holden
>

Thanks everyone for the responses.




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

Date: 6 Nov 2003 14:15:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Converting a list join to a scaler/string
Message-Id: <bodl1l$n2$1@mamenchi.zrz.TU-Berlin.DE>

sdfgsd <footnipple@indiatimes.com> wrote in comp.lang.perl.misc:
> 
> "Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
> news:slrnbqjlkk.79p.sholden@flexal.cs.usyd.edu.au...
> > On Thu, 06 Nov 2003 04:23:29 GMT, sdfgsd <footnipple@indiatimes.com>
> wrote:
> > >
> > > The end goal is to build an SQL INSERT:
> > >
> > > my @fields = qw(Name Address City State Zip Phone);
> > > my @quoted = map {"'$_', "} @fields;
> > > my $insert = join ' ', @quoted;
> > >
> > > The problem is that I need $insert to be an actual string so that I can
> > > concatenate it with a set of parenthesis and the rest of the INSERT. I
> then
> > > need to push these INSERTS into a file for later use.
> > >
> > > The expected output if I were to print $insert:   ('name', 'address',
> ...)
> >
> > And that's what you'll get (well you want get the parenthesis and you'll
> > have a trailing comma - which can be fixed by moving the comma to the
> > join.
> >
> > Tack:
> > print "$insert\n";
> > after those four lines of code and you'll get:
> >
> > 'Name',  'Address',  'City',  'State',  'Zip',  'Phone',
> >
> > I can't see how that is not an "actual string".
> >
> > As I said in my first reply:
> >
> > What result do you want?
> 
> I want to strip the trailing comma and to be able to add to the string.
> 
> Given:
> $mystring = "Hello there,";
> $mystring =~ s/.$//s;
> print $mystring;    #Hello there  <- No comma
> 
> my @fields = qw(Name Address City State Zip Phone);
> my @quoted = map {"'$_', "} @fields;
> my $insert = join ' ', @quoted;     # This line does leave a trailing comma
> $insert =~ s/.$//s;
> print $insert;     # 'Name', 'Address', 'City', 'State', 'Zip', 'Phone',  <-
> comma remains!
> 
> This leads me to believe that $insert is "not really a string".
> 
> > What result did you get?
> 
> The comma could not be stripped from the string produced by the join

Of course not.  Remember how you built the string?  The parts were

    my @quoted = map {"'$_', "} @fields;

These all end with a comma *and a blank*, and so does the joined string
you build from them.  No mystery at all.

Anno


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

Date: Thu, 06 Nov 2003 14:25:00 GMT
From: "sdfgsd" <footnipple@indiatimes.com>
Subject: Re: Converting a list join to a scaler/string
Message-Id: <0Rsqb.173492$ox6.2417627@twister.tampabay.rr.com>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:bodl1l$n2$1@mamenchi.zrz.TU-Berlin.DE...
> sdfgsd <footnipple@indiatimes.com> wrote in comp.lang.perl.misc:

<snip>

> > The comma could not be stripped from the string produced by the join
>
> Of course not.  Remember how you built the string?  The parts were
>
>     my @quoted = map {"'$_', "} @fields;
>
> These all end with a comma *and a blank*, and so does the joined string
> you build from them.  No mystery at all.
>
> Anno
>

OH Jeez!! Thanks.




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

Date: Thu, 06 Nov 2003 10:34:45 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Converting a list join to a scaler/string
Message-Id: <uHuqb.1206$2B6.18819@news.uswest.net>

sdfgsd wrote:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:bodl1l$n2$1@mamenchi.zrz.TU-Berlin.DE...
> 
>>sdfgsd <footnipple@indiatimes.com> wrote in comp.lang.perl.misc:
> 
> 
> <snip>
> 
>>>The comma could not be stripped from the string produced by the join
>>
>>Of course not.  Remember how you built the string?  The parts were
>>
>>    my @quoted = map {"'$_', "} @fields;
>>
>>These all end with a comma *and a blank*, and so does the joined string
>>you build from them.  No mystery at all.
>>
>>Anno
>>
> 
> 
> OH Jeez!! Thanks.

Now that you've stated you're trying to build SQL, there are better ways 
to do what you want.  Read a few of the many articles at:

http://www.perl.com/search/index.ncsp?sp-q=dbi&submit=Search

For instance:

http://www.perl.com/pub/a/2001/03/dbiokay.html

my $fields = join(', ', @fields);
my $values = join(', ', map { $dbh->quote($_) } @formdata{@fields});
my $sql = "INSERT into $table ($fields) values ($values)";

Can also use placeholders, and not have to worry about calling quote 
directly, to make things even nicer. That's also covered in that article.



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

Date: Thu, 06 Nov 2003 16:38:10 GMT
From: "sdfgsd" <footnipple@indiatimes.com>
Subject: Re: Converting a list join to a scaler/string
Message-Id: <SNuqb.174669$ox6.2425886@twister.tampabay.rr.com>


"J. Gleixner" <glex_nospam@qwest.invalid> wrote in message
news:uHuqb.1206$2B6.18819@news.uswest.net...
> sdfgsd wrote:

<snip>

> Now that you've stated you're trying to build SQL, there are better ways
> to do what you want.  Read a few of the many articles at:
>
> http://www.perl.com/search/index.ncsp?sp-q=dbi&submit=Search
>
> For instance:
>
> http://www.perl.com/pub/a/2001/03/dbiokay.html
>
> my $fields = join(', ', @fields);
> my $values = join(', ', map { $dbh->quote($_) } @formdata{@fields});
> my $sql = "INSERT into $table ($fields) values ($values)";

Wow. This is a lot easier. Thanks

> Can also use placeholders, and not have to worry about calling quote
> directly, to make things even nicer. That's also covered in that article.
>
>




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

Date: Thu, 06 Nov 2003 15:53:44 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: DBD::Oracle docs?
Message-Id: <IqWdnbnWz_1qKTeiRVn-iQ@ctc.net>


I'm looking for some documentation on DBD::Oracle, specifically for the 
  dbms_msgpipe_* functions.  They don't seem to be included.  I've got 
some legacy in-house OraclePipe functions, but I'd rather use the 
CPAN-available code if possible.

-Greg G



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

Date: 6 Nov 2003 09:53:52 -0800
From: james@time4tea.demon.co.uk (James Richardson)
Subject: Re: embedding perl within perl....
Message-Id: <274f94c.0311060953.58973913@posting.google.com>

> 
> how do i do this? can this be done from C++? what are the function calls to be 
> used to get hold of the primary perl interpreter?
> 
> thanks,
> suraj

How to call a static function ( at least used to be! )

     static const char *my_function = "My::Package::function";
     SV* retval;
     SV* param1, param2, param3;
     int count = 0;

     dSP;
     PUSHMARK(SP);
     XPUSHs ( param1 );
     XPUSHs ( param2 );
     XPUSHs ( param3 );
     PUTBACK;
     count = call_pv ( my_function , G_SCALAR );
     SPAGAIN;

     if ( count != 1 ) {
         croak ("Called %s, expected 1 return value, got %d\n",
my_function, count );
     }

     retval = POPs;
     PUTBACK;




Hope thats of use!

James


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

Date: 6 Nov 2003 15:06:20 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: equivalent perl for sed command ..newbie question
Message-Id: <slrnbqkosk.k2o.xx087@smeagol.ncf.ca>

Ben Morrow <usenet@morrow.me.uk> wrote:
>  arena318@yahoo.com (walter) wrote:
> >     sed -e '/exp1/,/exp2/d' file
>  
>  perl -ne'print unless /exp1/.../exp2/'
>  
>  See perldoc perlop for .. and ..., and the differences between them.

Ah, the lightbulb illuminates.  Thanks for that example:  I now
understand the .. operator in a scalar context.  Still a bit fuzzy on
the difference with ... though.  Can someone provide another example?
This outputs the same results whether I use .. or ...:

    #!/usr/local/bin/perl -w
    use strict;
    while (<DATA>) {
        print if /4/../7/;
    }
    __DATA__
    1
    2
    3
    4
    5
    6
    7
    8
    9



-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Thu, 6 Nov 2003 16:03:59 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: equivalent perl for sed command ..newbie question
Message-Id: <bodrdf$rgp$2@wisteria.csv.warwick.ac.uk>


Glenn Jackman <xx087@freenet.carleton.ca> wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote:
> >  arena318@yahoo.com (walter) wrote:
> > >     sed -e '/exp1/,/exp2/d' file
> >  
> >  perl -ne'print unless /exp1/.../exp2/'
> >  
> >  See perldoc perlop for .. and ..., and the differences between them.
> 
> Ah, the lightbulb illuminates.  Thanks for that example:  I now
> understand the .. operator in a scalar context.  Still a bit fuzzy on
> the difference with ... though.  Can someone provide another example?
> This outputs the same results whether I use .. or ...:

<snip>

~% echo "12345467" | perl -lne'BEGIN{$/=\1}; print if /4/.../4/'
4
5
4
~% echo "12345467" | perl -lne'BEGIN{$/=\1}; print if /4/../4/'
4
4
~%

Note that the ... example goes off-on-off whereas the .. example goes
off-onoff-onoff.

Ben

-- 
               EAT
               KIDS                                          (...er, whoops...)
               FOR                                             ben@morrow.me.uk
               99p


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

Date: 6 Nov 2003 11:10:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Execute JavaScript from within Perl
Message-Id: <3faa9ca4@news.victoria.tc.ca>

bruno (bskorepa@yahoo.com) wrote:
: How do I execute Javascript from within perl?

: What I want to do:
: I have a perl script that downloads webpages and analyzes them.
: One of these pages just sends a lot of raw data. A long javascript
: program generates the page using document.write. I would like to read
: this page.

: My system: win2000, activeperl 5.8
: I have downloaded javascript.pm.
: I have downloaded js-1.5-rc5.tar.gz and compiled it with VC 6.0, which
: resulted in 2 files: js32.dll, jsshell.exe.

: Where do I have to copy the dll-file to use it with perl?

Sounds interesting.

Normally a .dll must simply be put somewhere in the path.  



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

Date: 6 Nov 2003 06:27:30 -0800
From: diwaneel@yahoo.com (Newbie)
Subject: how to access a (global) variable across files
Message-Id: <8a54fd80.0311060627.14790bdf@posting.google.com>

Hi

Scenario is like this:
1>I have a file A.pl. It makes a call to the new() functions of other
2 files  B.pm and C.pm.
2> I am accepting a cfg.ini filename as parameter while running A.pl
and storing it in a variable $ini, which I want to access to B.pm and
C.pm.
3> When I declare $ini as out (global) in A.pl and try accessing it in
B.pm as:
my $iniFile = Config::IniFiles->val(file =>$ini)
It says: Global symbol "$ini" requires explicit package name at B.pm

Please tell me how to get the solution for this. P.S.: I dont want to
pass this variable as argument to new().

Pl. reply ASAP.
thanks


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

Date: Thu, 06 Nov 2003 15:26:48 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to access a (global) variable across files
Message-Id: <bodm1f$183n0i$1@ID-184292.news.uni-berlin.de>

Newbie wrote:
> 3> When I declare $ini as out (global) in A.pl and try accessing it
> in B.pm as:
> my $iniFile = Config::IniFiles->val(file =>$ini)
> It says: Global symbol "$ini" requires explicit package name at
> B.pm

Try:

     my $iniFile = Config::IniFiles->val(file =>$main::ini)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 6 Nov 2003 15:56:46 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: how to access a (global) variable across files
Message-Id: <bodqvu$rgp$1@wisteria.csv.warwick.ac.uk>


Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Newbie wrote:
> > 3> When I declare $ini as out (global) in A.pl and try accessing it
> > in B.pm as:
> > my $iniFile = Config::IniFiles->val(file =>$ini)
> > It says: Global symbol "$ini" requires explicit package name at
> > B.pm
> 
> Try:
> 
>      my $iniFile = Config::IniFiles->val(file =>$main::ini)

While this is the correct answer to the question the OP asked :), it
would almost certainly be better to either create the variable in the
B namespace, ie. in A.pl use
  $B::ini = "foo";
rather than simply
  our $ini = "foo";
and then declare it as 'our $ini' in B.pm; or to put
  my $ini;
  sub set_ini {
    $ini = shift;
  }
in B.pm and then call 'B::set_ini("foo")' in A.pl. It's cleaner, and
makes your module more likely to be reusable.

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Thu, 06 Nov 2003 17:23:45 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to access a (global) variable across files
Message-Id: <bodstf$1csu90$1@ID-184292.news.uni-berlin.de>

Ben Morrow wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> Newbie wrote:
>>> 3> When I declare $ini as out (global) in A.pl and try
>>> accessing it in B.pm as:
>>> my $iniFile = Config::IniFiles->val(file =>$ini)
>>> It says: Global symbol "$ini" requires explicit package name at
>>> B.pm
>> 
>> Try:
>> 
>>     my $iniFile = Config::IniFiles->val(file =>$main::ini)
> 
> While this is the correct answer to the question the OP asked :),
> it would almost certainly be better to either create the variable
> in the B namespace, ie. in A.pl use
>   $B::ini = "foo";
> rather than simply
>   our $ini = "foo";
> and then declare it as 'our $ini' in B.pm; or to put
>   my $ini;
>   sub set_ini {
>     $ini = shift;
>   }
> in B.pm and then call 'B::set_ini("foo")' in A.pl. It's cleaner,
> and makes your module more likely to be reusable.

No objection. Global variables in package main is normally not advisable.

Maybe the very first advise to OP should be to study the relevant
docs, such as:

     http://www.perldoc.com/perl5.8.0/pod/perlmod.html

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

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.  

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 V10 Issue 5759
***************************************


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