[16580] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3992 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 11 18:16:03 2000

Date: Fri, 11 Aug 2000 15:15:48 -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: <966032147-v9-i3992@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 11 Aug 2000     Volume: 9 Number: 3992

Today's topics:
    Re: Perl code for a newbie!! <abe@ztreet.demon.nl>
    Re: Perl code for a newbie!! <abe@ztreet.demon.nl>
    Re: Perl code for a newbie!! <abe@ztreet.demon.nl>
    Re: Perl mods for MySQL <alesr@siol.net>
        Perl on NT connect to SQL Server lancepr@my-deja.com
    Re: perl program running with cgi extension <drawbridge@home.com>
    Re: perl program running with cgi extension <flavell@mail.cern.ch>
    Re: perl program running with cgi extension <drawbridge@home.com>
        Perl, MS Exchange and E-mail problems <efedlegend@earthlink.net>
    Re: problems with ^= (Anno Siegel)
    Re: Regex help <tim@ipac.caltech.edu>
    Re: Regex help <abe@ztreet.demon.nl>
    Re: Simple Argument Passing Question <tim@ipac.caltech.edu>
        Trouble with example <studentfl@hotmail.com>
    Re: Trouble with example <newsposter@cthulhu.demon.nl>
    Re: Were are all the executibles? <juex@deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 11 Aug 2000 21:19:59 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Perl code for a newbie!!
Message-Id: <g9k8psckt33hdk6k5bem6r7b8q8mhfev3t@4ax.com>

On Fri, 11 Aug 2000 14:24:01 GMT, kcivey@cpcug.org (Keith Calvert Ivey)
wrote:

> "Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote:
> 
> >I keep getting this error message:
> >
> >delete argument is not a HASH element or slice at linecutter.pl line 17.
> 
> And?  Do you have a suggestion for how the error message could
> be made any clearer?  Presumably it's referring to this line:
> 
> >> > >     delete ($file[$linenum]);
> 
> And (surprise!) it's complaining that the argument to delete
> there is not a hash element or slice (it's an array element).
> Read the documentation for the delete() function.  Then try the
> splice() function.

Upgrade! perldoc -f delete:

  delete EXPR
          Given an expression that specifies a hash element, array
          element, hash slice, or array slice, deletes the specified
          element(s) from the hash or array. In the case of an array, if
          the array elements happen to be at the end, the size of the
          array will shrink to the highest element that tests true for
          exists() (or 0 if no such element exists).


-- 
Good luck,
Abe


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

Date: Fri, 11 Aug 2000 21:52:08 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Perl code for a newbie!!
Message-Id: <b3l8pss4rq6em4itr9ccbhqpr79nstcp7o@4ax.com>

On Fri, 11 Aug 2000 10:36:41 -0700, Larry Rosler <lr@hpl.hp.com> wrote:

> [In the future, please use the Subject to describe your problem, not 
> yourself.  Using 'newbie' in the Subject has already caused innumerable 
> newsreaders to filter you away.]
> 
 ...
> I already pointed to perlfaq5: "How do I change one line in a 
> file/delete a line in a file/insert a line in the middle of a 
> file/append to the beginning of a file?"
> 
> Tucked in there is a way to do this job with a single command:
> 
>     perl -i -ne 'print unless $. == 5' /home/user/directory/*
> 
> which strips the fifth line out of every file in the directory.  
> (Replace the single-quotes by double-quotes for Windows/DOS.)
> 
> As warned in the FAQ (but not in the Perl documentation!),
> 
>   Note that -i may require a suffix on some non-Unix systems;
>   see the platform-specific documentation that came with your port.
> 

Well, the glob thing doesn't work either from the command line, although
it should.

This is perl, v5.6.0 built for MSWin32-x86-multi-thread (613)

-- 
Good luck,
Abe


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

Date: Fri, 11 Aug 2000 23:13:32 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Perl code for a newbie!!
Message-Id: <qfp8psceqrm10lmfp8pd2jp8uj0nhnep89@4ax.com>

On Fri, 11 Aug 2000 10:36:41 -0700, Larry Rosler <lr@hpl.hp.com> wrote:

 ...
> Tucked in there is a way to do this job with a single command:
> 
>     perl -i -ne 'print unless $. == 5' /home/user/directory/*
>
Nope.
 
From perlop:

  You can modify @ARGV before the first <> as long as the array ends up
  containing the list of filenames you really want. Line numbers (`$.')
  continue as though the input were one big happy file. See the example
  in the eof entry in the perlfunc manpage for how to reset line numbers
  on each file.


	perl -i -ne 'print unless $. == 5; close ARGV if eof' ./*

And I ran into loads of trouble trying that on a Win32 box.

-- 
Good luck,
Abe


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

Date: Fri, 11 Aug 2000 23:27:25 +0200
From: marvin <alesr@siol.net>
Subject: Re: Perl mods for MySQL
Message-Id: <39946FBD.AC8@siol.net>

Bart Lateur wrote:
> 
> <((>< <yamar420@my-deja.com> wrote:
> 
> >Everytime I try
> >to untar the Mysql bin file it tells my it has a checksum error. After
> >looking around I found notes stating that I needed to load GNUtar. I
> >have since then installed it, but still have problems untarring the
> >file. Does anyone know how to correct this ?
> 
> I think you've got a corrupt file. Try downloading it again.
> 
> --
>         Bart.
You need GNU tar, not regular one. It is mentioned that on their
download page.


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

Date: Fri, 11 Aug 2000 18:58:48 GMT
From: lancepr@my-deja.com
Subject: Perl on NT connect to SQL Server
Message-Id: <8n1id4$17i$1@nnrp1.deja.com>

I am running active perl and need to connect to
my SQL server using filedsn.
The filedsn seems to be my hang up.
Are their any good books or websites that will
help me connect to SQL server?

Thanks

Lance


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


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

Date: Fri, 11 Aug 2000 18:20:23 GMT
From: DM <drawbridge@home.com>
Subject: Re: perl program running with cgi extension
Message-Id: <39944440.3DA90CEB@home.com>

I feel that the question IS a Perl related question.  Some of us don't
use CGI.pm, which I personally don't like CGI.pm.

If you want to get into what does and doesn't belong on this discussion
group, I suggest starting with getting on peoples case as ones to
remove. Good luck.

___James

Free Code... You get what you pay for...

"Alan J. Flavell" wrote:
> 
> On Fri, 11 Aug 2000, DM demonstrated the usual properties of those who
> post upside-down to usenet.  It's off-topic for this group too, though
> there are some details that fall into Perl's bailliewick...
> 
> > Yes, I also had this problem.  If you are creating HTML,  you need to
> > print:
> >
> > print "HTTP/1.0 200 OK\n";
> 
> Please review the CGI specification before offering further answers of
> this nature.  This CGI response is invalid from normal (parsed-header)
> scripts.  Non-parsed-header (nph) scripts on the other hand are
> required to return a complete and accurate HTTP response, for which
> your HTTP part would be correct: but then, "\n" is in general wrong,
> since the HTTP specification mandates precisely a carriage return
> followed by a linefeed, whereas "\n" stands for Perl's platform-
> dependent newline representation, which isn't necessarily the same
> thing.  It just so happens that if you are working in text mode on MS
> Windows, the result will come out right, but there are better (i.e
> more portable) ways to work - specifically, using CGI.pm instead of
> trying to hand-knit it.


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

Date: Fri, 11 Aug 2000 20:35:41 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: perl program running with cgi extension
Message-Id: <Pine.GHP.4.21.0008112024490.14931-100000@hpplus03.cern.ch>


On Fri, 11 Aug 2000, DM quoted my entire followup, about which he
apparently had no technical contribution whatever, in order to assert
the usual litany:

> I feel that the question IS a Perl related question. 

Usenet custom is that discussions belong on the most relevant group.
Since there is a WWW CGI group, and the discussion is primarily about
CGI and not about Perl programming language issues, the conclusion
seems obvious.

> Some of us don't use CGI.pm, which I personally don't like CGI.pm.

So you prefer to get wrong answers, and share those wrong answers with
others, in preference to software which you don't like but which does
things correctly (or at least when discrepancies are found, they get
fixed, and everyone can benefit).

> If you want to get into what does and doesn't belong on this discussion
> group, I suggest starting with getting on peoples case as ones to
> remove.

I guess that was meant as an application to join some killfiles.

I always have mixed feelings about that.  Some people are just too
dangerous to be ignored.  But as long as you continue with upside-down
fullquoting, I guess it's OK.

> Free Code... You get what you pay for...

I'll take the liberty of presuming to speak for for some of the
regulars here too, in saying that some of us take more pride in our
contributions than seems to be implied in your comment.


[jeopardectomy, and scorefile adjusted.]



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

Date: Fri, 11 Aug 2000 19:06:52 GMT
From: DM <drawbridge@home.com>
Subject: Re: perl program running with cgi extension
Message-Id: <39944F25.6D840486@home.com>

Get a hobby.

"Alan J. Flavell" wrote:
> 
> On Fri, 11 Aug 2000, DM quoted my entire followup, about which he
> apparently had no technical contribution whatever, in order to assert
> the usual litany:
> 
> > I feel that the question IS a Perl related question.
> 
> Usenet custom is that discussions belong on the most relevant group.
> Since there is a WWW CGI group, and the discussion is primarily about
> CGI and not about Perl programming language issues, the conclusion
> seems obvious.
> 
> > Some of us don't use CGI.pm, which I personally don't like CGI.pm.
> 
> So you prefer to get wrong answers, and share those wrong answers with
> others, in preference to software which you don't like but which does
> things correctly (or at least when discrepancies are found, they get
> fixed, and everyone can benefit).
> 
> > If you want to get into what does and doesn't belong on this discussion
> > group, I suggest starting with getting on peoples case as ones to
> > remove.
> 
> I guess that was meant as an application to join some killfiles.
> 
> I always have mixed feelings about that.  Some people are just too
> dangerous to be ignored.  But as long as you continue with upside-down
> fullquoting, I guess it's OK.
> 
> > Free Code... You get what you pay for...
> 
> I'll take the liberty of presuming to speak for for some of the
> regulars here too, in saying that some of us take more pride in our
> contributions than seems to be implied in your comment.
> 
> [jeopardectomy, and scorefile adjusted.]


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

Date: Fri, 11 Aug 2000 19:53:53 GMT
From: "Brian Walker" <efedlegend@earthlink.net>
Subject: Perl, MS Exchange and E-mail problems
Message-Id: <lRYk5.1295$FY4.46206@newsread1.prod.itd.earthlink.net>

Greetings

I need to develop a Perl script that sends mail through a form on the
company's MS Exchange Server.  I don't know a lot about Perl, especially
operating in a Windows environment.

Here's what I need done, pretty simple:

There are 3 main boxes on this form.

-A "From" box where the user types anything in.
-A Drop-down box that contains a listing of employees that can be paged.
The values are set up like this : < option value = "phonenumber@paging
alias"> Employee Name</option>
-A message box for the user to type in the message.

I need the script to read the data in the from box, the value (Mail address)
in the drop-down box and the text in the message box, then have it send it
in an e-mail to the value in the drop-down box.

There will be several employees listed in any one box.  How do I accomplish
this?

Any help appreciated
Brian




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

Date: 11 Aug 2000 18:10:46 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problems with ^=
Message-Id: <8n1fj6$985$1@lublin.zrz.tu-berlin.de>

Larry Rosler  <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>In article <8n0qk2$8gs$1@lublin.zrz.tu-berlin.de> on 11 Aug 2000 
>12:12:50 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...

[...]

>> [1] Well, obviously I haven't wondered often enough to go and check.
>
>Neither have I.  Especially as the result is undefined. 

How comforting.  There's no need to check :)

Anno


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

Date: Fri, 11 Aug 2000 11:36:09 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Regex help
Message-Id: <39944799.B9627A51@ipac.caltech.edu>

Jody Fedor wrote:
>         I'm looking for some help on a regex to parse the sample data
> below.  There are always 2 spaces after the name or a cr and #.

We call '\n' newlines. Carriage returns are '\r'.

> I would like to eliminate all data between the name and phone number.  I
> want to keep the cr after the phone number but I don't want cr's in between
> names and numbers.

I just can't resist an RE challenge! The code below produces:

A Affordable Septic Service  503 682-1929:
A Better Spa Service  503 263-7727:
A To Z Rental Centers  503 370-9303:  503 585-7782:
Alluis Todd Excavation Inc  503 873-4347:
Allstate Insurance Companies  503 982-6619:  503 981-9507:  503 981-3201:

To pay the newsgroup back for our help, promise that you'll pull the code apart
and understand it by fully ingesting the perlre document (and maybe perlvar). 

Otherwise I'd feel horribly used.

-- Tim

#! /usr/bin/perl -wl
use strict;
$_ = join("",<DATA>); # I prefer this to $'=undef;
my $phonere = '(?:\d\d\d)? \d\d\d-\d\d\d\d';
s/\n#+.*?($phonere)/  $1:/sg;
s/^(\S.*?)(  |\n#+).*?(?=$phonere)/$1  /mg;
print;
__DATA__
A Affordable Septic Service
#PO Box 1130  Wilsonville 503 682-1929
A Better Spa Service  Canby 503 263-7727
A To Z Rental Centers
#3362 Silverton Rd NE  Salem 503 370-9303
#995 Commercial SE  Salem 503 585-7782
Alluis Todd Excavation Inc
#Silverton 503 873-4347
Allstate Insurance Companies
#Sales Offices
##Woodburn
###1585-M N Pacific Hwy  Woodburn 503 982-6619
###612 Glatt Cir  Woodburn 503 981-9507
###983 Oregon Way  Woodburn 503 981-3201

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Fri, 11 Aug 2000 20:52:34 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Regex help
Message-Id: <ijg8pskol2mvpu3lh99v1k4ge0qp6sge9d@4ax.com>

On Fri, 11 Aug 2000 11:51:42 -0400, "Jody Fedor" <Jodyman@usa.net>
wrote:

> Hello,
> 
>         I'm looking for some help on a regex to parse the sample data
> below.  There are always 2 spaces after the name or a cr and #.
> I would like to eliminate all data between the name and phone number.  I
> want to keep the cr after the phone number but I don't want cr's in between
> names and numbers.
>         The data exists in $listing.  I've tried:
> (each regex is done in this order)
> $listing =~ s/\n\#/  /g;  # Remove all cr & tabs

As these lines seem to start with one or more hashes:

	$listing =~ s/\n#+/  /g; #replace with two spaces

> $listing =~ s/\s+\d+ \w+.*(\d\d\d\s\d\d\d-\d\d\d\d)/:$1/g;  #any num of
> spaces followed by any number of numbers and any words to area code and
> phone number and replace with :phone number

	$listing =~ s/(?:  .+?)(\d{3} \d{3}-\d{4})/:$1/g;

The bits you want removed should start with two spaces, so the pattern
should also start with two spaces, followed by one or more characters
[together grouped for clarity with (?:)], followed by your phone-number
pattern.

> $listing=~ s/\#+//g;  # remove all #'s

No need for this as it was done in the first substitution.

-- 
Good luck,
Abe


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

Date: Fri, 11 Aug 2000 12:07:51 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Simple Argument Passing Question
Message-Id: <39944F07.DE407E84@ipac.caltech.edu>

Kenny Lim wrote:
> 
> I would like to be able to pass the argument (See below) in the command
> prompt to run my process and are wondering is someone can provide some quick
> pointers to this
> problem.
> 
> (a) Target Drive  #(Works Fine!)
> (b) Name of the Project (Most project are independent by itself except for
>       Embarcadero_Project)
> 
> ie. Perl test1.pl - d d: -p $DBArtisan
> or
> ie Perl test1.pl -d d: -p $@Embarcadero_Projects

Being blissfully ignorant of what DOS/Windows will do to $@Embarcadero_Projects,
I'll ignore that issue ...

So you want to pass the name of a variable, which could be either a scalar or an
array, to your perl program from the command line? I'll give you the clues you
need below, but before I do, may I suggest you rethink this strategy? Why not
simply pass in a key word which will be tested in the script, like this:

% test1.pl -d d: -p embarc
test1.pl fragment (untested):
  my $drive = $opt_d || "d:";
  my $proj  = $opt_p || "embarc";
  my (@embarc) = qw(xxx yyy zzz);
  my $artisan  = "www";
  my %projects = (embarc=>\@embarc, art=>\$artisan);
  my $doproj = $projects{$proj} || die "Unknown project '$proj'";

See? Now read perlref to see how to use $doproj.

To answer your question, you need to eval the input var. name. 'perldoc -f
eval'. Here's a one-liner for you to contemplate:

% perl -le '@b=(1,2,3); $z="\@b"; @a = eval "($z)"; print "@a";'
1 2 3

-- Tim

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Fri, 11 Aug 2000 21:12:41 GMT
From: "Robert Brooks" <studentfl@hotmail.com>
Subject: Trouble with example
Message-Id: <d%Zk5.37891$eS6.709786@news1.rdc1.md.home.com>

I was going through a perl book, and am having trouble getting one of the
examples to work. It is right out of the book (Learning Perl):

 open (WORDSLIST, "wordslist") || die "can't open wordlist: $!";
 while ( defined ($name = <WORDSLIST>)) {
  chomp ($name);
  $word = <WORDSLIST>;
  chomp ($word);
  $words{$name} = $word;

 }
 close (WORDSLIST) || die "couldn't close wordlist: $!";

The problem is, $name doesn't make it past this line:
  $word = <WORDSLIST>;

I don't understand what is wrong. A mistake in the book, but how do I fix
it? Thanks






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

Date: 11 Aug 2000 21:39:03 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Trouble with example
Message-Id: <8n1rpn$ljv$1@internal-news.uu.net>

Robert Brooks <studentfl@hotmail.com> wrote:
> I was going through a perl book, and am having trouble getting one of the
> examples to work. It is right out of the book (Learning Perl):

[snip]

> The problem is, $name doesn't make it past this line:
>   $word = <WORDSLIST>;

> I don't understand what is wrong. A mistake in the book, but how do I fix
> it? Thanks

  The code itself is OK. I think it is your input file. The code always
reads lines in pairs. Your input file probably has an odd number of lines.
Count those end-of-line's carefully ...

Erik



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

Date: Fri, 11 Aug 2000 11:43:16 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Were are all the executibles?
Message-Id: <39944944@news.microsoft.com>

"Tony L. Svanstrom" <tony@svanstrom.com> wrote in message
news:1ef7o0l.1wycog314auixbN%tony@svanstrom.com...
> But what if someone invented like a virtual machine, so you can run them
> on a single platform, but at the same time on different platforms...
> Hmmm... I think I better patent/copyright this before I send it... damn,
> I've already pushed the send-button... Oh, well, I guess this great idea
> is out now. ;-)

That idea has been around a while, oh, let's say since the mid 70s?
Ever heard of e.g. the UCSD Pascal system? Became quite famous on the Apple
II.

jue




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

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


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