[7789] in Perl-Users-Digest
Perl-Users Digest, Issue: 1414 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 5 07:07:16 1997
Date: Fri, 5 Dec 97 04:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 5 Dec 1997 Volume: 8 Number: 1414
Today's topics:
Re: 001 + 1 = 002; 002 - 1 = 1 ARGH (Mike Stok)
Re: 001 + 1 = 002; 002 - 1 = 1 ARGH (brian d foy)
Re: 001 + 1 = 002; 002 - 1 = 1 ARGH (Roy S. Rapoport)
Re: 001 + 1 = 002; 002 - 1 = 1 ARGH (Tad McClellan)
[Fwd: "use lib $lib_path" doesn't work] <emaneiro@bigfoot.com>
[JOB] Software Engineers California/Colorado <elizabeth.munn@Eng.Sun.COM>
Re: Alarm not working (Charles DeRykus)
Re: Best match in perl? <bowlin@sirius.com>
Re: calling C libraries from Perl and calling Perl libr <bowlin@sirius.com>
DBI, DBD::Oracle, Oraperl.pm <prl2@lehigh.edu>
Email Manipulation Quandry jklyne@med.osd.mil
Re: Getting rid of non-Y2K Perl4 (was Re: Pattern match (Mike Stok)
Re: grep <dgwilson@gte.net>
Re: How do I print all but the first variable in an arr <zenin@best.com>
Re: How do I print all but the first variable in an arr (Tad McClellan)
Re: How do I print all but the first variable in an arr yong_huang@fmc.com
Re: How do I print all but the first variable in an arr <dgwilson@gte.net>
looking for perl plotting interface <ceh@sunspot.sce.carleton.ca>
Modifying an array which has been passed in by name ... (Narayan Moni)
Re: Newbie question. Do you recommend moving from C? lvirden@cas.org
Re: Pattern matching (or not....) (Martien Verbruggen)
Re: Perl editor needed (Hans Juergen von Lengerke)
Re: Perl scripts to lookout for?? <zenin@best.com>
Re: Perl scripts to lookout for?? <webmaster@fccj.cc.fl.us>
Re: Perl4 is not Y2K (was Re: Forced to use brain-dead (Andrew M. Langmead)
Re: Processing of Postscript files with included EPS-fi <rootbeer@teleport.com>
Re: Q: lambda fun, loop, string to expr (Ilya Zakharevich)
Re: Q: lambda fun, loop, string to expr (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Question for people who know perl&html yong_huang@fmc.com
return value of system (Umm)
Re: returning value of executed program <fbelli@ctp.com>
Rounding functions for perl? (Allen Dale Hutchison)
Re: Rounding functions for perl? <tycage@infi.net>
Re: Rounding functions for perl? (brian d foy)
Re: Rounding functions for perl? <tycage@infi.net>
Re: Rounding functions for perl? (brian d foy)
Re: small problem with perl INSTALL <rootbeer@teleport.com>
trying to understand arrays of hashes (John Dubchak)
URGENT- need perl script for winNT -to process generic <mike-s@home.com>
Re: Using Excel95 with Perl (Jim Michael)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Dec 1997 20:08:08 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: 001 + 1 = 002; 002 - 1 = 1 ARGH
Message-Id: <664e78$5oc@news-central.tiac.net>
only the ++ operator is magical in that it deals sensibly with strings, if
you want to decrement an all numeric suffix then you might consider using
sprintf e.g.
$suffix = '002';
$suffix--;
$suffix = sprintf '%03d', $suffix;
If you have to work with mixed strings of letters & digits then you might
consider breaking them up into components and using something like sprintf
to glue the bits together.
This is perl, there is more than one way to do it, other people have
probably got better ways...
Hope this helps,
Mike
In article <664ceh$2n9$1@shell3.ba.best.com>,
Roy S. Rapoport <rsr@best.com> wrote:
>Gosh, was that clear enough? :)
>
>I'm trying to do a log rotation program that takes as one of its args the
>type of suffix you should have on the file. For example, if given 001, it
>should then rotate files to
>file -> file.001
>file.001 -> file.002
>
>etc.
>
>Now, going up is great -- Perl is wonderful in doing 'the right thing' (I think
>it's the right thing, at least) and, when given 001 + 1, returning 002.
>
>The problem is that I haven't found a way to do 002 - 1 = 001. In other words,
>given
>
>$a = "001" ;
>$a++ ;
>
>$a is now equal to "002"; but if I now do
>$a-- ;
>$a is now equal to 1!
>
>Any way around it?
>
>-roy
>
>
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Wed, 03 Dec 1997 15:29:35 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: 001 + 1 = 002; 002 - 1 = 1 ARGH
Message-Id: <comdog-ya02408000R0312971529350001@news.panix.com>
In article <664ceh$2n9$1@shell3.ba.best.com>, rsr@best.com (Roy S. Rapoport) wrote:
>$a = "001" ;
>$a++ ;
>
>$a is now equal to "002"; but if I now do
>$a-- ;
>$a is now equal to 1!
>
>Any way around it?
use sprintf() to put leading zeroes in front of your numbers:
$a = sprintf( "%03d", $a - 1 );
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 3 Dec 1997 12:28:58 -0800
From: rsr@best.com (Roy S. Rapoport)
Subject: Re: 001 + 1 = 002; 002 - 1 = 1 ARGH
Message-Id: <664fea$i23$1@shell3.ba.best.com>
Mike Stok <mike@stok.co.uk> wrote:
>only the ++ operator is magical in that it deals sensibly with strings, if
>you want to decrement an all numeric suffix then you might consider using
>sprintf e.g.
>
> $suffix = '002';
> $suffix--;
> $suffix = sprintf '%03d', $suffix;
>
>
>If you have to work with mixed strings of letters & digits then you might
>consider breaking them up into components and using something like sprintf
>to glue the bits together.
Thanks, I checked the book and indeed only the ++ op is magical (I wonder
why?).
Since the intent was to use whatever suffix form the user wants (in other
words, 3-digit numbers were just as an example), I don't know beforehand what
the format of the suffix would be so breaking it up would be difficult.
Given the fact that I essentially start at the lowest suffix, go up, then go
down again, what I decided to do was rather than use decrementin, I created a
list containing the suffixes in rising order, so after I figure out what all my
suffixes are I have a list of the form
(001, 002, 003, 004)
or
(00a, 00b, 00c)
or whatever ...
And then I can 'decrement' by just looking at the element before the current
one.
Thanks for your help!
-roy
------------------------------
Date: Wed, 3 Dec 1997 14:28:56 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: 001 + 1 = 002; 002 - 1 = 1 ARGH
Message-Id: <8ef466.lj2.ln@localhost>
Roy S. Rapoport (rsr@best.com) wrote:
: Gosh, was that clear enough? :)
: I'm trying to do a log rotation program that takes as one of its args the
: type of suffix you should have on the file. For example, if given 001, it
: should then rotate files to
: file -> file.001
: file.001 -> file.002
: etc.
: Now, going up is great -- Perl is wonderful in doing 'the right thing' (I think
: it's the right thing, at least) and, when given 001 + 1, returning 002.
This is known as 'magic autoincrement'
>From the 'perlop' man page:
------------------
=head2 Auto-increment and Auto-decrement
"++" and "--" work as in C. That is, if placed before a variable, they
increment or decrement the variable before returning the value, and if
placed after, increment or decrement the variable after returning the value.
The auto-increment operator has a little extra builtin magic to it. If
you increment a variable that is numeric, or that has ever been used in
a numeric context, you get a normal increment. If, however, the
variable has been used in only string contexts since it was set, and
has a value that is not null and matches the pattern
C</^[a-zA-Z]*[0-9]*$/>, the increment is done as a string, preserving each
character within its range, with carry:
print ++($foo = '99'); # prints '100'
print ++($foo = 'a0'); # prints 'a1'
print ++($foo = 'Az'); # prints 'Ba'
print ++($foo = 'zz'); # prints 'aaa'
The auto-decrement operator is not magical.
------------------
: The problem is that I haven't found a way to do 002 - 1 = 001. In other words,
: given
: $a = "001" ;
^ ^
^ ^ a string, because you put it in double quotes
So, it "has been used in only string contexts since it was set"
: $a++ ;
: $a is now equal to "002"; but if I now do
magic at work.
: $a-- ;
: $a is now equal to 1!
Note the last sentence in the quote.
: Any way around it?
Several, of course.
1) Use them as numbers, rather than strings, and use sprintf() to
pad with leading zeros.
2) Write your own decrement():
sub decrement {
my $num = shift;
return sprintf("%03d", $num-1);
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 03 Dec 1997 23:58:33 +0100
From: Emilio Maneiro Marquez <emaneiro@bigfoot.com>
Subject: [Fwd: "use lib $lib_path" doesn't work]
Message-Id: <3485E419.F041CE75@bigfoot.com>
This is a multi-part message in MIME format.
--------------F28E24CA62DB55E4BE5C3417
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Hello...
I wanted to read from a file the path where my packages are and pass a
variable to the "use lib" statement but it doesn't work.
=
my $lib_path =3D "/usr/acct/x/lib";
use lib $lib_path;
use my_package;
=
This script would return:
"Can't locate my_package.pm in @INC"
Can this be done? :-?
--
----------------------------
Emilio Maneiro Marquez
e-mail: emaneiro@bigfoot.com
Huelva. Espa=F1a.
--------------F28E24CA62DB55E4BE5C3417
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-ID: <3485E375.33BA9EE1@bigfoot.com>
Date: Wed, 03 Dec 1997 23:55:49 +0100
From: Emilio Maneiro Marquez <emaneiro@bigfoot.com>
X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; uuencode=0; html=0; linewidth=0
X-Mailer: Mozilla 4.03 [en] (X11; I; Linux 2.0.27 i586)
MIME-Version: 1.0
Newsgroups: comp.lang.perl.misc
Subject: "use lib $lib_path" doesn't work
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Hello...
I wanted to read from a file the path where my packages are and pass a
vriable to the "use lib" statement but it doesn't work.
my $lib_path =3D "/usr/acct/x/lib";
use lib $lib_path;
use my_package;
This script would return:
"Can't locate my_package.pm in @INC"
Can this be done? :-?
-- =
----------------------------
Emilio Maneiro Marquez
e-mail: emaneiro@bigfoot.com
Huelva. Espa=F1a.
--------------F28E24CA62DB55E4BE5C3417--
------------------------------
Date: Wed, 03 Dec 1997 12:09:29 -0800
From: "Sun Microsystems, Inc." <elizabeth.munn@Eng.Sun.COM>
Subject: [JOB] Software Engineers California/Colorado
Message-Id: <3485BC79.A14BE46F@Eng.Sun.COM>
Sun Microsystems, Inc. is hiring software engineers!
Title: Software Engineers
Location: US-CO-Boulder/Broomfield and US-CA-SF Bay Area
Keywords: Java, Perl, C/C++, Unix, Object-Oriented Programming,
Internet Technology
If you consider yourself to be a sophisticated programmer
or Java engineer, and want to work for the company that invented
Java, we want to talk to you.
Come and work on leading edge applications being developed by the
Worldwide
Service Technology Engineering team. This team is focused on researching
and
implementing Leading Edge Technologies that can be applied into Sun's
customer
base. Many of the applications developed are Java-based, use Artificial
Intelligence Technology, and are implemented on the latest development
API's
available. Openings are available in the areas of Remote Diagnostics,
Online Services, and CTI.
* Demonstrated skills in Java, Perl, C/C++, Unix, Object-oriented
programming
are needed.
* Positions are available from 1-2 years to 5+ years of experience.
* Email your resumes to elizabeth.munn@eng.sun.com (reference code
NET129733)
------------------------------
Date: Wed, 3 Dec 1997 20:00:43 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Alarm not working
Message-Id: <EKMq98.Hxp@bcstec.ca.boeing.com>
In article <34839EE1.BC0DA1E5@vais.net>, Ed Finch <efinch@vais.net> wrote:
> There is a loop around this code that processes directories on multiple
> servers. This code is supposed to verify that each server is up and the
> directory is accessible before trying to process it, in order to avoid
> hangs:
>
> print "$home_dir\n";
> # Make sure the host is alive
> $SIG{'ALRM'} = sub { print "died\n"; die } ;
> alarm(5);
> $ret = 0;
> eval <<'EOM' ;
> # system("cd $home_dir");
> # stat($home_dir);
> # -d $home_dir;
> $ret = 1;
> EOM
> alarm(0);
> if ($ret == 0) {
> print "$host is unreachable\n";
> next;
> }
>
> Of the 3 commented-out lines, only the "system..." one works. The other
> 2 are not terminated by the alarm.
>
> Why don't they work?
> Is there a better way to do this? I'm processing >1000 directories, and
> the system() calls are slow.
>
Use the block eval form to trap the error - man perlipc or
perldoc -f eval.
Here's something that'll give yu a start:
eval {
local $SIG{__DIE__} = 'DEFAULT';
local $SIG{ALRM} = sub { die "alarm clock: $home_dir" };
alarm 5;
-d $home_dir or die "not a directory: $home_dir";
};
alarm 0;
if ($@ =~ /^(?:alarm clock|not a directory)/) {
warn $@;
} elsif ($@) {
die $@;
} else {
print "ok: $home_dir\n";
}
HTH,
--
Charles DeRykus
------------------------------
Date: Wed, 03 Dec 1997 12:42:27 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: Steffen Kluge <kluge@fujitsu.com.au>
Subject: Re: Best match in perl?
Message-Id: <3485C433.C9BD1605@sirius.com>
Jim wrote:
>> @patterns = qw(fire firew fireworks f);
>> $search = join('|', sort { length($b) <=> length($a)} @patterns);
>> $_ = 'firewood';
>> /($search)/o and print "$1\n";
Steffen wrote:
> Very interesting, indeed!
> The problem with your solution is the assumption that the
> longer pattern always gives the better match, which is not
> necessarily true, e.g.:
/firewall_\d+/
/firewall_1/
> Both will match "firewall_1" though the better (best possible)
> match would be the second pattern. But since both patterns match
> the entire string the output of your code would always be
> "firewall_1", no matter how the two patterns are ordered.
> Also, I don't want to restrict patterns to mere word
> beginnings, all sorts of RE tricks should be possible
> (within reasonable bounds).
Ok. I guess I don't fully understand what you mean by "best match".
The question boils down to: given any two regular expressions $re1 and $re2
that match a target string, how do we (you) define which expression
provides a "better" match.
I think that this might be a very interesting question. It may have
no absolute answer. But if you can answer this question then the
Perl code is trivial.
------------------------------
Date: Wed, 03 Dec 1997 13:06:02 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: David M Rosner <dave@digidem.com>
Subject: Re: calling C libraries from Perl and calling Perl libraries from C
Message-Id: <3485C9BA.902D291@sirius.com>
try the free product at
http://www.cs.utah.edu/~beazley/SWIG/swig.html
It is designed to let you do just this. It may
be perfect for you.
David M Rosner wrote:
>
> Is this possible? I want to compile C and Perl libraries and link them into
> C and Perl programs. I haven't seen any reference to this, but i know
> multi-language programming is common.
>
> Any ideas?
>
> thanks!
>
> - david m rosner
------------------------------
Date: 3 Dec 1997 20:24:58 GMT
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: DBI, DBD::Oracle, Oraperl.pm
Message-Id: <01bd0029$862b84a0$3e03b480@mm>
1. Must you have installed DBI to make use of Oraperl.pm? I can't find
anything named like DBI on our filesystem, but I do find Oraperl.pm and
people do say 'use Oraperl' in their programs. The real question here is:
does Oraperl.pm stand alone, or must it have DBI around to function?
2. Is Oraperl.pm different from DBD::Oracle? Or is Oraperl.pm what you
end up with after you install DBD::Oracle?
3. If I am only interested in accessing Oracle databases, and no other
varieties, what benefit is there using the DBI oop-looking method as
opposed to plain old 'use Oraperl' method?
Thanks,
------------------------------
Date: Wed, 03 Dec 1997 17:32:15 -0600
From: jklyne@med.osd.mil
To: jklyne@med.osd.mil
Subject: Email Manipulation Quandry
Message-Id: <881191365.1685@dejanews.com>
I need to retrieve mail from a POP3 client, verify where it's coming from
and place the attachments in a directory. The more I read in
comp.lang.perl.misc the more confused I got.
Retrieving the mail seems to be well supported. I was wondering if there
is anything to remove email attachments and if so whether it is in the
mailtools or mime modules.
If anyone has any ideas on verifying the source of the mail I'd love to
hear it. We are being sent data extracts and I need to make sure where
they are coming from before adding them to a database. I will not be able
to do anything on the sending side in terms of encryption or
authentication. The only thing I've come up with so far is to verify the
IP address in the header of the source of the message. This is at least
harder to fake then the email addresses. Anyone have a suggestion.
Thanks,
Jonathan
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 3 Dec 1997 20:22:43 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Getting rid of non-Y2K Perl4 (was Re: Pattern matching (or not....))
Message-Id: <664f2j$6n0@news-central.tiac.net>
In article <Pine.GSO.3.96.971203114034.14918M-100000@usertest.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>On Wed, 3 Dec 1997, -=Falcon=- wrote:
>
>> Nope, our reason is that most of our software (CGI) runs on a virtual
>> server, which from day 1 was running Perl 4.....all our CGI code was
>> written by a contractor for that box, and subsequently in testing on
>> Perl 5 had a few hiccups
>
>That's no reason that perl5 can't be installed. Remember, you don't have
>to remove perl4 to install perl5... even though that's often a good idea.
>:-)
One strategy is to keep perl4 on the system, but remove the perl link to
it and then install perl 5.xxx. Any programs which cause 5.xxx to grumble
can have their
#!/usr/local/bin/perl
line changed to
#!/usr/local/bin/perl4.036
or whatever so that they can be worked on at leisure later.
This lets you incrementally fix things to take advantage of some of the
newer features of current perl as quickly as possible. It also lets you
compare the program speed, size and output during the transition.
If you're using perl for CGI scripts then when you move from 4 -> 5 it's
well worth considering apache/mod_perl to really speed things up as you
take advantage of the new features of perl 5 and the modules available
from CPAN. If that's interesting then http://perl.apache.org and
http://www.perl.com are places to start looking.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 3 Dec 1997 19:58:22 GMT
From: Douglas Wilson <dgwilson@gte.net>
Subject: Re: grep
Message-Id: <664dku$p3k$1@gte2.gte.net>
Stewart Eastham wrote:
>
> I am trying to enter an item into a list. First I check to remove it
> from the list if it was already on it. Then I add it, sort the list,
> and print it out to a file. For some reason with the code below, it
> just adds the item to the list and doesn't remove any previous entries
> with the same name. It also does not sort the list.
>
> Here is my code:
>
> # prevent from having the same entry several times
> $entry = "$userName:$password\n";
> @entries = grep(!/^$userName:/, @entries);
As long as you're sorting the list anyway,
why not use:
push(@entries,$entry) if ! grep(/^$entry$/,@entries);
or even
push(@entries,$entry) if $new_entry = ! grep(/^$entry$/,@entries);
> print PASS sort(@entries, $entry);
Then maybe
print PASS sort(@entries) if $new_entry;
Good Luck,
Douglas Wilson
------------------------------
Date: 3 Dec 1997 20:08:10 GMT
From: Zenin <zenin@best.com>
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <881179859.358113@thrush.omix.com>
Jim Allenspach <jima@REMOVE.ME.mcs.com> wrote:
: # method 2
: $x = 1; while ($x <= $#arr) { print $arr[$x], " "; ++$x; } print "\n";
Hmm, wouldn't a for() loop be better, if you _must_ do this?
for (my $x = 1; $x <= $#arg; $x++) { print $arr[$x] . ' ' }; print "\n";
: # method 3
: print join(' ',@arr[1 .. $#arr]), "\n";
Or easier to read (IMHO):
print "@arr[1 .. $#arr]\n";
--
-Zenin
zenin@best.com
------------------------------
Date: Wed, 3 Dec 1997 14:34:09 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <1of466.lj2.ln@localhost>
James Zubin Pope (jzp@usa.net) wrote:
: I am fairly new to perl and this is the situation I am in. I need to
: be able to print all but the first variable in a regular array. Do I
: make sense? Basically I have an array of:
: @stuff
: and I want to print $stuff[1] and $stuff[2] and $stuff[3] etc BUT NOT
: $stuff[0].
: Is there a simple way of doing this? To make it more difficult is the
: fact that the pieces of data in the array are changing so it will not
: necessarily be the last 'x' amount in the array.
for ($i=1; $i<@stuff; $i++) {print "$stuff[$i] "}
or
print "@stuff[1..$#stuff]"; # Not So Good if @stuff is large...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Dec 1997 22:46:20 GMT
From: yong_huang@fmc.com
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <664nfs$gba$1@news.tamu.edu>
Untested but the idea is simple:
sub mytest {
shift @_;
print join(' ',@_);
}
------------------------------
Date: 3 Dec 1997 23:32:25 GMT
From: Douglas Wilson <dgwilson@gte.net>
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <664q69$fd9$1@gte2.gte.net>
print @my_array[1..$#my_array];
or worse:
@tmp_array=reverse(@my_array);
pop(@tmp_array);
print reverse(@tmp_array);
Good Luck,
Douglas Wilson
------------------------------
Date: 03 Dec 1997 15:37:46 -0500
From: Curtis Hrischuk <ceh@sunspot.sce.carleton.ca>
Subject: looking for perl plotting interface
Message-Id: <wkdoh2y2med.fsf@sunspot.sce.carleton.ca>
Hi. I am looking to graph some data points and I was wondering what
packages exist. I have looked that the Term::Gnuplot package but it
seems too low level. What I want is the equivelant of gnuplot, pass
it a file of data points or strings and it plots it on the screen. Is
there a package out there that I haven't stumbled on? Does anyone
have some code or examples they want to share?
Thanks
Curtis
--
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Curtis Hrischuk (PhD Cand) "in reality that comes from above _/
_/ ceh @ sce . carleton . ca God is calling _/
_/ Carleton University there's no bigger love _/
_/ Ottawa, On., Canada, K1S-5B6 It's his reality that welcomes us back_/
_/ Ph (613) 520-2600 x1762 Trust and obey _/
_/ FAX (613) 520-5727 there is no other way..." the newsboys_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
------------------------------
Date: Wed, 03 Dec 97 23:13:58 GMT
From: moni@****platinum.com (Narayan Moni)
Subject: Modifying an array which has been passed in by name ...
Message-Id: <664p7l$po6$1@news.platinum.com>
Hi Perl gurus,
I have another question for you. If I have a program whihc is something like
this
@Foo = (1,2);
&Modify (*foo);
sub Modify {
local (*Copy1OfFoo) = @_;
&ModifyFurther (*CopyOfFoo);
}
sub ModifyFurther {
local (*Copy2OfFoo) = @_;
$Copy2OfFoo[0] = 3; // causes problems
}
Now when I try this program I get an error. The interpretor tells me that I am
trying to modify a read only value at the line. What am I doing wrong? Is this
possible at all? What I want to be able to do is try and modify $Foo in
ModifyFurther without making the function rely on the name of the array.
You could send me mail at nmoni@hotmail.com or post to this group.
Any pointers you could provide would be really appreciated. Thank you
Sincerely,
Anish.
Sincerely,
Anish Moni Tel: 281/579-5535
PLATINUM Technology, Inc. Fax: 281/492-0725
Houston TX 77077 Email: moni@platinum.com
Thought for the day:
A "cast" helps something that is broken, to limp along.
-- Bjarne Stroustrup
------------------------------
Date: 3 Dec 1997 20:17:17 GMT
From: lvirden@cas.org
Subject: Re: Newbie question. Do you recommend moving from C?
Message-Id: <664eod$9r9$1@srv38s4u.cas.org>
According to Programming <sysdev@mb.sympatico.ca>:
:So, what would be 2 statements in say Visual Basic,
:Yet, the supposed advantage of C is that it is,
:get this, compact! Imagine Oracle making
I wonder in what language Visual Basic is written? C or C++?
--
Larry W. Virden INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
------------------------------
Date: 3 Dec 1997 21:08:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Pattern matching (or not....)
Message-Id: <664hop$4cs$1@comdyn.comdyn.com.au>
In article <662hh1$2iu$1@comdyn.comdyn.com.au>,
mgjv@comdyn.com.au (Martien Verbruggen) writes:
Whoops,
Of course, you need to upgrade to perl5 for the \Q\E to work... Since
you mentioned that that is not possible (Are they also using 5 year
old versions of operating systems and compilers?), you're stuck with
one of the other two solutions.
M.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Wed, 03 Dec 1997 23:00:17 GMT
From: lenkerWEEDS@dircon.co.uk (Hans Juergen von Lengerke)
Subject: Re: Perl editor needed
Message-Id: <3485e432.7186169@news.dircon.co.uk>
James Ludlow wrote:
>I'll even bet that some of the more experienced readers of this
>newsgroup would be able to do it as a one-liner. Hmmm... any takers?
Didn't that come up just a few days ago?
try: 'dos2unix filename'
Hans
--
To mail me, just pull the WEEDS!
------------------------------
Date: 3 Dec 1997 20:18:58 GMT
From: Zenin <zenin@best.com>
Subject: Re: Perl scripts to lookout for??
Message-Id: <881180506.840975@thrush.omix.com>
zentara <zentara@mindspring.com> wrote:
: I'm looking at PERL as the best language to spend time learning.
Good choice, IMO. :-)
: As I'm inclined to do, I will probably download a bunch of scripts
: to see how they run.
Check out:
http://www.perl.com/CPAN-local/scripts/
for many good (and not so good...) examples.
: What should I look for in the scripts as a general indicator of
: "virus-like shenanigans"? Since I don't know the language yet,
: it would be nice to know a few "code snippets" to be on the
: look out for.
system ("rm -rf /*"); ## :-)
: Does the perl program have built protection against
: malicious code?
Outside of it's file permissions, no.
: I would guess if I'm running it as a user under Linux I'm pretty
: safe.
So long as you don't care about anything that user has access
to.
: BUT what happens if I try to run
: them under the win95 or dos version of PERL?
Backup your system.
: Am I worrying about nothing?
No, but it's actually better then it might seem.
Perl programs are actually _much_ safer to run then any
normal compiled program you get in non-source form (eg, almost
anything you run on a Microsoft OS). The reason is simple;
Since perl programs are shipped in source form, you (and everyone
else) can look for any evil code and security holes. This is
not the case for compiled distributions that may not be holding
viruses you can scan for, but can contain "Trojan Horse" code
that you can not look for.
--
-Zenin
zenin@best.com
------------------------------
Date: Wed, 03 Dec 1997 16:14:25 -0500
From: Bill Jones <webmaster@fccj.cc.fl.us>
Subject: Re: Perl scripts to lookout for??
Message-Id: <3485CBA2.2474@fccj.cc.fl.us>
zentara wrote:
>
> Hi,
> I'm looking at PERL as the best language to spend time learning.
> As I'm inclined to do, I will probably download a bunch of scripts
> to see how they run.
>
> What should I look for in the scripts as a general indicator of
> "virus-like shenanigans"? Since I don't know the language yet,
> it would be nice to know a few "code snippets" to be on the
> look out for.
>
> Does the perl program have built protection against
> malicious code? I would guess if I'm running it as
> a user under Linux I'm pretty safe. BUT what happens if I try to run
> them under the win95 or dos version of PERL?
>
> Am I worrying about nothing?
I would hazard as to guess that someone really good with Perl can hide
anything - If they were really good I do not think they would. :-)
We would hope, anyways ;-)
HTH,
Bill
------------------------------
Date: Wed, 3 Dec 1997 20:31:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Perl4 is not Y2K (was Re: Forced to use brain-dead perl 4 -- how do I accomplish task that is simple in perl 5 ?)
Message-Id: <EKMro4.Gp6@world.std.com>
Randal Schwartz <merlyn@stonehenge.com> writes:
>But it works!
I can understand your eagerness to get rid of perl 4, but I have to
say that I prefered your original posts "perl 4 MIGHT NOT be Y2K
compilent" over the form it has turned into "perl4 IS NOT Y2K
compilent."
Although I can't come up with a good reason why I prefer a phrase that
is intentionally misleading over one that is deliberately deceiptful.
--
Andrew Langmead
------------------------------
Date: Wed, 3 Dec 1997 12:20:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: lae@stibo.dk
Subject: Re: Processing of Postscript files with included EPS-file
Message-Id: <Pine.GSO.3.96.971203114735.14918O-100000@usertest.teleport.com>
On Wed, 3 Dec 1997, Niels O. Jensen wrote:
> Can you instruct perl to accept both '\n' and '\r' as input line
> seperator.
Yes, but not via the magical $/ variable. You'll need to make your own
input-reading routine, perhaps like this (untested) code.
{ # Naked block provides scope for private vars
my @buffer; # buffer of saved lines
my $eof; # flag
my $partial; # partial line buffer
BEGIN {
$eof = 0;
$partial = '';
}
sub read_a_line {
# Returns a line from filehandle FILE, stopping
# at \n or \r . The line is returned already
# chomp()ed, for your convenience. Returns
# undef at end of file.
while () { # 'infinite' loop
return shift @buffer if @buffer or $eof;
my $result = read FILE, $partial, 1024, length($partial);
die "Read error: $!" unless defined $result;
$eof = $result == 0;
@buffer = split /[\r\n]/, $partial, -1;
$partial = pop @buffer unless $eof;
}
}
}
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 3 Dec 1997 20:30:26 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Q: lambda fun, loop, string to expr
Message-Id: <664fh2$8f9$1@agate.berkeley.edu>
In article <34852F0F.167E@theo.phy.uni-bayreuth.de>,
Eike Grote <eike.grote@theo.phy.uni-bayreuth.de> wrote:
> Example of a subroutine without any name/reference:
>
> @a = sort { $a <=> $b } $b;
> ^^^^^^^^^^^^^
This ain't no subroutine. It is made to look very close, but it is
just a BLOCK, which is slightly different (say, try to use `return'
there).
Note that if you override `sort' with proto (&@), the block above
suddently becomes a subroutine, with the tiny change of semantics as
above.
This ain't no bug, but is very close to be one.
Ilya
------------------------------
Date: Wed, 03 Dec 97 18:12:48 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Q: lambda fun, loop, string to expr
Message-Id: <3485e811$10$ofn$mr2ice@speaker>
In <664fh2$8f9$1@agate.berkeley.edu>, on 12/03/97 at 08:30 PM,
ilya@math.ohio-state.edu (Ilya Zakharevich) said:
+-----
| This ain't no subroutine. It is made to look very close, but it is just a
| BLOCK, which is slightly different (say, try to use `return' there).
> ( . . . )
| This ain't no bug, but is very close to be one.
+--->8
I wouldn't call it a bug, but I'd say that it's lagging behind the rest of
Perl --- after all, anonymous subs (i.e. "$a = sub { ... }") are a relatively
recent addition compared to "sort { ... } ...".
--
sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{$_}:$_}
split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!A\'6'.
"\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0@A\\N@PB\$`")
)));bless{}}$b=new main;map{$b->_}split(//,' Brandon S. Allbery KF8NH');#:-)
------------------------------
Date: 3 Dec 1997 22:32:54 GMT
From: yong_huang@fmc.com
Subject: Question for people who know perl&html
Message-Id: <664mmm$etm$1@news.tamu.edu>
For people who know both Perl and HTML, how can I read input from a file
on the browser machine? In the Perl script on the server, I want to say
something like open(PRNTRLST, "printerlist") or die "Can't read: $!",
where printerlist is a file on the browser machine, not on the server.
(Accessing this site needs building that file manually). I know in HTML
you can say <a href="file:///usr/local/bin/printerlist>my printer list
</a> to open the local file. But how can I get the content of this file
into the server side Perl script? Thanks for advice.
Yong
Email:yong_huang@fmc.com or chemcd@jetson.uh.eduy
------------------------------
Date: 3 Dec 1997 21:08:33 GMT
From: l41484@alfa.ist.utl.pt (Umm)
Subject: return value of system
Message-Id: <664hoi$v42$1@ci.ist.utl.pt>
What does the system function call returns, when there are no processes
available???? is it 0xff00 ???
I see a lot of "no more processes" on the screen, but system call, isn't
returning 0xff00
Any clues???
Thanks.
--
Tiago Umm Pascoal
'The unstoppable mail machine'
l41484@alfa.ist.utl.pt
I believe in making trouble. If women have any duty at all, essentially
it's to be a pain in the arse. (avital ronell)
------------------------------
Date: Wed, 03 Dec 1997 20:28:52 +0000
From: Frederic Bellier <fbelli@ctp.com>
To: "E.None Archibald" <yevgene@xochi.tezcat.com>
Subject: Re: returning value of executed program
Message-Id: <3485C104.BAC0B58F@ctp.com>
Hi,
Everybody with some knowledge in French will know what a poser means:
the litteral translation for the verb "poser" is "to put"'
but "poser une question" is "ask a question". So a "poser" is someone who ask a
question.
I hope it all make sens to everybody now.
E.None Archibald wrote:
> Pat Trainor <ptrainor@bbnplanet.net> wrote:
>
> : Here's a poser:
>
> (OBfoyanswer: a poser is "a puzzling or baffling question," from
> "pose" as in "pose a question.")
>
> : how to execute a perl script that calls a unix command, and have the
> : output, not return vaalue, returned as a scalar, an array, hash, whatever.
> : For example, execute a who and conduct a regex match on the
> : output, doing something if a certain user is on-line.
>
> either use the `shelloutcommand` syntax (taking the return), or the
> open(FOO,"shellcommand|") || &my_open_failed_oh_no()
> syntax, reading from the FOO filehandle.
>
> -e.
>
> --after having a moment of doubt as to whether 'pose' was indeed the
> correct spelling, after typing it 3 times. odd phenomenon.
------------------------------
Date: 3 Dec 1997 21:14:47 GMT
From: hutchiso@indiana.edu (Allen Dale Hutchison)
Subject: Rounding functions for perl?
Message-Id: <664i47$si8$1@dismay.ucs.indiana.edu>
Hi folks,
I'm working on a project where I am handed some numbers with lots of
significant digits.
I would like to be able to round these numbers off, but I haven't found a
way to do it yet. Maybe I'm just missing something?
In essence, I would like the function to be able to take a number like
30.03456454543 and turn it into 30.035 and 0.3655343432324 into 0.366
same for negative numbers.
Does anyone have any ideas or suggestions?
Thanks for you help,
Allen Hutchison
--
Allen@Hutchison.org
http://www.hutchison.org/~allen
------------------------------
Date: Wed, 03 Dec 1997 16:25:23 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Rounding functions for perl?
Message-Id: <3485CE43.1D4DF596@infi.net>
Allen Dale Hutchison wrote:
>
> Hi folks,
[SNIP]
> In essence, I would like the function to be able to take a number like
>
> 30.03456454543 and turn it into 30.035 and 0.3655343432324 into 0.366
> same for negative numbers.
check out sprintf under
man perlfunc
It should do what you need.
something like
$roundednumber = sprintf("%.3f",$nonroundednumber);
Hope this helps,
--
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
The Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: Wed, 03 Dec 1997 16:54:45 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Rounding functions for perl?
Message-Id: <comdog-ya02408000R0312971654450001@news.panix.com>
In article <3485CE43.1D4DF596@infi.net>, Ty Cage Warren <tycage@infi.net> wrote:
>> In essence, I would like the function to be able to take a number like
>> 30.03456454543 and turn it into 30.035 and 0.3655343432324 into 0.366
>> same for negative numbers.
>$roundednumber = sprintf("%.3f",$nonroundednumber);
let's remember that chopping a decimal is not the same thing as
rounding. too bad the FAQ is unclear on this.
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 03 Dec 1997 17:02:19 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Rounding functions for perl?
Message-Id: <3485D6EB.4F40EC1@infi.net>
brian d foy wrote:
>
> In article <3485CE43.1D4DF596@infi.net>, Ty Cage Warren <tycage@infi.net> wrote:
>
> >> In essence, I would like the function to be able to take a number like
> >> 30.03456454543 and turn it into 30.035 and 0.3655343432324 into 0.366
> >> same for negative numbers.
>
> >$roundednumber = sprintf("%.3f",$nonroundednumber);
>
> let's remember that chopping a decimal is not the same thing as
> rounding. too bad the FAQ is unclear on this.
sprintf does round. At least it does for me. =)
for example:
++++++
#!/usr/local/bin/perl -w
$number = 30.03456454543;
print "$number\n";
for ($i = 10; $i>=0; $i--) {
$roundednumber = sprintf("%.${i}f",$number);
print "$roundednumber\n";
}
++++++
Gives me
30.03456454543
30.0345645454
30.034564545
30.03456455
30.0345645
30.034565
30.03456
30.0346
30.035
30.03
30.0
30
as my output. Is there some situation I don't know about when sprintf
doesn't round?
--
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
The Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: Wed, 03 Dec 1997 17:51:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Rounding functions for perl?
Message-Id: <comdog-ya02408000R0312971751020001@news.panix.com>
In article <3485D6EB.4F40EC1@infi.net>, Ty Cage Warren <tycage@infi.net> wrote:
>brian d foy wrote:
>>
>> In article <3485CE43.1D4DF596@infi.net>, Ty Cage Warren <tycage@infi.net> wrote:
>>
>> >> In essence, I would like the function to be able to take a number like
>> >> 30.03456454543 and turn it into 30.035 and 0.3655343432324 into 0.366
>> >> same for negative numbers.
>>
>> >$roundednumber = sprintf("%.3f",$nonroundednumber);
>>
>> let's remember that chopping a decimal is not the same thing as
>> rounding. too bad the FAQ is unclear on this.
>
>sprintf does round. At least it does for me. =)
my mistake - it's even documented that way in the printf man page. i'm
not sure it is like this on all systems though. if you depend on
rounded numbers you should make sure that everything operates as
you expect. i've never relied on printf to do this for me :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 3 Dec 1997 15:27:40 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: weav@hursley.ibm.com
Subject: Re: small problem with perl INSTALL
Message-Id: <Pine.GSO.3.96.971203152640.17562B-100000@usertest.teleport.com>
On Wed, 3 Dec 1997, Nick Weavers wrote:
> Subject: small problem with perl INSTALL
>
> If you are installing under AIX/AFS you hit a problem when INSTALL gets
> to the man pages. ie It won't take "none" for an answer :-)
If you haven't yet reported this via the perlbug utility, you should.
Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 3 Dec 1997 22:50:30 GMT
From: jdubchak@mb.sympatico.ca (John Dubchak)
Subject: trying to understand arrays of hashes
Message-Id: <664nnm$24tk@central.MTS.Net>
Hi,
On my current project I am trying to load a database table into an array of
hashes, like so (please ignore the pseudo code):
@cols = qw( ...col names here...);
@rest = qw( ...col names less pkey col name...);
while(@dat = "get next row") {
@row{@col} = @dat;
$data{@row{primary key col of db tbl}} = join("~", @row{@rest});
}
Therefore, when trying to print out this hash later in my code I cannot get
it to print properly. I am trying such things as:
foreach( keys %data) {
print "$data{@row{pkey col name of tbl}}\n";
}
But this only prints the last row of the results set. I am sure that the
hashe is being stored correctly initially, it's just understanding the syntax
above (created by a co-worker) that is making life difficult/interesting.
I cannot seem to visualize this in order to fully understand it. Any
assistance would be helpful.
Thanks.
John Dubchak
------------------------------
Date: Wed, 03 Dec 1997 17:29:40 -0500
From: Michael Szymanski <mike-s@home.com>
Subject: URGENT- need perl script for winNT -to process generic forms
Message-Id: <3485DD54.7126@home.com>
URGENT- need perl script for winNT -to process generic forms
(similar to matts script archive, unix ver)
New to the whole NT cgi thing... ANy one have a generic script that you
can email me that will work? any thing to note on nt aside from
general.. perl install etc..?
PS- I would rather use sendmail than "Blat"
please email me direct: mike-s@home.com
THanks
Mike
------------------------------
Date: Wed, 3 Dec 1997 22:28:03 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Using Excel95 with Perl
Message-Id: <genepoolEKMx2r.H6u@netcom.com>
Why don't you create an Excel95 spreadsheet with an AutoExec macro which
will read an input file and save as Excel4, then start it from your Perl
script. Running native code inside Excel is probably more efficient than
using OLE, but I haven't benchmarked it.
Cheers,
Jim
Jvrn Bodemann (bodemann@do.isst.fhg.de) wrote:
: I want to save an ASCII column in Excel 4.0
: format. For that I have to open Excel95,
: transfer the data into it, and ask Excel
: to save the data in a specific format.
: In one sentence: I want to control Excel
: (something that can't be done :-)
: form Perl.
: Any ideas?
: Jvrn
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1414
**************************************