[13543] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 953 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 30 16:07:11 1999

Date: Thu, 30 Sep 1999 13:05:15 -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: <938721915-v9-i953@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 30 Sep 1999     Volume: 9 Number: 953

Today's topics:
    Re: @INC and CGI problem <rootbeer@redcat.com>
        Book suggestion <nolenj@worldnet.att.net>
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca <aqumsieh@matrox.com>
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca <AgitatorsBand@yahoo.com>
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca <jll@enterprise.newedgeconcept>
        Calling a subroutine held at one sever from another (C. Gaunt)
    Re: Catching errors in anouther name space. <rootbeer@redcat.com>
    Re: CGI call CGI? <rootbeer@redcat.com>
    Re: debugger I/O redirect <stampes@xilinx.com>
    Re: debugger I/O redirect (Ilya Zakharevich)
    Re: HELP! Clueless know-nothing asks a question <jre@idirect.com>
    Re: how to invoke DUN from perl? <jdrumm@blazenetme.net>
    Re: Indent around perl "print <<EOF" constructs? <aqumsieh@matrox.com>
        Install CPAN module in ActiveState Windows version of P <walsh@averstar.com>
    Re: Install CPAN module in ActiveState Windows version  <jeff@vpservices.com>
        memory differences reported by top and perl? <stampede3@yourcompass.com>
        numeric sort on field 2 in @array... <shiloh@shell9.ba.best.com>
    Re: Perl - SQL examples <smiles@wfubmc.edu>
        Perl module for Kerberos telnet  <tohru@bigfoot.com>
        Perl5.005_03 on RedHAT 6.0 <N0SPAM-msturtz@bcandid.com>
    Re: Please compare and contrast C and Perl. (Scott Sellers)
    Re: Pre-release Perl Beta-Testers <uri@sysarch.com>
    Re: Proble with chopped filenames from script <aqumsieh@matrox.com>
    Re: Proble with chopped filenames from script (Abigail)
    Re: Proble with chopped filenames from script <aqumsieh@matrox.com>
        Problem with list! <cutandpastescripts@exl.co.uk>
    Re: Problems compiling perl <rootbeer@redcat.com>
    Re: Q: Syntax to open a file in PERL on an NT server <hartleh1@westat.com>
    Re: Q: Syntax to open a file in PERL on an NT server (Necromancer)
    Re: Q: Syntax to open a file in PERL on an NT server (Larry Rosler)
    Re: Q:post-compile testscripts fail <rootbeer@redcat.com>
    Re: Question from a starter <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 30 Sep 1999 12:06:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: @INC and CGI problem
Message-Id: <Pine.GSO.4.10.9909301200220.17231-100000@user2.teleport.com>

On Wed, 29 Sep 1999 edoloughlin@my-deja.com wrote:

> I can't get my CGI scripts to work with the 'use' keyword and
> any of the standard modules. 

Perhaps the modules aren't properly installed in the correct places.

> When I print @INC from a CGI prog I get correct results. 

Are you modifying @INC inside your program? Don't forget that 'use'
happens at compile time.

> AFAIK, the directory in which the script is executed shouldn't be
> relevant, as the paths are absolute anyway.

Yes, except for '.' (which may not be present). Of course, you can't rely
upon dot being any particular directory at the start of a CGI program.

Could you be running a different perl binary than you think? Could there
be some useful error messages which your server is gobbling up or hiding
in a log file?

Good luck with it!

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



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

Date: Thu, 30 Sep 1999 15:14:05 -0500
From: "Nolen Johnson" <nolenj@worldnet.att.net>
Subject: Book suggestion
Message-Id: <7t0fa5$n74$1@bgtnsc01.worldnet.att.net>

I'm looking for suggestions on a perl 5 book that either
strictly or mostly deals with regular expressions...pattern matching etc.
I've got plenty of perl books, but regular expressions indeed could
be covered in a book by itself.

TIA





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

Date: Thu, 30 Sep 1999 11:14:37 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <x3y670sv3c2.fsf@tigre.matrox.com>


"Paul J. Lucas" <pjl@fuckoff.com> writes:

> 	Since when does Tom deserve decency?

Then perhaps you shouldn't be consulting perldoc or any of the on-line
perl docs and FAQs. You shouldn't be reading the Llama either, or the
Camel, and certainly not the Ram. You shouldn't be reading the
FMTEYEWTK series and shouldn't download the PPT.

Actually, you shouldn't be using Perl at all.

--Ala



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

Date: Thu, 30 Sep 1999 17:30:36 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <07NI3.72$QB2.11160@news.shore.net>

Ala Qumsieh <aqumsieh@matrox.com> wrote:
:> 	Since when does Tom deserve decency?

: Then perhaps you shouldn't be consulting perldoc or any of the on-line
: perl docs and FAQs. You shouldn't be reading the Llama either, or the
: Camel, and certainly not the Ram. You shouldn't be reading the
: FMTEYEWTK series and shouldn't download the PPT.

: Actually, you shouldn't be using Perl at all.

What are you implying? That because Tom has contributed a lot of work to
the perl community that we should pretend that he isn't a condescending
jerk when he posts?

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 01 Oct 1999 00:06:07 +0200
From: Jean-Louis Leroy <jll@enterprise.newedgeconcept>
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <m3iu4srr5c.fsf@enterprise.newedgeconcept>

> You are missing a point:  there are two different persons posting
> under the same netidentity.  Thanks go to one of them (from me too),
> flames go to another one (from me too).

???


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

Date: Thu, 30 Sep 1999 18:29:50 GMT
From: plate-n-sheet@postservices.com (C. Gaunt)
Subject: Calling a subroutine held at one sever from another
Message-Id: <37f3abba.39322794@news.prestel.co.uk>

Is it possible to call a subroutine that is is the cgi-bin on one
sever from a perl script in the cgi-bin of a second server.
I tried:
server1
# hello.pl
sub say_hello {
  print "Content-type: text/html\n\n";
  print "Hello from server1.com\n";
}

server2
#!/usr/bin/perl
require "http://www.server1.com/cgi-bin/hello.pl;
&say_hello;

It did not work. error log reports cannot find
http://www.server1.com/cgi-bin/hello.pl

Is there a way of doing this?  


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

Date: Thu, 30 Sep 1999 12:44:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Catching errors in anouther name space.
Message-Id: <Pine.GSO.4.10.9909301242060.17231-100000@user2.teleport.com>

On Wed, 29 Sep 1999, Scott Beck wrote:

> See if you can figure out where it is crashing.
> 
> <CODE>
> #!/usr/bin/perl -w
> 
> use CGI::Carp 'fatalsToBrowser';

Maybe (just maybe) this isn't doing what you think it's doing. Perhaps
it's not installed correctly, for example.

There are other ways to do this, but for debugging, I
sometimes put something like this near the top of a script.

    # Remove this block when done debugging!
    BEGIN {
	local($|) = 1;			# Temporarily turn off buffering
	print "Content-type: text/plain\n\n";
	my $date = localtime;
	print "Script $0\nrunning on $date (Perl version $])\n\n";
	unless (open STDERR, ">&STDOUT") {
	    print "Can't redirect STDERR: $!";
	    exit;
	}
	print "\n";
    }

Now you should be able to see any error messages (and everything else)
produced by your script, right on your browser.

Good luck with it!

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



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

Date: Thu, 30 Sep 1999 12:51:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: CGI call CGI?
Message-Id: <Pine.GSO.4.10.9909301250140.17231-100000@user2.teleport.com>

On Thu, 30 Sep 1999, Bangert Goldsmith wrote:

>   How can I call an CGI script from another CGI script, both in Perl?

Whether written in Perl or not, they must implement the CGI protocol.

    http://hoohoo.ncsa.uiuc.edu/cgi/

Good luck with it!

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



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

Date: 30 Sep 1999 17:29:00 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: debugger I/O redirect
Message-Id: <7t06ks$9q2@courier.xilinx.com>

Christian Seeberger <cseeberg@sgi1.chemie.uni-hamburg.de> wrote:
: How can I redirect the I/O (mainly the O) from the debugger ?? I have a
: large hash and each time i dump it with 'X hash' it runs through the
: screen. I know about '|X hash' but that is not what I need. Actually I
: have two large hashes and need to compare them. So it would be nice to
: dump them into separate files for further examination. Anny ideas on how
: to do this ??

I've been doing some of this myself recently (perl makes it so damn
easy to work with BIG datastructures, and it's so fast, it's hard to
resist the temptation to create some BIG honkers) 

I started using Data::Dumper...here's a quickie to show you an
example of how to use it to accomplish your task.  For the purpose
of debugging, insert a use Data::Dumper in your script, and then
put in a similar function to my dump_hash_to_file()

(For bonus points:  Why does Perl complain about my only using
 the DUMP filehandle once?  Don't the open and close count?)

#!/devl/perl/bin/perl -w

use strict;
use Data::Dumper;
use Fatal qw(open close);

my $rh = \%INC;
dump_hash_to_file('/tmp/Dump.out',$rh);

sub dump_hash_to_file
{
   my ($filename,$rh) = (@_);

   open DUMP, ">$filename";
   print DUMP Dumper($rh);
   close DUMP;
}


-- 
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 30 Sep 1999 19:12:00 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: debugger I/O redirect
Message-Id: <7t0cm0$rf8$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Christian Seeberger 
<cseeberg@sgi1.chemie.uni-hamburg.de>],
who wrote in article <37F333B7.D75F8EB9@sgi1.chemie.uni-hamburg.de>:
> Hi there
> 
> How can I redirect the I/O (mainly the O) from the debugger ?? I have a
> large hash and each time i dump it with 'X hash' it runs through the
> screen. I know about '|X hash' but that is not what I need. Actually I
> have two large hashes and need to compare them. So it would be nice to
> dump them into separate files for further examination. Anny ideas on how
> to do this ??

a) Do not use 'X' command of debugger.  It is there mostly for
   backward compatibility.  Do 'h h' if in doubt.

b) you can dump the values yourself:

   DB::dumpit(\*YOUR_HANDLE, expr)

Ilya


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

Date: Thu, 30 Sep 1999 17:48:48 GMT
From: "James E." <jre@idirect.com>
Subject: Re: HELP! Clueless know-nothing asks a question
Message-Id: <4oNI3.17671$fp1.195596@quark.idirect.com>

>>When I open the index.html file, there's nothing!  wwwboard.out has
>>something in it, so it should load.  The server supports SSI, and
everything
>>is CHMOD'd properly.  So my question - what's wrong!?
>
> Try using 'use strict', '-w', and put a return code handler on
>open(), like 'open(FOO, "$file")||die "$0: can't read $file\n"' .  Then
>check your error_log output if the script fails to run.  In the future,
>put 'use strict' and '-w' in all of your scripts.


Thanks,
--J



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

Date: Thu, 30 Sep 1999 16:03:06 -0400
From: Jeffrey Drumm <jdrumm@blazenetme.net>
Subject: Re: how to invoke DUN from perl?
Message-Id: <Q7=zNxH5l+AvylnXwPPryns2eaDQ@4ax.com>

[posted to comp.lang.perl.misc and mailed]

On Wed, 29 Sep 1999 13:09:47 GMT, tony_barratt@my-deja.com wrote:

>Hi list,

Hello, scalar.

>I'm running active state perl 519 on W98, and NT. What I want to do is
>to invoke a pre-defined connection defined in DUN so as to cause a dial-
>out to a RAS access number (so I can do a Net::Ping to various hosts).
>I thought that might be easy, and perhaps it is, just that I don't know
>how to do it...
>I suppose if it was possible to invoke a connection with a Start.Run,
>then I could use a system("mi_coomand"). But maybe the answer llies in
>the Win32 api?
>If i get stuck I guess I could install RAS on NT, and not use the W98,
>and cause a dial-out with a ping to a remote IP address (associated
>with a phone num in RAS) but that's not really what i want to do.

Pretty much the same way you would from just about any other scripting
language, which means this really isn't a Perl question. But I'm feeling
charitable today, so I'll give you a place to start:

	http://support.microsoft.com/support/kb/articles/Q145/7/40.asp

It took me less than a minute to locate this on Microsoft's support site.

What's your excuse?

(guess I wasn't really feeling that charitable after all)

-- 
 - Jeff Drumm
   "So what are YOU doing on 00/01/100?"


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

Date: Thu, 30 Sep 1999 13:49:59 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Indent around perl "print <<EOF" constructs?
Message-Id: <x3yzoy4thkp.fsf@tigre.matrox.com>


Alex Ramos <iis4@my-deja.com> writes:

> Please reply to the newsgroup; I don't read e-mail very often.

WOW. I never ever expected to see this sentence!

--Ala



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

Date: Thu, 30 Sep 1999 18:05:25 GMT
From: John P Walsh <walsh@averstar.com>
Subject: Install CPAN module in ActiveState Windows version of Perl?
Message-Id: <37F3A664.74BCD012@averstar.com>

What is the procedure to install an CPAN module into an ActiveState Win
version of Perl? The PPM program provided by ActiveState appears to be
limited to modules available at the ActiveState site.

Pointers to a FAQ or web site would be appreciated.

Thanks in advance,
- John Walsh
  walsh@averstar.com





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

Date: 30 Sep 1999 19:11:13 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Install CPAN module in ActiveState Windows version of Perl?
Message-Id: <37F3B407.C4056FB2@vpservices.com>

John P Walsh wrote:
> 
> What is the procedure to install an CPAN module into an ActiveState Win
> version of Perl? The PPM program provided by ActiveState appears to be
> limited to modules available at the ActiveState site.

Well, not exactly true. You can change the repository location of ppm to
point to other sites that have .ppd files so you *can* use ppm to
install files not on the ActiveState site.

But there are also other files that are not in .ppd format and therefore
would need to be installed from CPAN.  Some of these need to be compiled
and so you'd need a c++ compiler.  Others only need to be made, so you
need a version of make such as microshlock's nmake.exe but not the
compiler.  Once you have nmake or its equivalent, you install the
(non-XS) CPAN modules the same way you do on any platform.

> Pointers to a FAQ or web site would be appreciated.

Both alternate site usage of ppm and use of nmake with CPAN modules are
covered in the help materials that come with ActiveState Perl.

-- 
Jeff


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

Date: Thu, 30 Sep 1999 18:37:05 GMT
From: stampede <stampede3@yourcompass.com>
Subject: memory differences reported by top and perl?
Message-Id: <7t0akg$e57$1@nnrp1.deja.com>

I'm running some scripts which iterate over a bunch of extremely large
BTrees.  Once I reach a certain point, I receive the "Out of memory!"
error, and the program dies.

1) When I watch 'top,' I see that only 15% of memory is being consumed
by my perl script; and of the total memory, there is always at least
640K (between 790K and 640K) free.

2) How can I conserve memory?  How can I have perl clean up
appropriately so that I can get through this 1 GB DB?

Thanks.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 30 Sep 1999 19:32:45 GMT
From: <shiloh@shell9.ba.best.com>
Subject: numeric sort on field 2 in @array...
Message-Id: <37f3badd$0$229@nntp1.ba.best.com>

I could not find this "exactly" in perfunc or perlfaq4.
I want to do a numeric sort only on field 2 of an @array.

Here is the data file:
cat junk11
fred 2
wilma 3 
larry 5
tom 4
barney 1
betty 1

Here is what I want to do in perl:
sort -rn +1 junk11
larry 5
tom 4
wilma 3 
fred 2
betty 1
barney 1

Here is the script (with section from perlfunc):
#!/usr/local/bin/perl5

open(INFILE,"junk11") || die "cannot open junk11 $!";
@array = <INFILE>;
 
@new = sort { field1($a) <=> field1($b) ||
                 field2($a) <=> field2($b) ||
                 field3($a) <=> field3($b)
               }     @array;
 
#@new = sort {$b <=> $a} @array;
 
print "================== \n";
 
foreach $item (@new){
  chomp($item);
  print "$item \n";
}

Here is the error:
Undefined subroutine &main::field1 called at ./junk78.pl line 6, <INFILE> chunk 6.

How do I numerically sort "only" on the second field?
How do I get rid of the "field1" error? 

thanks,


--Joe McCaughan | Great is the Lord, and greatly to be praised,
shiloh@best.com | And His greatness is unsearchable!           Psalm 145:3



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

Date: Thu, 30 Sep 1999 13:02:09 -0400
From: Steve Miles <smiles@wfubmc.edu>
Subject: Re: Perl - SQL examples
Message-Id: <37F39791.83E94BDC@wfubmc.edu>

Here's my favorite:

http://www.inlink.com/~perlguy/sql

Steve Miles
http://www.groundbreak.com



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

Date: Thu, 30 Sep 1999 12:13:22 -0700
From: "Tohru Kao" <tohru@bigfoot.com>
Subject: Perl module for Kerberos telnet 
Message-Id: <rv7db4333i540@news.supernews.com>

Hi,

I am new in Perl area.

Does any Perl module support "Kerberos Telnet"?
I know there are modules that support Kerberos and Telnet,

Is there any module that I can use "Kerberos telnet" in Perl?

It will be nice if someone can help me with an simple example.

TIA,
Tohru Kao





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

Date: Thu, 30 Sep 1999 19:44:57 GMT
From: Matt Sturtz <N0SPAM-msturtz@bcandid.com>
Subject: Perl5.005_03 on RedHAT 6.0
Message-Id: <37F3BE4E.273ED50B@bcandid.com>

Hi--

Has anybody seen any weirdness compiling Perl5 on RedHAT 6.0?  I'm using
a script that uses the dbmopen funtion (a POP-Before-SMTP hack).  The
Perl included with RedHAT didn't do this correctly, and when I compile
Perl from scratch, and run the test suite, I get an error:

<...>
pragma/warning.....ok
lib/abbrev.........ok
lib/anydbm.........FAILED at test 12
lib/autoloader.....ok
lib/basename.......ok
<...>
Failed 1 test script out of 190, 97.89% okay.
   ### Since not all tests were successful, you may want to run some
   ### of them individually and examine any diagnostic messages they
   ### produce.  See the INSTALL document's section on "make test".
   ### If you are testing the compiler, then ignore this message
   ### and run
   ###      ./perl harness
   ### in the directory ./t.
   ###
   ### Since most tests were successful, you have a good chance to
   ### get information with better granularity by running
   ###     ./perl harness
   ### in directory ./t.
u=0.6  s=0.35  cu=23.06  cs=5.39  scripts=187  tests=6732
make: *** [test] Error 1

This all worked just peachy under RedHAT 5.2...  Can anybody shed some
light on this?  I'm guessing they changed some library somewhere that
Perl needs...  RedHAT is good at that...  <sigh>

-Matt-
(remove "NO SPAM" to reply)



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

Date: 30 Sep 1999 18:05:40 GMT
From: sds@cts.com (Scott Sellers)
Subject: Re: Please compare and contrast C and Perl.
Message-Id: <slrn7v7a3q.1ej.sds@confab.home.org>

Neil <neil@pacifier.com>:
>> Really? The differences are obvious for those who know C and Perl.
>
Neil, please configure your newsreader so it provides an
attribution line at the top of quoted text.  It's also good to
include enough quoted text to provide some context to what one is
quoting.  In this case, I not only have to guess at who wrote the
above, but also what they were responding to.

>When you or someone else solves a problem for someone in this
>group the solution is often obvious to you but not the original
>poster. That something is obvious to you doesn't prevent you
>from posting about it. In this case, my question isn't a problem
>as in help, help I can't figure out how to do * but instead it
>is just an interest in learning more about Perl and C.
>
Focus on that (the topic + reasonable tangents) and you can
learn a lot here.  In fact, Abigail's initial response was chalk
full of meaning, if only in hinting at the absurdity of your
question.  You could have taken that for what it was worth, and
been better off.

>I would hope that a group such as this would be interested in
>general discussions initiated by beginners who are genuinely
>interested in learning more about Perl, and not just on solving
>specific programming problems. If the C and Perl comparison
>discussion is trivial, it is through my inexperience with both
>that I didn't realize it was trivial.
>
I think it's more that a simplistic question all but demanded
trivial answers.  That's going to be anathema to many people.
Keep asking questions, but don't expect to be spoonfed by
all of the people, all of the time.

>I hope I don't get plonked for this.
>
This is tiresome.

-- 
Scott Sellers  |  clpm lurker, more than a little PO'd that Tom C
(sds@cts.com)  |  isn't posting here anymore 


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

Date: 30 Sep 1999 13:36:27 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Pre-release Perl Beta-Testers
Message-Id: <x7so3wuwro.fsf@home.sysarch.com>

>>>>> "R" == RecruitSource  <examtesting@recruitsource.com> writes:

  R> Our company, http://www.recruitsource.com, is looking for people to
  R> beta-test an online technical testing system, which will soon be
  R> released to the public.  Specifically, we need people of various
  R> skill levels to take one or more timed, multiple-choice exams
  R> (including a Perl exam), and to comment on/criticize the exam as a
  R> whole, as well as on individual questions.

your tests suck. all online tests suck. all online certifications
suck. all recruiters who use tests suck. 

that is my feedback to you before and after taking your tests.

  R> There are currently over 50 exams in the RecruitSource database -
  R> if there are any other skills that you would like to try against
  R> our exam system, please let us know.

how about testing yourself for an above room temperature iq? just make
sure to set the thermostat to very cold.

don't post this crap here.

uri

(i am a certified perl quiz hacker having paid my $3 for a certificate
printed by ziggy)

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 30 Sep 1999 11:27:16 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Proble with chopped filenames from script
Message-Id: <x3y4sgcv2qz.fsf@tigre.matrox.com>


Malcolm Garbutt <mgarbutt@ozland.com.au> writes:

> I am using the script below to read a data file from within the script,
> which works fine until the line it reads has a + or - or _ in it.

The reason is that you match using (\w+) which matches a word
character. This icludes all the alphabet, all the numbers and the
underscore (_). It does not include the '+' or '-'.

> #!/usr/local/bin/perl -w
> 
> use strict;
> 
> # redefine the end-of-line marker
> # now every record is a line
> 
> $/ = "new\n";

This will make Perl read up to and including the word 'new' followed by
a new line.

With your given data, the first record read will contain the only the
word 'new' followed by a newline character. Perhaps you want to skip
that, or remove the first 'new' word.

> while ( <DATA> ) {
> 
>         # remove the end-of-line chars and if the line has words on
>         # it, get the first word for the filename
> 
>         chomp;
>         if ( m/(\w+)/ ) {

here. You should check what the \w+ matched. Do a:

	print "I matched '$1'.\n";

and see what you exactly matched. As I said, the above will not match
'a'+ or a '-'. You can solve this by changing it to:

	if (/(\S+)/) {

which says, match everything that is not a white space.

>                 open ( OUT, ">./email/$1" ) ||
>                         die "Could not open $1 for writing. $!.\n";
>                 print OUT;
>                 close ( OUT ) ||
>                         die "Could not close $1 after writing. $!.\n";
> 
>         }
> 
> }
> 
> __DATA__
> new
> a+b
> 1003456  blah
> 2345678 more blah
> (fun times)
> new
> super
> 123456 yeah
> 234567 more yeah

HTH,
--Ala



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

Date: 30 Sep 1999 14:10:24 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Proble with chopped filenames from script
Message-Id: <slrn7v7dsv.8i.abigail@alexandra.delanet.com>

Malcolm Garbutt (mgarbutt@ozland.com.au) wrote on MMCCXXI September
MCMXCIII in <URL:news:37F3079D.CBD5A1B6@ozland.com.au>:
"" 
"" Now the problem is that when it comes accross the 3 mentioned characters
"" (see above) in the first line (Filename to be) it will make a file
"" called a and b (See data below), where as I would like the line a+b to
"" be the file name, like the line bill would do.

It makes files `a' *and* `b'? Are you really, really sure? Because that
doesn't make sense, as you only create one file per line. I do not see
a problem with `_' either. As for `+' and `-', look up what \w means.
You will see that it doesn't include `+' or `-'.



Abigail
-- 
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 30 Sep 1999 13:44:55 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Proble with chopped filenames from script
Message-Id: <x3y3dvwuwdl.fsf@tigre.matrox.com>


"Peter Icaza" <picaza@chsi.com> writes:

> \w+ will match 1 or more word characters, [+-_] are not word characters
> [a-zA-Z0-9], depending on locale.

No. An underscore is a word character. '+' and '-' aren't.

--Ala



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

Date: Thu, 30 Sep 1999 19:11:13 +0100
From: "Cut and Paste Scripts" <cutandpastescripts@exl.co.uk>
Subject: Problem with list!
Message-Id: <PaPI3.4748$gE.123521@stones>

Hi,

Here is my problem, does anyone has a solution.  I have a value called
$usernames which is a list of usernames people have chosen formatted like
$usernames = "myname, nextname, nameafter"; and so on.

I want to create a HTML page which contains all the usernames, formated in a
form like this -

<HTML>
<BODY>
<FORM>
<INPUT TYPE=CHECKBOX VALUE="myname">myname
<INPUT TYPE=CHECKBOX VALUE="nextname">nextname
<INPUT TYPE=CHECKBOX VALUE="nameafter">nameafter

and so on.  Is this possable?  I do not know the number of usernames, the
usernames etc.  Any ideas?

Thanks,

Graeme :-)




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

Date: Thu, 30 Sep 1999 11:49:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Problems compiling perl
Message-Id: <Pine.GSO.4.10.9909301148430.17231-100000@user2.teleport.com>

On Wed, 29 Sep 1999, Anas Mughal wrote:

> When I try compiling a simple Perl script, I get the error that it
> fails to find 0.pm. 

If perl is giving you an error message which is not described in the
perldiag manpage, please file an appropriate bug report. Thanks!

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



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

Date: Thu, 30 Sep 1999 13:13:21 -0400
From: HHH <hartleh1@westat.com>
Subject: Re: Q: Syntax to open a file in PERL on an NT server
Message-Id: <37F39A31.DAC00C5D@westat.com>



Alex Rhomberg wrote:
> or on MS products, it should be something like
> C:\Micros~1\window~1\webser~1\datadi~1

And I think you need to escape backslashs thusly:

C:\\Micros~1\\window~1\\webser~1\\datadi~1

which makes using "frontslashes" look more attractive.

HHH


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

Date: Thu, 30 Sep 1999 19:21:10 GMT
From: necr0mancer@myremarq.com (Necromancer)
Subject: Re: Q: Syntax to open a file in PERL on an NT server
Message-Id: <3875b629.98891198@news>

Thanks to all who have contributed information.  I have found the
syntax that works.  The file resides (physically) at:

d:\www\client\data\data.txt

so, the correct way to open it (keeping ActiveState in mind) is:

OPEN (DATAIN, "</www/client/data/data.txt") or die "Error! $!";

(I don't know where the file resides mentally...)

 ...now I'm dealing with permissions on the files so they can be
overwritten.  I've got a handle on this one, though!

Thanks!


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

Date: Thu, 30 Sep 1999 12:42:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q: Syntax to open a file in PERL on an NT server
Message-Id: <MPG.125d5ce4454b98e98a009@nntp.hpl.hp.com>

In article <3875b629.98891198@news> on Thu, 30 Sep 1999 19:21:10 GMT, 
Necromancer <necr0mancer@myremarq.com> says...
> Thanks to all who have contributed information.  I have found the
> syntax that works.  The file resides (physically) at:
> 
> d:\www\client\data\data.txt
> 
> so, the correct way to open it (keeping ActiveState in mind) is:
> 
> OPEN (DATAIN, "</www/client/data/data.txt") or die "Error! $!";

Why do you assume that your current drive is D: ?  That is still a 
relative path, not an absolute path.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 30 Sep 1999 12:10:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Q:post-compile testscripts fail
Message-Id: <Pine.GSO.4.10.9909301208290.17231-100000@user2.teleport.com>

On Tue, 28 Sep 1999, Roman Legat wrote:

> I tried to compile Perl (which worked fine) but the testsuite won't run
> completely, three tests always fail, the rest works.
> The tests that fail are getopt, dup and io_dup.
> They all fail when trying to close a file, 

Sounds as if Perl's Configure program has guessed something wrong about
your system's close() function, maybe. If you can't find the problem, you
may need to check with someone who knows about your OS. Good luck!

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



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

Date: 29 Sep 1999 21:28:58 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Question from a starter
Message-Id: <7su0aq$220$1@gellyfish.btinternet.com>

On Wed, 29 Sep 1999 12:12:53 -0700 David Cassell wrote:
> Jonathan Stowe wrote:
> [snip]
>> @name = (
>>           ["blah","woof"],
>>           ["plio","roow"],
>>           ["zippey","dippey"]
>>         );
>> 
>> print $name[3][0]; # zippey
> 
> Funny, I would have said:
> 
>     print $name[2][0];
> 
> Nit 1, Perl 2,

Ooo yes - deranged by Informix 4GL I'm afraid ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 953
*************************************


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