[9679] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3273 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 28 07:17:19 1998

Date: Tue, 28 Jul 98 04:00:32 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 28 Jul 1998     Volume: 8 Number: 3273

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
        AutoLogin <robert_rg@hotmail.com>
    Re: Breaking out of a block (David Cantrell)
        CHOMP not working on some servers <c-denman@dircon.co.uk>
    Re: CHOMP not working on some servers (Neil Briscoe)
        Counting fork()s. dwiesel@my-dejanews.com
    Re: Counting fork()s. dwiesel@my-dejanews.com
    Re: Detecting Countries <boys@aspentech.com>
        how does bless work (Jimmy Zhengyu Zhang)
    Re: Im Willing to pay or give a free DOMAIN for a custo <jaeger@deepfx.com>
    Re: Loop Problem dave@mag-sol.com
        Method GET steban@my-dejanews.com
        Method GET nuriaf@santandersupernet.com
    Re: Native "vmstat" in Perl ? (M.J.T. Guy)
    Re: OFF-TOPIC: Hosting svcs, which is best? (Soren Andersen)
    Re: Perl use in html documents <zkessin@lhr-sys.dhl.com>
    Re: Perl use in html documents <simonf@conduit.co.uk>
    Re: Perl, NT, sendmail <aperrin@mcmahon.qal.berkeley.edu>
        reading a file listing? <clarkjason@usa.net>
    Re: regexp as subroutine parameter <fecund@fatnet.net>
    Re: regexp as subroutine parameter (Ilya Zakharevich)
    Re: regexp as subroutine parameter <r.goeggel@atos-group.de>
    Re: seeing if a file exists. (Ollie Cook)
    Re: subs in separate files? (Ken Williams)
        Try perl on Ms Dos <sursood@mail.emirates.net.ae>
    Re: Usage of tie with ndbm_file <quednauf@nortel.co.uk>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 28 Jul 1998 10:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage901621441.11830@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 18 May 1998

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Spring of
1997; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://cpan.perl.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://cpan.perl.org/
    http://www.perl.com/CPAN/
    http://cpan.perl.org/doc/FAQs/FAQ/html/perlfaq.html
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:

    setdir usenet-by-group/news.announce.newusers
    send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Tue, 28 Jul 1998 13:28:05 +0800
From: robert <robert_rg@hotmail.com>
Subject: AutoLogin
Message-Id: <35BD6163.58D88E4A@hotmail.com>

Hi,

Is there any way to automate login's to web sites ? When I access any of
the sites,
it pops up a login screen and I want to pump in the id/password, the
equivalent
of the 'expect' utility.

The reqmt is that, i have a list of subscribed sites (which prompt for
id/pwd) and
have to make these sites available to the users, who, are not going to
type
in the id and pwd. Meaning, I provide a web page with links pointing to
the sites,
with the users clicking on the links and accessing the sites, without
having
to type in the id/pwd.

Thanks
Robert








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

Date: Tue, 28 Jul 1998 09:45:19 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Breaking out of a block
Message-Id: <35be9c99.59982840@thunder>

On 28 Jul 1998 02:52:49 GMT,
  Tom Christiansen <tchrist@mox.perl.com> enlightened us thusly:

>In comp.lang.perl.misc, someone who screwed with their address asked
>a question.

As the only message referenced in your headers is mine, I assume you
mean I 'screwed with the address'.  I didn't.  The address in my
'from' line is a valid one.

>             The simple solution is to double the braces, of course.

Thankyou.  No doubt, finding which braces to double and then what to
do with them after doubling is left as an exercise for the reader ;-)

--
David Cantrell, part-time NT/java/SQL techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: Tue, 28 Jul 1998 10:58:37 -0700
From: Chris Denman <c-denman@dircon.co.uk>
Subject: CHOMP not working on some servers
Message-Id: <35BE114D.83637A45@dircon.co.uk>

I have been coding perl for 9 months and obviously have had no
problems with CHOMP.  Just recently I moved some code from one
server to another - a daily thing for me - and the code would
not work at all.  After a bit of debugging I found that chomp
only took the last character off of the string and left some
crap (I thought that chomp took off all of the crap off the end
of a string?).

Any thoughts?

Chris



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

Date: Tue, 28 Jul 1998 11:52 +0100 (BST)
From: neilb@zetnet.co.uk (Neil Briscoe)
Subject: Re: CHOMP not working on some servers
Message-Id: <memo.19980728115229.12955A@skep.compulink.co.uk.cix.co.uk>

In article <35BE114D.83637A45@dircon.co.uk>, c-denman@dircon.co.uk (Chris 
Denman) wrote:

> I have been coding perl for 9 months and obviously have had no
> problems with CHOMP.  Just recently I moved some code from one
> server to another - a daily thing for me - and the code would
> not work at all.  After a bit of debugging I found that chomp
> only took the last character off of the string and left some
> crap (I thought that chomp took off all of the crap off the end
> of a string?).
> 
> Any thoughts?
> 
Its difficult to give any useful advice without knowing what the crap was. 
However, chomp() is normally preferred because it *only* gets rid of line 
terminators at the end of a variable.  The older chop() - still found in 
many scripts - will take off whatever the last character at the end is.  
True, it is often a line terminator, but chop() doesn't care.  If you have 
extraneous "crap", that isn't a line terminator, perhaps you should use 
the older call on this occasion.

Regards
Neil



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

Date: Tue, 28 Jul 1998 05:24:27 GMT
From: dwiesel@my-dejanews.com
Subject: Counting fork()s.
Message-Id: <6pjnab$noe$1@nnrp1.dejanews.com>

Hi,

I have a fork() problem. I can't figure out what is wrong. Look at this
code...

#!/usr/local/bin/perl
$number_of_forks = 0;

$SIG{CHLD} = sub { $number_of_forks--; wait;};

for ($i = 0; $i < 3; $i = $i + 1)
{
  $number_of_forks++;
  $pid = fork;

  # If child
  if ($pid eq 0)
  {
        &do_something_that_takes_a_while($i);
        exit;
  }
}

while($number_of_forks > 0)
{
  print "Number of forks: $number_of_forks\n";
  sleep 1;
}

When I run this small program I get the following output:

my_computer:~$ test.pl
Number of forks: 3
Number of forks: 1
Number of forks: 1
Number of forks: 1
etc. etc. (looping forever)

I can't figure out what I have done wrong... can you help me?

// Daniel

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 28 Jul 1998 09:00:20 GMT
From: dwiesel@my-dejanews.com
Subject: Re: Counting fork()s.
Message-Id: <6pk3v3$7cg$1@nnrp1.dejanews.com>

Ok. Now I have figured out the problem. The problem was that I can't fork as
much as I want to. Therefore I have to check if my forking was a failure or
not.

Well, I still have some problems. I wan't to have a loop that continues until
I have done all the forks that I want to do. Then at the end, I want to wait
until all the forks are done.

$number_of_forks = 5;
$started_forks = 0;
$finished_forks = 0;

$SIG{CHLD} = sub { wait; $finished_forks++; };

while($started_forks <= $number_of_forks)
{
    if ($pid = fork)
	{
		$started_forks++;

   		# If child
  		if ($pid == 0)
  		{
                        &do_something_that_takes_a_while;
			exit 0;
  		}
	}
}

while($finished_forks != $number_of_forks)
{
    sleep 1;
}

&handle_the_rest_of_the_program;

Well, when I run the above code I end up in a neverending loop. I can't figure
out why. Maby someone has a solution to my problem?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 28 Jul 1998 11:07:52 +0100
From: Ian Boys <boys@aspentech.com>
Subject: Re: Detecting Countries
Message-Id: <35BDA2F8.5656@aspentech.com>

Scott wrote:
> 
> You could sell a dongle with it that has a GPS receiver.  :-)
> 
> I'd look at the domain, and if it ends with one of the myriad of USA or the
> Canadian postfix, you could not let it run.
> 

Hmmm. My email address is boys@aspentech.com. I access the internet
via an ISP in Boston, MA. Which country am I in?  

PS: It is not the USA.

Ian


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

Date: 28 Jul 1998 07:04:39 GMT
From: zhengyu@lacerta.Berkeley.EDU (Jimmy Zhengyu Zhang)
Subject: how does bless work
Message-Id: <6pjt67$mqm$1@agate.berkeley.edu>

hi, 

  This is my question regarding the insight of "bless".

  When blessed, a pointer to a thingy becomes an object. 

  Later, we can use ref function to return the package (class) name.

  But how does the object actually know which class it belongs to, or
  in other words, what is the magic of bless, or said yet in another way,
  how does the object store the class name information?


  My initial guess was to simply add another field into the hash.        

  bless $a, a_class_name  === $$a{"class" => "a_class_name"};

  when referred, it simply do a hashing on it.    

  but when I treat an object as a hash, and use "keys" to print out all
  its keys, I can not find any such field; in fact, the object is identical
  to a plain hash.


  thanks for your help,

  Zhengyu


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

Date: Tue, 28 Jul 1998 10:21:34 +0200
From: "Ralph Jaeger" <jaeger@deepfx.com>
Subject: Re: Im Willing to pay or give a free DOMAIN for a custom cgi!
Message-Id: <6pjvkg$p8h$1@news.seicom.net>

Hi,

you could do this with ssi and retrieving the url from within perl.
User won't notice.
The problem:
the sponsor would notice a whole lot of clicks from on ip !

also most sponsors are not willing to pay more then 4% clickthrough rate...

ralph


--
-
----------------------
email: jaeger@deepfx.com

Personal Spider - Free remotly hosted search-engine
Sitegrabber - A free site retrieval service

http://www.deepfx.com/sitegrabber/
method98 schrieb in Nachricht
<6pj6hr$cle$1@reader1.reader.news.ozemail.net>...
>Can Anyone Make a Hidden Cgi that clicks on sponser
>undectably to the user viewing the web page and the sponsers
>itself... I am willing to pay Webmasters or Hosters $400 USD with my
>credit card, or buy a DOMAIN to anyone how can make this cgi-script
>and the DOMAIN is for 1 year.
>
>IT MUST BE 110% UNDECTABLE TO THE SPONSERS AND THE USERS!!!
>
>if you can make this, email a.s.a.p
>
>method98@iname.com
>
>
>Regards
>
>
>
>
>




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

Date: Tue, 28 Jul 1998 07:57:40 GMT
From: dave@mag-sol.com
Subject: Re: Loop Problem
Message-Id: <6pk09j$3qa$1@nnrp1.dejanews.com>

Juli,

If I understand your problem correctly the important lines are

if (($line =~ /$nameitem/) &&
 ($line =~ /$familyitem/))

which you expect to fail if $nameitem and $familyitem don't have data in them.
In this case they will effectively contain an empty string and an empty string
will match whatever you have in $line.

hth,

Dave...

In article <6pj45h$u47$1@nnrp1.dejanews.com>,
  Juli@my-dejanews.com wrote:
> while (defined ($line = <SAM>) ) {
> # if cusip matches write line to file
>    if ($line =~ /$cusip/) {
> 	    push (@file, $line);
> 	    $found = 1;
>    }
> # else match all the variables, write line(s) to file
>    else {
>    	foreach $nameitem (@name){
> 	 foreach $familyitem (@family){
>
> 		  if (($line =~ /$nameitem/) &&
>   	    	     ($line =~ /$familyitem/)) {
>
> 		  push (@file, $line);		  $found = 1;  }  }  }	}  }
> What I am trying to do here, is 1st match a $cusip to $line. If they match
> push the line to a file. The problem I'm having is, if the first $line, or
> second $line, or any $line up to the matching $line, doesn't match $cusip,
> you drop down into the second loop, and at that point all unmatching $lines
> are pushed to the file, until the matching $line is found, then that $line is
> finally pushed to the file. I don't understand why this is happening, b/c in
> the second loop, $nameitem, and  $familyitem do not have any values to match
> $line, and therefore shouldn't be pushed.  This information is coming from a
> form, and is compared against lines in a file.	So if you just choose
the
> cusip, then $nameitem, and $familyitem do not have any values.
> juli@my-dejanews.com
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 28 Jul 1998 10:11:37 GMT
From: steban@my-dejanews.com
Subject: Method GET
Message-Id: <6pk84o$be4$1@nnrp1.dejanews.com>

My CGI program (perl 5.00x) run whit the GET method when I call from windows
95. Wowever from windows NT not run. If I change the POST method then It run.
Why? is It for the CONTENT_LENGTH variable? How I could modify the
CONTENT_LENGTH variable?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 28 Jul 1998 10:12:04 GMT
From: nuriaf@santandersupernet.com
Subject: Method GET
Message-Id: <6pk85j$bea$1@nnrp1.dejanews.com>

My CGI program (perl 5.00x) run whit the GET method when I call from windows
95. Wowever from windows NT not run. If I change the POST method then It run.
Why? is It for the CONTENT_LENGTH variable? How I could modify the
CONTENT_LENGTH variable?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 28 Jul 1998 10:27:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Native "vmstat" in Perl ?
Message-Id: <6pk92n$452$1@pegasus.csx.cam.ac.uk>

root  <root@birch.netsis.com> wrote:
>        $VMSTAT=`vmstat | tail -1 ` ;
>
>Problem:  IMHO, the backquoted "vmstat | tail -1" on line 15.  This 
>          forks not one, but two processes .. every $Sleeptime 
>          seconds.  Not good.  Running this on an old SPARC 2 shows 
>          96% idle .. but perfmeter sings a far different song.  
>          During the 30 seconds the process runs, CPU averages about 
>          20%, and peaks at 30%.  Which makes this code a 
>          "Heisenberg's microscope".  
>
>What I    Is there a Perl-native "vmstat" module that does not 
>want:     require a second process to be forked ?  That might help.  

You get two processes, one to run `vmstat' and a second to run `tail'.
The obvious solution is to do the `tail' function in Perl:

      { my @vmstat = `vmstat`;
        $VMSTAT = pop @vmstat;
      }


Mike Guy


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

Date: Tue, 28 Jul 1998 01:05:16 -0400
From: sorentin@sprynet.com (Soren Andersen)
Subject: Re: OFF-TOPIC: Hosting svcs, which is best?
Message-Id: <6pjm66$p7p@bgtnsc03.worldnet.att.net>

In article <35BCE813.2DD4@min.net>, John Porter (jdporter@min.net) 
says...
> You think wrongly.  And your anarchist attitude stinks.

   LOL

     soren andersen


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

Date: 28 Jul 1998 08:28:13 +0100
From: Zachary Kessin <zkessin@lhr-sys.dhl.com>
Subject: Re: Perl use in html documents
Message-Id: <m34sw2l9iq.fsf@pc-hhu-52.lhr-sys.dhl.com>


Eric S Keyes <eskeye01@homer.louisville.edu> writes:

> I somewhat can use perl and the book I am learnign from does not help with
> this.
> 
> My problem in an example:
> 
> <html>
> <body 'bla bla bla'>
> Welcome to my page.
> 
> <* Run a perl script to insert data here*>
> 
> Thank you and please read my guestbook.
> </body>
> </html>
> 
> To clarify I would like to load a script into the html doc, right now
> all I know is how to to is make the perl script create a new html doc and
> I do not want to do this.
> 

there is a package called HTML::Embperl, it will do just what you
want. Its on CPAN.

--Zach


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

Date: Tue, 28 Jul 1998 11:18:23 +0100
From: "Simon Fairey" <simonf@conduit.co.uk>
Subject: Re: Perl use in html documents
Message-Id: <35bda48a.0@nnrp1.news.uk.psi.net>

If you absolutely cannot use a cgi script to create the whole page (I assume
it is an ISP restriction) but need processing in the middle then you need to
look into PerlScript (fairly new though) or the more established JavaScript.

Simon
Eric S Keyes wrote in message ...
>I somewhat can use perl and the book I am learnign from does not help with
>this.
>
>My problem in an example:
>
><html>
><body 'bla bla bla'>
>Welcome to my page.
>
><* Run a perl script to insert data here*>
>
>Thank you and please read my guestbook.
></body>
></html>
>
>To clarify I would like to load a script into the html doc, right now
>all I know is how to to is make the perl script create a new html doc and
>I do not want to do this.
>
>Please help.
>
>Eric S. Keyes
>@}-,-}- BlkRose @}-,-}-
>
>Mail: erickeyes@louisville.edu
>Web : http://www.louisville.edu/~eskeye01
>
>"You can push the meek around but those with a strong will, never budge."
>




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

Date: Mon, 27 Jul 1998 21:47:15 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: Dale Askey <askeyd@seer.wustl.edu>
Subject: Re: Perl, NT, sendmail
Message-Id: <35BD57D3.84C2C3AD@mcmahon.qal.berkeley.edu>

That depends on how your program accesses sendmail.  Try searching the code
for the reference to the path where sendmail is supposed to live -- it has
to be there somewhere!  You should then be able to change the path in the
code to your correct one, and go from there.

I often do this at the beginning of a program, i.e.:

$mailcmd = '/usr/local/bin/sendmail -t';

so I can change it easily if we move it around systems.

Good luck.

Dale Askey wrote:

> Confession: I'm totally new to Perl and am not much of a programmer
> (e.g.-JavaScript gives me a headache).
>
> Problem: Running IIS 3.0 on NT 4.0. I've read dozens of posts looking
> for my answer but have yet to find it. I've installed Perl successfully
> (from NT Resource Kit), modified my registry to address .pl files, and
> created and tested a script from a Web page. Now I've got a script I
> downloaded from a web site
> that is a form handler designed for UNIX. I've corrected the #! line at
> the beginning to tell it where Perl dwells, but I have no idea how to
> tell it where to find my NT sendmail program, wSendmail. wSendmail works
> fine from a command prompt and from a web page (if accessed directly in
> the script directory), but I cannot call it from the original script I
> was tinkering with. I've tried $DOS_path, $smtp=, and numerous other
> syntaxes, but the mail will not go. Basically, I want to call wSendmail
> from another script on my server. If that won't work, I'd be happy to
> point to our VMS mail server, if only I knew the syntax. Is there a
> simple answer, besides 42, to this rambling question?
>
> Many thanks in advance,
>
> Dale Askey
>
> --
> Pediatric Computing Facility
> Washington University
> St. Louis, MO
> askey_d@kids.wustl.edu



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King
http://socrates.berkeley.edu/~aperrin        to e-mail me)
    e-mail wheres-andy@socrates.berkeley.edu to find me!
-------------------------------------------------------------




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

Date: Tue, 28 Jul 1998 10:30:07 +0100
From: Jason Clark <clarkjason@usa.net>
Subject: reading a file listing?
Message-Id: <35BD9A1E.2251A196@usa.net>

I'm trying to quite simply read a file listing from a given directory.
The files I want to list will change so
I will need to use a varible with my wild card expressions.
The (foreach) loop used dos not reconise the format of my Var. and
replys in the below code, One file which is my wild card syntax.

----------------------------------------------
$filename = "123.txt";                            # Files already exist
of 123.txt.001 / 123.txt.002 / 123.txt.003
$FileParttern = "<".$filename."*>";
print $FilePatterm;                                # Returns
<123.txt*>

foreach $files ($FilePattern)                  # If I use <123.txt*> it
works/ But not with the Var.
  {
    print $files;                                        # Returns the
FilePattern. <123.txt*>
  }
------------------------------------------------

Can Any one help me. I must be doing somthing stupid???



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

Date: Tue, 28 Jul 1998 01:04:02 -0700
From: Yary Hluchan <fecund@fatnet.net>
To: ryanpc@lbin.com
Subject: Re: regexp as subroutine parameter
Message-Id: <35BD85F2.7EB4@fatnet.net>

]   foreach $id (keys %hash) {  $contents =~ $regexp;     };

have you tried $contents =~ /$regexp/ge ?


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

Date: 28 Jul 1998 09:09:59 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regexp as subroutine parameter
Message-Id: <6pk4h7$gb5$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to ryan pc gibson 
<ryanpc@lbin.com>],
who wrote in article <35BD3259.32F272A5@lbin.com>:
> $regexp = 's/$id/$hash{$id}/gism'
 ...
>     foreach $id (keys %hash) {	$contents =~ $regexp;     };

While 
      $a =~ $b;
is a legal syntax, it does not do what you think it does.  It is just a
shortcut for 
      $a =~ /$b/;

What is bad with plain

      foreach $id (keys %hash) {        $contents =~ s/$id/$hash{$id}/gism };

?

Ilya


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

Date: Tue, 28 Jul 1998 11:03:23 +0200
From: "Ronald Gvggel" <r.goeggel@atos-group.de>
Subject: Re: regexp as subroutine parameter
Message-Id: <6pk472$5n3$1@news.pop-stuttgart.de>


ryan pc gibson schrieb in Nachricht <35BD3259.32F272A5@lbin.com>...
!>hello,
!>
!> i damn near lost my mind trying to figure out how to pass a regexp
as a
!>parameter to a subroutine (that i am trying to make as general as
!>possible).  the tricky part is i want the perl regexp to contain
!>variables that get interpolated once they are inside the subroutine,
not
!>before.
!> i would be very interested in any suggestions or thoughts.
!>
!> - ryan*(pc)
!>
!> here is a skeleton of the code...
!>
!>########################################
!># somewhere in main loop
!>
!>$regexp = 's/$id/$hash{$id}/gism'
!>&insert_hash(\%hash,$file);
!>
!>########################################
!># replaces occurences of the key with value for each hash item
!>
!>sub insert_hash {
!>
!>    my %hash = %{@_[0]};    # hash of ids/values to replace
!>    my $file = @_[1];       # file to modify
!>
!>    # convert file to string
!>    open(IN,$file); $contents=join('',<IN>); close IN;
!>
!>    foreach $id (keys %hash) { $contents =~ $regexp;     };

my $command = "foreach \$id (keys %hash) { \$contents =~
exp;     };";
eval $command;

!>
!>    open(OUT,">$file") or die "Could not open $file for output\n";
!>    print OUT $contents or die "Could not write to $file\n";
!>    close OUT;
!>
!>}; # end insert_hash sub
!>

this is just an idea, no tested code.

HTH
Ronald






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

Date: Tue, 28 Jul 1998 07:02:49 GMT
From: oliver.cook@bigfoot.com (Ollie Cook)
Subject: Re: seeing if a file exists.
Message-Id: <35bd76d3.304650@news.ukonline.co.uk>

On 28 Jul 1998 00:19:31 GMT, mgjv@comdyn.com.au (Martien Verbruggen)
wrote:

>In article <35bc2928.457026@news.ukonline.co.uk>,
>	oliver.cook@bigfoot.com (Ollie Cook) writes:
>> I'm having some trouble at the moment with a shopping cart that i'm
>> writing, and would really appreciate it if some of you could shed some
>
>another shopping cart? :)

My client wanted a specially written one...

>>  # Fill Out Amount, Either From File, Or Set To Zero
>>
>>	if (-e "$visitordir/$ENV{'REMOTE_ADDR'}") 
>
>Are you running under -w? Did you try using strict? Both are very good
>practices.
>
>Does $ENV{'REMOTE_ADDR'} contain anything at all? If it doesn't, then
>you will just test for the existence of $visitordir. Maybe you should
>consider using the -f test. Either that, or test that
>$ENV{REMOTE_ADDR} does indeed contain something useful.

I thought that wouldn't be necessary since the script is always called
from a browser and that will convey $ENV{'REMOTE_ADDR'} automatically.

>>	{
>>   	open (DATAIN,"$visitordir/$ENV{'REMOTE_ADDR'}");
>
>You should always, always check the return value of an open.
>
>open(ZZ, $file) || die "Cannot open $file: $!";

Sounds like an extremely good idea to me. I'll whack that in the next
version. Thanks for the tip!

>>   	@readin = <DATAIN>;
>>   	close(DATAIN);
>>   	$readloop = "0";
>
>Why are you quoting the 0?

erm... mistake!

>There are other ways of setting an array to all zeroes, although I
>can't think of any real use for that right now. You should probably
>read the perldata documentation:
>
># perldoc perldata

Shall do!

>> I hope someone can give me a clue on this one, and if you're disgusted
>> by my code, please don't be - I'm just learning.
>
>That's why there are pointers in there to improve it :)
>
>Martien

Thanks very much for those tips!

Regards,

Ollie
----
Oliver COOK, Web Site Designer for
Premiere Web Designs - Http://Www.Premiere.Uk.Com/
+
Webmaster of The Audio-Visual Archive 
 * over 900 images and 700 sounds, free
 * Http://Www.Premiere.Uk.Com/ava/ 


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

Date: Sun, 26 Jul 1998 15:55:13 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: subs in separate files?
Message-Id: <ken-2607981555130001@news.swarthmore.edu>

Hi,

You don't use "require" or "use" to find a subroutine, you use it to find
a file.  That file can contain subroutines.  Here's an example:

____________ file1.pl contents __________________

sub something {
  ...
}

1;
____________ file2.pl contents __________________

require "file1.pl";
&something();
_________________________________________________


It's basically the same idea with "use", but until you've mastered
"require" I'd stay away from "use."  There are a few gotchas that may just
confuse you now.


In article <35BA7DC4.10A6D1F8@acm.org>, melinda@acm.org wrote:

>Thanks for the replies.  I think maybe I need to 
>modify my question.  How do I get "use" and/or
>"require" to search the CURRENT DIRECTORY for the
>subroutine.  I get messages about not being able
>to find the subroutine in one of the libraries
>provided with perl. It would be a tremendous help
>if someone would actually provide a simple example.
>Thanks, 
>Melinda Quinn   melinda@acm.org  
>
>Quinn,M wrote:
>> Novice question:
>> How do I put subrouotines (functions) into
>> separate files?  I have learned to call functions
>> (subs) that are in the SAME file, but I cannot
>> figure out how to put subs in separate files.
>> I've tried "use", "require", etc. No luck.
>> The following works in the SAME file - how can I
>> make the subroutine work if it is in a SEPARATE FILE
>> IN THE SAME DIRECTORY?
>> ==== file: subtry ========
>> #!/usr/bin/perl -w
>> print ("=== subtry BEFORE calling subtry2 ==\n);
>> $MVAR = "SOMETHING";
>> subtry2($MVAR);
>> print ("=== subtry AFTER calling subtry2 ==\n");
>>======== works if in SAME file - not if in DIFFERENT file=== 
>> sub subtry2 {
>> my $Stuff = $_[0];
>> print ("This stuff is $Stuff \n");}
>> ================EOF=============================
>> If anyone can refer me to pages in "Learning Perl" or
>> "Programming Perl" or on-line Perl documentation,
>> I'd be grateful.
>> Please also reply by e-mail.  Thank you.
>> Melinda Quinn    melinda@acm.org
>> 
>> }


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

Date: Mon, 27 Jul 1998 21:01:01 +0400
From: Suruchi <sursood@mail.emirates.net.ae>
Subject: Try perl on Ms Dos
Message-Id: <35BCB24D.78E8@emirates.net.ae>

Hi Everyone
i would like to try executing some perl scripts on my stand alone pc. I
know that perl compiel is available for Ms Dos. i've downloaded it but i
can't save my file with the extention .pl . can some one help me.
i'm using notepad to make the program.


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

Date: Tue, 28 Jul 1998 09:56:03 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
To: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Usage of tie with ndbm_file
Message-Id: <35BD9223.8DE59AFE@nortel.co.uk>

Daniel Grisinger wrote:
> 
> >Hello there, it's Monday and it's difficult to think
> 
> That's ok, drink some coffee, it'll get better :-).

It does, doesn't it ?!?

> use Fcntl;  # have to import your constants

That does the trick indeed, thank you very much !

> >Argument "O_SVWST" isn't numeric in null at
> >/u/quednauf/public_html/cgi-bin/vote.pl line 13.
> 
> You forgot to C<use Fcntl;>, so the O_RDWR and O_CREAT
> constants weren't imported.  O_SVWST is the result of
> a bitwise or on the two strings O_RDWR and O_CREAT.

Quite Funny in a way....

> Consider-
> use Fcntl;
> print O_RDWR | O_CREAT, "\n";
> print 'O_RDWR' | 'O_CREAT', "\n";
> __END__
> 66
> O_SVWST

Which means that you can use the number directly, so you wouldn't have
to import Fcntl.
Anyway, cheers for that..

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3273
**************************************

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