[19589] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1784 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 21 00:07:27 2001

Date: Thu, 20 Sep 2001 21:06:51 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001045210-v10-i1784@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 20 Sep 2001     Volume: 10 Number: 1784

Today's topics:
    Re: A couple of Win9x Perl questions <ron@indra.com>
    Re: A couple of Win9x Perl questions <bart.lateur@skynet.be>
        Adding Modules to Activestate on Win2k <mikecook@cigarpool.com>
    Re: Adding Modules to Activestate on Win2k <rob_13@excite.com>
    Re: Adding Modules to Activestate on Win2k <ron@savage.net.au>
        CGI params to a hash  [was: Use symbol table like 'real <iltzu@sci.invalid>
    Re: Creating a file <s_grazzini@hotmail.com>
    Re: Dream Login Script (Malcolm Dew-Jones)
    Re: Global variables nobull@mail.com
        Help: LWP/HTTPS/Proxy, problem with certificate (Namsuk Kim)
    Re: how to replace several blank lines with 1 (Jonadab the Unsightly One)
        i not understan  the diff  between $rs=\&greet and  $rs (hugh1)
    Re: i not understan  the diff  between $rs=\&greet and  <buggs-clpm@splashground.de>
    Re: Objects and Sockets nobull@mail.com
    Re: pattern matcher for embedded seperators. <davidhilseenews@yahoo.com>
    Re: Perl Compiler (Jonadab the Unsightly One)
        perl from frames <blahblahblah@blah.com>
    Re: perl from frames <james@zephyr.org.uk>
        Perl installation hangs (R. W. Ennis)
        perl pattern matching question (Thestar Onedallbe)
    Re: Perl time transferred to Javascript ? <ron@savage.net.au>
        perl, lvalues, rvalues, and operators <mikesl@wrq.com>
    Re: pretty printing a web page <W_i_l_l@me.com>
    Re: Problem with Object Oriented Perl (Tim Hammerquist)
    Re: Regular Expresion help needed (Jonadab the Unsightly One)
    Re: Regular Expresion help needed <dtweed@acm.org>
    Re: Regular Expresion help needed (Jonadab the Unsightly One)
    Re: s/// modifies @_ ? <iltzu@sci.invalid>
        Suppress output while using Expect.pm? <vhg@byu.edu>
        this program has wrong ! i not find it , i think it is  (hugh1)
    Re: this program has wrong ! i not find it , i think it <joe+usenet@sunstarsys.com>
    Re: this program has wrong ! i not find it , i think it <buggs-clpm@splashground.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Sep 2001 16:17:09 -0600
From: Ron Reidy <ron@indra.com>
Subject: Re: A couple of Win9x Perl questions
Message-Id: <3BAA6AE5.8BD9BDA@indra.com>

DrDebug wrote:
> 
> Hi all--
> 
> A couple of Perl/Win9x questions, if I may:
> 
> 1) Is there a way, via a Perl script, to discover the CPU speed
> in MHz?
> 
> 2) Is there a way, via a Perl script, to reboot a Win9x machine?
> 
> I have done a cursory search on CPAN, especially the Win32 modules,
> but nothing popped into focus...  I also searched for a manual
> Win9x command line command to reboot, but again, could not find
> one.  Everything is so damned GUI based.
> 
> Perhaps I am missing something obvious, but if anyone has a clue,
> could you please chime in?
> 
> By the way, the machines I am working on are Win98 and WinMe machines,
> not WinNT or Win2000 (which did have some help in that area on CPAN).
> 
> Thanks!
Look at the modules on this site...
http://www.Generation.NET/~aminer/Perl/
-- 
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


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

Date: Thu, 20 Sep 2001 22:51:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: A couple of Win9x Perl questions
Message-Id: <3hskqtc7smq2jffsmfdil9nhrldh27imdf@4ax.com>

DrDebug wrote:

>2) Is there a way, via a Perl script, to reboot a Win9x machine?

Via an API call (with Win32::API), yes. Search for "ExitWindowsEx".
Needn't work on NT (because of lack of privileges).

-- 
	Bart.


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

Date: Thu, 20 Sep 2001 16:36:30 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Adding Modules to Activestate on Win2k
Message-Id: <i4vq7.1820$Ni7.331664@news.uswest.net>

Hello,
    I wish to add some modules to my Win2k Activestate Perl for use in an
app I am writing. I can find the modules on CPAN & have no trouble
installing them on Solaris, but can't seem to get them to work on win32. The
docs on both CPAN & Activestate state that if a module requires compiling
"you're on your own". How does one go about this? Can I use lcc (a free C
compiler for win32)? Can I just copy the MODULE.pm file into my Perl
library?
    Thanks a million!!!
        Michael
--
== CigarPool ==
http://www.cigarpool.com




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

Date: Fri, 21 Sep 2001 01:03:42 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Adding Modules to Activestate on Win2k
Message-Id: <Xns9122D6331E99Brock13com@64.8.1.226>

Michael Cook <news:i4vq7.1820$Ni7.331664@news.uswest.net>:

> Hello,
>     I wish to add some modules to my Win2k Activestate Perl for
>     use in an 
> app I am writing.

Does ActiveState have the modules in their repository? If so any 
compiling and such should already be done IIRC.

> I can find the modules on CPAN & have no
> trouble installing them on Solaris, but can't seem to get them
> to work on win32. The docs on both CPAN & Activestate state
> that if a module requires compiling "you're on your own". How
> does one go about this? Can I use lcc (a free C compiler for
> win32)?

Probably, or gcc if there's one for Win.

> Can I just copy the MODULE.pm file into my Perl library? 

Not if it requires compiling.

-- 
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Fri, 21 Sep 2001 13:27:17 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Adding Modules to Activestate on Win2k
Message-Id: <Pvyq7.1467$cu4.92796@ozemail.com.au>

Michael

If you're a smoker, stop reading. Else, see below.

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
Michael Cook <mikecook@cigarpool.com> wrote in message news:i4vq7.1820$Ni7.331664@news.uswest.net...
> Hello,
>     I wish to add some modules to my Win2k Activestate Perl for use in an
> app I am writing. I can find the modules on CPAN & have no trouble
> installing them on Solaris, but can't seem to get them to work on win32. The
> docs on both CPAN & Activestate state that if a module requires compiling
> "you're on your own". How does one go about this? Can I use lcc (a free C
> compiler for win32)? Can I just copy the MODULE.pm file into my Perl
> library?

It depends on the module.

1) Some a pure Perl, and can be _carefully_ copied to The Right Place.

2) Some are pure Perl but complex and so should be copied with this mantra:

dos>perl Makefile.PL
dos>nmake
dos>nmake test
dos>nmake install

See ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe for the freeware nmake.

3) Some are Perl and C/C++ and so need the same compiler as was used for Perl itself. These are installed with the above mantra.

4) But wait! ActiveState have pre-compiled many modules. Fish around on www.activestate.com for PPM packages.

Eg: To install the GD library, you'd open your internet connexion and then do:

dos>ppm install GD





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

Date: 20 Sep 2001 23:21:59 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: CGI params to a hash  [was: Use symbol table like 'real' hash]
Message-Id: <1001026980.9565@itz.pp.sci.fi>

In article <9od9fi$bhh$1@penthesilea.materna.de>, Bianka Martinovic wrote:
>
>I am using the &template function of Recipe 20.9 of the Perl Cookbook to 
>parse data into a html template. Also, I am using the import_names() 
>function to import the data into namespace 'IN'.

You can already get the parameters from CGI.pm in a (tied) hash.  See
the section "COMPATIBILITY WITH CGI-LIB.PL" in the CGI.pm documentation
for details.

Or you can do it yourself:

  my %in = map +($_ => scalar $cgi->param($_)), $cgi->param();

Depending on how you want to handle multivalue parameters, you may want
to choose one of the variation below instead, or to modify them to suit
your specific needs:

  my %in = map +($_ => join "\0", $cgi->param($_)), $cgi->param();

  my %in = map +($_ => [$cgi->param($_)]), $cgi->param();

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: Fri, 21 Sep 2001 02:37:57 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: Creating a file
Message-Id: <9Kxq7.33983$A5.5339252@typhoon.nyc.rr.com>

'>' will create... so you should certainly double check the variable, as
suggested.

If you want to don't want to clobber a (possibly) existing file, test first
with -e

open FILE,  -e $file ? ">> $file" : "> $file"
    or die "Couldn't open '$file': $!.";

(Seems like there should be an easier way to append-but-create-if-necessary,
but I do not know it.)


"Lorimer" <djdjokic@yahoo.com> wrote in message
news:a18e5d95.0109200913.688a8c90@posting.google.com...
> Here is the problem: I want to open a file if exist and if it is not
> exist then I want to create it and then open for writting in it.
> Opening existing one is not a problem but how to create new one.
>
> open (FILE, "> $file") || die "Could not open $!";
> print FILE 'nesto';
> close (FILE);
>
> And I am getting this message
>
> Could not open No such file or directory at line 650
>
> if there is no such file
>
> Can someone help?




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

Date: 20 Sep 2001 15:43:12 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Dream Login Script
Message-Id: <3baa7100@news.victoria.tc.ca>

Lou Moran (lmoran@wtsg.com) wrote:
: I am currently using a standard batch file for my NT/Win9X user login
: scripts.  It does the following:

Perl can do various things, but as an aside, windows 95 batch files can
extract information such as the username by using NET CONFIG.  A trick is
to filter the output into a temporary batch file and then run that batch
file.  That temporary batch file will have the format required to call
another batch file which sets the username.

something like
	if not %username%.==. goto nt
	NET CONFIG | find "User name" > %TEMP%\set_user.bat
	call %TEMP%\set_user.bat
	:nt

Note that %TEMP%\set_user.bat will look something like
	User name                            JOEBLOE

therefore *ahead* of time you create another batch file on the path called
"User.bat" that looks like

	SET username=%2


which is what gets run when you run the temporary file.



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

Date: 19 Sep 2001 12:58:57 +0100
From: nobull@mail.com
Subject: Re: Global variables
Message-Id: <u97kuvcry6.fsf@wcl-l.bham.ac.uk>

Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr> writes:

> I have a script.pl file, where I use a global variable :

No, you do not.

> use strict;
> my %hash;

my(%hash) declares %hash to be lexically scoped not global.
 
> In this .pl file, I use some .pm files of my own. How can I make these
> .pm modules access the %hash variable, defined in the .pl script ?

There are several ways.  One would be to use global variables (well
actually variables in the package namespace 'main').  

Another would be to pass a reference to %hash into the module in some
way.  Again there are a myraid of ways you could go this.  The most
direct way would be:

use strict;
use MyModule;
my %hash;
*MyModule::hash = \%hash;

The above code where the script directly modifies MyModule's symbol
table is considered ugly.

Without knowing more about what you are trying to achieve it is
impossible to recommend an approach.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 20 Sep 2001 16:59:38 -0700
From: namsuk_kim@lycos.com (Namsuk Kim)
Subject: Help: LWP/HTTPS/Proxy, problem with certificate
Message-Id: <aba94ec.0109201559.6c974b44@posting.google.com>

Hi,

I have been tackling with this problem quite a while.  I am using LWP
to access an https site through an iPlanet proxy.  What I get is that

-------------------------------------------------------------------------------
The requested item could not be loaded by the proxy.
The server's certificate has an invalid signature.
You will not be able to connect to this site securely
--------------------------------------------------------------------------------

My code is quite simple.

-------------------------------------------------------------------------------
use LWP::UserAgent;

$ua = LWP::UserAgent->new;
$ua->proxy(['https', 'http'] => 'http://proxy:8080');
$req = HTTP::Request->new(GET => 'https://madison.fncinc.com/');
$req->proxy_authorization_basic("*******", "*******");
$req->authorization_basic('******', '*****');

print $ua->request($req)->as_string;
--------------------------------------------------------------------------------

The certificate is not right one due to this is test environment. 
This whole thing is happening that LWP is relying on proxy to handle
the certification exchange.  What I like to do is to handle
certificate by myself so I wouldn't depend on the proxy server.  I
have looked for a similar case in Internet, but the search has not
been successful.  Our proxy admin suggest to look for a solution with
Java to handle CAs.  But, I am not a really java person.  But, I am
willing to if there is definite solution for this problem within java.
 In fact, I have started java with sample code but I have not even
authenticate proxy.  If I have missed documentation, please, let me
know.

Thanks in advance,

Namsuk Kim


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

Date: Fri, 21 Sep 2001 03:54:37 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: how to replace several blank lines with 1
Message-Id: <3baab7e7.10283798@news.bright.net>

ced@bcstec.ca.boeing.com (Charles DeRykus) wrote:

> >I cannot find how to replace or delete several successive blank lines
> >from a text file.
> 
> perl -ni.bak -e 'print if !/^$/' file1 file2 ...

That removes *all* blank lines.  Admittedly, he could have
been more clear, but I *think* what he wanted was to remove
only multiple adjascent blank lines, leaving one...

while (<STDIN>) {
   if ($wasblank) {
      if (not(/^$/)) {
         $wasblank=0; print; }}
   else {
      print;
      if (/^$/) { $wasblank=1; }}}

And yeah, I've started formatting the whitespace around
nested grouping symbols in Perl like I do in elisp.  
What can I say, it's addictive.  

-- 
$_=$j="(.";s/$/.)/;$o=$_;s/..//;$k=reverse;($a,$b,$c,)="U r bad"=~
"$j$k$j$k$j+)";($f,$d)="lyons"=~"$o.$o";$_=$d;s/s/o/;$;=reverse($c
 ."a$_");s/o/e/ ;$e="O$_";$g="h";s/$/t/;$ := ".$_";($i) =/(.)$/;$,=
"ig$g$i";$\="he $a$d$,$f $e <j$;\@b$b$,$:>$/";print"$/-- $/J$; $i";


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

Date: 20 Sep 2001 18:58:36 -0700
From: weiwe1@yeah.net (hugh1)
Subject: i not understan  the diff  between $rs=\&greet and  $rs=\&greet(). .....
Message-Id: <7dcf30ba.0109201758.1fe4b0fc@posting.google.com>

hello every one !
 in zhe book << advanced perl programming >> . i not understand one test program. 

 (1)
#!/usr/bin/perl

sub greet {
 print "hello \n";
}
$rs=\&greet;-------------> author say it is not call the greet ,only reference
                            so not print 

$rs=\&greet();-----------> call it . and print 


 (2)
 in another program.

  sub test1 {
     ........
     ........
      return \&test2; ------------> call the test2 print,why ???   
    }

  sub test2 {
    .......
    .......
    }      

 (3) i cahnge it 
   #!/usr/bn/perl
   $rs=\&test1;
   $rs->("batman")->("robin");

sub test1 {
        my $arg=shift;
        print "$arg";
        $b=\&test2;----------> can call test2 print ,if i add () ,it not print!
}
sub test2 {
        my $arg=shift;
        print " and $arg\n";
        }


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

Date: Fri, 21 Sep 2001 04:22:03 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: i not understan  the diff  between $rs=\&greet and  $rs=\&greet(). .....
Message-Id: <9oe8d4$3os$06$1@news.t-online.com>

hugh1 wrote:

[...]
> 
> (3) i cahnge it
> #!/usr/bn/perl
> $rs=\&test1;
> $rs->("batman")->("robin");
> 
> sub test1 {
> my $arg=shift;
> print "$arg";
> 
> $b=\&test2;----------> can call test2 print ,if i add () ,it not print!

because \&test2 returns a code reference
but \&test2() executes test2(), without args,
and returns a scalar reference.

try with:

$b = \&test2("penguin");

> }
> sub test2 {
> my $arg=shift;
> print " and $arg\n";
> }
> 

Buggs



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

Date: 19 Sep 2001 13:18:30 +0100
From: nobull@mail.com
Subject: Re: Objects and Sockets
Message-Id: <u94rpzcr1l.fsf@wcl-l.bham.ac.uk>

delanthear@yahoo.com (Del) writes:

> Could you point me to a working example so I can get my head
> around it?
> 
> eg, 
> socket(SESSION, PR_INET, SOCK_STREAM, getprotobyname('tcp')) || die
> "$!";
> 
> creates a socket, usable by the filehandle SESSION, but how would I
> store that within the object for later use?

You should stop using old Perl4-style naked filehandles.

socket(my $session, PR_INET, SOCK_STREAM, getprotobyname('tcp')) || die "$!";

You can now use the scalar variable $session in place of the bare
filehandle SESSION and you can also store its value in an object.

Note: The GLOBref autovivification used above only works in 5.6 and
later.  In eariler 5.x Perls you would need to use explicitly create a
GLOBref before you call socket().

use Symbol;
socket((my $session = gensym), PR_INET, SOCK_STREAM, getprotobyname('tcp')) || die "$!";

Of course, it would be better still to drop all the Perl4-style socket
IO and use IO::Socket.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 21 Sep 2001 00:12:42 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: pattern matcher for embedded seperators.
Message-Id: <_Bvq7.1131$Rj.549761@news1.rdc1.md.home.com>


"Chandra Yemparala" <ychandra@cisco.com> wrote in message
news:3BAA444D.4CC32A55@cisco.com...
> oops! I am sorry. This one works
>  /<[^<]*(?:<[^>]*>){4}>/,
> But can you tell me how it works? the pattern matcher looks complex!
>
> Thanks a lot
> chandra
>

"Works" is a relative term.  Like I said, it matches <<><><><>>, which may
not be valid.

(?:pattern) is explained in perldoc perlre.  It is similar to plain
parentheses, but doesn't make backreferences ($1,\1, etc).

The character class [^>] matches any character that is not a right angle
bracket.  Many people avoid using the period to say "any character up to a
special delimiter", and instead use a character class like that to say "a
series of characters that are not this character".  The period can surprise
you if you forget about things like greedy matching, so many people try to
avoid it if it's not necessary.  The [^<] character class is similar.
Character classes are also covered in perldoc perlre, but I'm not sure if
this general approach for stopping on a delimiter is in there.

In english, I would read the regex as:

Within angle brackets (beginning < and ending >), match the following:

A series of zero or more characters that are not the opening angle bracket
that starts the 4 elements (mentioned next), followed by 4 occurrences of
"an open angle bracket, with a series of 0 or more characters inside that
aren't the close bracket we're looking for to end this element, and then the
ending close bracket".

Hope this helps.

--
David Hilsee




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

Date: Fri, 21 Sep 2001 03:58:00 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Perl Compiler
Message-Id: <3baaba8b.10959621@news.bright.net>

Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:

> Yes. perlcc. Perhaps we should set up a reward for succesful usage 
> ($500.000 for the one who successfully compiles a script >= 5k).

I suppose it would be considered bad form to try to claim this
by compiling a 5k print statement...

-- 
$_=$j="(.";s/$/.)/;$o=$_;s/..//;$k=reverse;($a,$b,$c,)="U r bad"=~
"$j$k$j$k$j+)";($f,$d)="lyons"=~"$o.$o";$_=$d;s/s/o/;$;=reverse($c
 ."a$_");s/o/e/ ;$e="O$_";$g="h";s/$/t/;$ := ".$_";($i) =/(.)$/;$,=
"ig$g$i";$\="he $a$d$,$f $e <j$;\@b$b$,$:>$/";print"$/-- $/J$; $i";


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

Date: Thu, 20 Sep 2001 23:06:14 GMT
From: "Hmmm..." <blahblahblah@blah.com>
Subject: perl from frames
Message-Id: <GDuq7.3250$Hx1.306490@newsread1.prod.itd.earthlink.net>

For a web app:

I have an html page with an upper and lower frame.  The lower frame has
buttons.  When I click on a button, a perl script executes which retrieves
some database stuff and generates some html to display the data.  In the
generated html, I put some javascript to ensure that the generated page is
displayed in the upper frame.

The problem is that the page first is displayed in the lower frame
(briefly), and then is displayed properly in the upper frame.  How do I get
the page to display right away in the upper frame without first being
displayed in the lower frame where the button was selected?  Thanks.




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

Date: Fri, 21 Sep 2001 01:29:24 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: perl from frames
Message-Id: <3SbdJ1fknoq7Ewjp@gratiano.zephyr.org.uk>

In message <GDuq7.3250$Hx1.306490@newsread1.prod.itd.earthlink.net>,
Hmmm... <blahblahblah@blah.com> writes
>The problem is that the page first is displayed in the lower frame
>(briefly), and then is displayed properly in the upper frame.  How do I get
>the page to display right away in the upper frame without first being
>displayed in the lower frame where the button was selected?  Thanks.

Whilst this seems to not be a Perl related question, using a target for
your href would probably be of use.

-- 
James Coupe                                                PGP Key: 0x5D623D5D
Close your eyes so you don't feel them                           EBD690ECD7A1F
They don't need to see you cry                                   B457CA213D7E6
I can't promise I will heal you, but if you want to I will try  68C3695D623D5D


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

Date: 20 Sep 2001 16:43:20 -0700
From: ennis@yahoo.com (R. W. Ennis)
Subject: Perl installation hangs
Message-Id: <cbeed4a2.0109201543.7be53a7b@posting.google.com>

I'm attempting to install perl5.005_03 (version I have to use) on a
Solaris 2.6 sparc machine. The installation keeps hanging at "System
manual is in man/man1." I've installed the same version on another
Solaris 2.6 machine with no problem. I took a look at Configure and
saw that after finding the system manual it tries to "see what memory
models we can support," so I guess that's what's causing the problem.

Thanks for any help.


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

Date: 20 Sep 2001 18:28:07 -0700
From: luckee0909@yahoo.com (Thestar Onedallbe)
Subject: perl pattern matching question
Message-Id: <b5d53836.0109201728.508dba65@posting.google.com>

Hi:
  I got a file like this :
 # cat glo.txt
malay@uakron.edu>
>To: Anisa Zubery <ZuberyA@idhw.state.id.us>, Ajay Rathi 
><ajayrathi@northwesternmutual.com>,       Alok Das
<axdas@uswest.com>,
>Amitaksha Nag <amitaksha@myiris.com>,       Amit DasAdhikary 
><amit_da@chequemail.com>,       Amlan Guha <amlguha@yahoo.com>, Amlan
Ray 
><amlan@met.iitb.ernet.in>,       Angshuman Dey 
><deyangshuman@rediffmail.com>,       "Anindya K. Paul" 
><akpaul@bechtel.com>,       Anindita Mitra 

 ....et etc.This is the header of a email.I want to grep only the 
email addresses.Not the names or the <> signs.I have tried perl
and awk but all of them gives me the full line ..How can I limit my
search to just the pattern?


Thanks
neil


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

Date: Fri, 21 Sep 2001 13:29:31 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Perl time transferred to Javascript ?
Message-Id: <Uxyq7.1470$cu4.91763@ozemail.com.au>

Peter

See http://savage.net.au/Perl-tutorials.html

for demos on passing data back and forth between Perl and JavaScript.

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: Fri, 21 Sep 2001 04:04:10 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: perl, lvalues, rvalues, and operators
Message-Id: <m3bsk5yyti.fsf@thneed.na.wrq.com>

Hi:

I'm coming from a C background, working my way through the excersises
in _Learning Perl_, and am having a bit of trouble wrapping my mind
around a particular perl-ish concept.

If you want to do regexp substitution on a string, of course you do

$mystring =~ s/regex/subst/

This assumes that mystring is an lvalue, because it does the
substitution in place.  Is there any kind of regexp substituion
operator that can work on rvalues - that is, use of this operator
doesn't change the value on the left, but instead the entire
expression returns a value (the string as processed by the
substitution operator)?

so if the mystery operator is ##, I could do:

$mystring = ($some_constant_string ## s/regex/subst/)


Why I want this - and perhaps the gurus will find the flaw in my logic
here:

Given a subroutine foo() that returns a string, I would like to call
the routine, mangle the output, and print it in one swell foop:

print foo($arg, $notherarg) =~ s/regex/subst/;


Of course, such a construct doesn't compile, but gives the error:

Can't modify non-lvalue subroutine call at ...


Instead, I need a temporary variable:

$temp = foo($arg, $notherarg);
print $temp =~ s/regex/subst;

which doesn't look like the direction "Learning Perl" is steering me.


Since this is a stylistic as well as syntactic question, suggestions
for better uses of either are welcome.


Thanks,


Mike


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

Date: Fri, 21 Sep 2001 03:10:41 GMT
From: W i l l <W_i_l_l@me.com>
Subject: Re: pretty printing a web page
Message-Id: <ugblqt0gnllflgnemrfnvepoc99afnggg2@4ax.com>

what kind of content do you want to print ... text and images, just
text, or is it a page of images ???  If you are only wanting to print
the text then just run a regex across it , something to strip out the
tags that just leaves the content behid,  i.e.


 s/(\<(.*?)\>)//sg;

This is not a perfect regex, I'd look at some of the Perl Modules
specifically intended to parse HTML if this is something you want to
accurately do.

good luck

Will




On Wed, 19 Sep 2001 16:54:30 -0400, "Desrosiers, Benoit
[CAR:9F53:EXCH]" <benoitd@americasm01.nt.com> wrote:

>
>Hi,
>
>I would like to know if there are tools to pretty print a web page on a
>printer.
>I have a perl program which generate a web page but when I want to print
>that web page, I only get the left part of it.
>I have tried everything I can think of to print it: sent it in
>postscript, reducing the font, changing the paper size, changing the
>browser size. But everytime, I only get part of the page.
>
>any help?
>
>thanks,
>Benoit



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

Date: Thu, 20 Sep 2001 23:07:22 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Problem with Object Oriented Perl
Message-Id: <slrn9qkucc.fqp.tim@vegeta.ath.cx>

Me parece que Randal L. Schwartz <merlyn@stonehenge.com> dijo:
> >>>>> "Thomas" == Thomas Bätzler <Thomas@Baetzler.de> writes:
> 
> Thomas> Try instead:
> 
> Thomas> sub new {
> Thomas>   my $proto = shift;
> Thomas>   # get proper classname
> Thomas>   my $class = ref( $proto ) || $proto;
> 
> replace this with
> 
>         my $class = shift;
> 
> for reasons explained in and near
> 
>         http://www.perlmonks.org/index.pl?node_id=52089
> 
> ref($proto) - a bad idea as a *default pattern* that has gone too far.
> Just say no.

Somewhat in line with your statement, I've had the following new() method
in my ASP::NextLink module:

sub new {
    my $class = shift;
    die "Cannot call class method on an object" if ref $class;
    ...    
}

This sort of verification is done inside all subs that are restricted
to *only* instance methods or to *only* class methods. Would you
consider this overkill?  Or would you recommend just doc'ing them as
class|instance calls and let the user misuse at his/her own peril?

Tim
-- 
"Dir-ty deeds...DONE TO SHEEP!"
Heh heh...AC/DC, eat yer heart out.
    -- Mary Roth


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

Date: Fri, 21 Sep 2001 03:35:42 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Regular Expresion help needed
Message-Id: <3baab50c.9553232@news.bright.net>

Dave Tweed <dtweed@acm.org> wrote:

> Fredrik wrote:
> > [^-->] would match any character *except* '-' or '-' or '>'
> 
> [^-->] would match any character except '-' through '>', equivalent
> to [^-./0123456789:;<=>]

ISTR reading someplace that it isn't a particularly good idea
to rely on the behavior of ranges involving non-alphanumeric
characters.  But I don't remember any specific thing that 
would break, just a general lack of guarantee.  

Of course, a ranged character set wasn't what the OP 
really wanted anyway.  

-- 
$_=$j="(.";s/$/.)/;$o=$_;s/..//;$k=reverse;($a,$b,$c,)="U r bad"=~
"$j$k$j$k$j+)";($f,$d)="lyons"=~"$o.$o";$_=$d;s/s/o/;$;=reverse($c
 ."a$_");s/o/e/ ;$e="O$_";$g="h";s/$/t/;$ := ".$_";($i) =/(.)$/;$,=
"ig$g$i";$\="he $a$d$,$f $e <j$;\@b$b$,$:>$/";print"$/-- $/J$; $i";


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

Date: Fri, 21 Sep 2001 04:00:37 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Regular Expresion help needed
Message-Id: <3BAABA20.7D262B84@acm.org>

Jonadab the Unsightly One wrote:
> Dave Tweed <dtweed@acm.org> wrote:
> > Fredrik wrote:
> > > [^-->] would match any character *except* '-' or '-' or '>'
> >
> > [^-->] would match any character except '-' through '>', equivalent
> > to [^-./0123456789:;<=>]
> 
> ISTR reading someplace that it isn't a particularly good idea
> to rely on the behavior of ranges involving non-alphanumeric
> characters.  But I don't remember any specific thing that
> would break, just a general lack of guarantee.

If ranges don't follow the ASCII sequence for characters from \0 to \177,
I would consider them to be broken in a major way. Outside that range,
you're on your own; I don't use those characters.

I was simply making the point that Fredrik had misinterpreted how Perl
would interpret the regex fragment [^-->].

-- Dave Tweed


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

Date: Fri, 21 Sep 2001 03:33:19 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Regular Expresion help needed
Message-Id: <3baab414.9305270@news.bright.net>

fridden@yahoo.com (Fredrik) wrote:

> The drawback with this expression however is that it doesnt 
> handles nested comments. 

Last I checked, neither do most browsers.  I could be mistaken,
but I was under the impression that the following was a single
valid HTML comment:
<!-- some <!-- text <!-- here -->

Furthermore, I believe that it is commonly recommended to 
avoid any > at all within a comment, on the grounds that 
many browsers will take just that as the end of a comment, 
even without a directly preceeding --

That being the case, I think a Perl regex can be forgiven
if it stops stripping the comment upon encountering -->

-- 
$_=$j="(.";s/$/.)/;$o=$_;s/..//;$k=reverse;($a,$b,$c,)="U r bad"=~
"$j$k$j$k$j+)";($f,$d)="lyons"=~"$o.$o";$_=$d;s/s/o/;$;=reverse($c
 ."a$_");s/o/e/ ;$e="O$_";$g="h";s/$/t/;$ := ".$_";($i) =/(.)$/;$,=
"ig$g$i";$\="he $a$d$,$f $e <j$;\@b$b$,$:>$/";print"$/-- $/J$; $i";


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

Date: 20 Sep 2001 23:58:27 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: s/// modifies @_ ?
Message-Id: <1001028398.10201@itz.pp.sci.fi>

In article <3baa49bf@e-post.inode.at>, peter pilsl wrote:
>
>  $temp=~s/\$\$(\$|_|\.)(.+?):(.*?):/
> sub{%$func_ptr=(%$func_ptr,%{$_[1]});
>      @$var_ptr=(@$var_ptr,@{$_[2]});
>      @$val_ptr=(@$val_ptr,@{$_[3]});$_[0]}->
>(fetch_template($ptr,$p[0],
>          $presubst?substitute($var_ptr,$val_ptr,$2,$func_ptr):$2,$p[2]+1,
>              $p[3],
>         $3?$1.($presubst?substitute($var_ptr,$val_ptr,$3,$func_ptr):$3):'')
>)/ge  if $tempsubst;

That's one seriously convoluted expression.  You do know you can put
multiple statements inside an s///e, don't you?

  $temp =~ s{\$\$([$_.])([^:\n]+):([^:\n]*):}{
       my $m2 = $2;
       my $m3 = $3 ? $1.$3 : '';  # think of better names
       if ($presubst) {
           $m2 = substitute($var_ptr, $val_ptr, $2, $func_ptr);
           $m3 = $1.substitute($var_ptr, $val_ptr, $3, $func_ptr) if $3;
       }

       my ($subst, $funcs, $vars, $vals) =
           fetch_template($ptr, $p[0], $m2, $p[2]+1, $p[3], $m3);

       @$func_ptr{keys %$funcs} = values %$funcs;
       push @$var_ptr, @$vars;
       push @$val_ptr, @$vals;

       $subst;  # this is what gets put into $temp
  }ge if $tempsubst;

I think this ought to do exactly what your original code does, down to
some features I think may not have been intentional.  (Should $2 and $3
be allowed to match linefeeds?  What if $3 equals "0"?)  I took the
liberty of tweaking your regex, too -- hopefully to make it faster.

There may, of course, be typos or bugs.  I haven't been able to test it,
as I don't have the rest of the program.  At least it compiles.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: Thu, 20 Sep 2001 17:15:17 -0600
From: Vaughn Gardner <vhg@byu.edu>
Subject: Suppress output while using Expect.pm?
Message-Id: <3BAA7885.1010503@byu.edu>

For various reasons (explained below [1] if you care about the details) 
I need to suppress the output to the screen when send()'ing with 
Expect.pm.  I've tried various strategies [2], with mixed results 
(usually either IO to/from the process breaks or there is no apparent 
change in behavior - it still prints the data I'm send()'ing to the 
screen).  Am I just barking up the wrong tree here, or is there 
something obvious [3] that I'm missing?

Thanks!
Vaughn Gardner

[1] The script I'm writing automates and audits a login for 
underprivileged users, allowing them to run arbitrary code against a 
database and see the results.  We LART them later if it was a bad thing 
to do.  The trick is that they must have no way of knowing the password 
(preferably not the connection method, either) used.  Right now I'm 
starting an ssh process with my $exp=new Expect('ssh', 'user@hostname') 
and using $exp->send("password") to log in at the correct time.  It 
works, but echoes the password to the screen several times in the 
process.  This is bad.

[2] various combinations of $exp->manual_stty(), $exp->exp_stty(), 
$exp->log_group(), $exp->set_group(), $exp->log_user(), system "stty 
-echo", and redirecting STDOUT to /dev/null.

[3] perl v5.6.1; file starts with #! /usr/bin/perl -w; using "use 
diagnostics;"  The script runs fine except that it won't shut up when I 
want it to.



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

Date: 20 Sep 2001 19:31:22 -0700
From: weiwe1@yeah.net (hugh1)
Subject: this program has wrong ! i not find it , i think it is no wrong ,but not work.
Message-Id: <7dcf30ba.0109201831.38d9a1ec@posting.google.com>

thanks ! 

can you help me to point the wrong?



#!/usr/bin/perl

%option = (
        "-1" => \&help,
        "-2" => sub { print " it is the b \n" },
        "-default"=> \&default
        );

procarg(\@ARGV,\%option);
sub procarg {
        my ($rarg,$roption)= @_;
        foreach $arg (@$rarg) {
                if (exists $roption->{$arg} ){
                        $rsub=$roption{$arg};
                        &$rsub();
                }else{
                        if (exists $roption->{"-default"}){
                                &{$roption->{"-default"}};
                         }
                      }
                }
        }

sub help { print " it is the help \n" ;}
sub default { print " it is the default \n" ;}


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

Date: 20 Sep 2001 22:50:00 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: this program has wrong ! i not find it , i think it is no wrong ,but not work.
Message-Id: <m38zf9z293.fsf@mumonkan.sunstarsys.com>

weiwe1@yeah.net (hugh1) writes:

> #!/usr/bin/perl
  ^^^^^^^^^^^^^^^ 

You forgot to enable strictures and warnings:

#!/usr/bin/perl -w

use strict;

> %option = (
 ^^
 my

>         "-1" => \&help,
>         "-2" => sub { print " it is the b \n" },
>         "-default"=> \&default
>         );
> 
> procarg(\@ARGV,\%option);
> sub procarg {
>         my ($rarg,$roption)= @_;
>         foreach $arg (@$rarg) {
                 ^^
                 my

>                 if (exists $roption->{$arg} ){
>                         $rsub=$roption{$arg};
                         ^^             ^
                         my            ->

>                         &$rsub();
>                 }else{
>                         if (exists $roption->{"-default"}){
>                                 &{$roption->{"-default"}};
>                          }
>                       }
>                 }
>         }
          ^       ^     ^

These brackets aren't indented right.

hth

-- 
Joe Schaefer    "When the end of the world comes, I want to be in Cincinnati.
                          Everything happens ten years later there."
                                               --Mark Twain



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

Date: Fri, 21 Sep 2001 04:54:12 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: this program has wrong ! i not find it , i think it is no wrong ,but not work.
Message-Id: <9oea9c$f00$04$1@news.t-online.com>

hugh1 wrote:

>                         $rsub=$roption{$arg};

perl -w

would have told ya :)

Buggs




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

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 1784
***************************************


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