[12372] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5972 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 12 13:07:26 1999

Date: Sat, 12 Jun 99 10:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 12 Jun 1999     Volume: 8 Number: 5972

Today's topics:
    Re: Afraid to ask about Y2K! <dgris@moiraine.dimensional.com>
        clear memory (IzB.)
    Re: clear memory (Marcel Grunauer)
        DBD::CSV <khowe@performance-net.com>
    Re: disalowing words <rereidy@uswest.net>
    Re: disalowing words (Lee)
    Re: disalowing words <gellyfish@gellyfish.com>
    Re: disalowing words (Twarren10)
    Re: disalowing words (Larry Rosler)
    Re: disalowing words (Tad McClellan)
        FormMail Modification <kenyon@ct1.nai.net>
    Re: FormMail Modification <gellyfish@gellyfish.com>
    Re: FormMail Modification (Marcel Grunauer)
    Re: FormMail Modification (Marcel Grunauer)
    Re: HELP: Perl on Windows Platform??? <dominikl@pyramid.de>
        I <walter@tscinternet.com>
    Re: importing comma-delimited data into perl? <gellyfish@gellyfish.com>
        Log file (Twarren10)
    Re: MacPerl and sending records to filemaker: apple eve (Chris Nandor)
    Re: MIcrosofts Attack on Perl <jgrain@yahoo.com>
    Re: multiple match & replace regexp (Larry Rosler)
        Prevent loading from Cache? <04282757-0001@t-online.de>
        Printing rsanders@ac.net
    Re: Printing <bjoern.teegen@gmx.de>
        Stat mtime <aef@pangea.ca>
        Subs that can operate on $_ in void context? (Marcel Grunauer)
    Re: Subs that can operate on $_ in void context? <gellyfish@gellyfish.com>
    Re: Verifying date data (Larry Rosler)
    Re: write the output of eval to a string? <info@java.seite.net>
    Re: write the output of eval to a string? <gellyfish@gellyfish.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 12 Jun 1999 09:54:50 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <m3d7z15s8l.fsf@moiraine.dimensional.com>

sbean@iex.net (Steve Bean) writes:

> This is exactly what I am talking about.  What the hell is deja.com?

If you don't know what deja.com is and can't figure it out (you
even have the damn URL) then you probably shouldn't be using
a computer.  Pick a field more suitable to your abilities, such
as medical research subject.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Sat, 12 Jun 1999 14:08:08 GMT
From: izzac@videotron.ca (IzB.)
Subject: clear memory
Message-Id: <37626317.623951@news.videotron.ca>

hi,
is there a function that free the memory associated with an object or
another vaiable ?  
 
@array[obj1,obj2,obj3]

if I want to clear my 'obj2', what could I do if I want to be certain
that all the memory used by 'obj2' is free again ?

thanks
Iz


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

Date: Sat, 12 Jun 1999 14:21:10 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: clear memory
Message-Id: <37646b7a.6445367@enews.newsguy.com>

On Sat, 12 Jun 1999 14:08:08 GMT, izzac@videotron.ca (IzB.) wrote:

>hi,
>is there a function that free the memory associated with an object or
>another vaiable ?  
> 
>@array[obj1,obj2,obj3]
>
>if I want to clear my 'obj2', what could I do if I want to be certain
>that all the memory used by 'obj2' is free again ?
>
>thanks
>Iz

Perl handles all the garbage collection for you and releases the
memory for a variable once the variable has gone out of scope and no
other references for the variable exist (sorry about the somewhat
imprecise wording, I'm trying to explain this although I'm still a
learner too).

I suppose you could undef obj2 manually...

HTH

Marcel



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

Date: Sat, 12 Jun 1999 12:11:31 -0300
From: "Kevin Howe" <khowe@performance-net.com>
Subject: DBD::CSV
Message-Id: <xIu83.25255$%65.48337@tor-nn1.netcom.ca>

How reliable/bug free is DBD::CSV? Is it safe to use in large projects?

Thanks,
Kevin




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

Date: Sat, 12 Jun 1999 06:18:05 -0600
From: Ron Reidy <rereidy@uswest.net>
Subject: Re: disalowing words
Message-Id: <37624FFC.3D5C972C@uswest.net>

Twarren10 wrote:

> I have what seems to be a relativly simple problem, but I cannot find the
> answer in the books. I want to cut off to a "not allowed" message anyone who
> enters the 8 or 9 words which are unacceptable to some people. I have it set
> with a long list of elsif statements, but I remember reading this can be done
> on one line with a comma or something to that nature? can anyone enlighten me
> how to avoid the long list of "elsif" statements for each word I want to
> exclude. Thanks in advance.

use George::Carlin;


--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.




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

Date: Sat, 12 Jun 1999 07:24:03 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: disalowing words
Message-Id: <B387BB93966821DE9B@204.112.166.88>

In article <19990612074323.22857.00000762@ng-fu1.aol.com>,
twarren10@aol.com (Twarren10) wrote:

>I have what seems to be a relativly simple problem, but I cannot find the
>answer in the books. I want to cut off to a "not allowed" message anyone who
>enters the 8 or 9 words which are unacceptable to some people. I have it set
>with a long list of elsif statements, but I remember reading this can be done
>on one line with a comma or something to that nature? can anyone enlighten me
>how to avoid the long list of "elsif" statements for each word I want to
>exclude. Thanks in advance.

if ($message =~ /any|naughty|word/) {
    tell($mom);
}

Lee




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

Date: 12 Jun 1999 12:59:36 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: disalowing words
Message-Id: <7jtljo$1mb$1@gellyfish.btinternet.com>

On 12 Jun 1999 11:43:23 GMT Twarren10 wrote:
> I have what seems to be a relativly simple problem, but I cannot find the
> answer in the books. I want to cut off to a "not allowed" message anyone who
> enters the 8 or 9 words which are unacceptable to some people. 

My your program must have an exceedingly liberal audience - only 8 or 9 ?

>                                                               I have it set
> with a long list of elsif statements, but I remember reading this can be done
> on one line with a comma or something to that nature? can anyone enlighten me
> how to avoid the long list of "elsif" statements for each word I want to
> exclude. Thanks in advance.
> 

This feels like a FAQ and I may well have missed something but there is
nothing in there that I could determine that would address this directly
although you might want to look at perlfaq6:

       How do I efficiently match many regular expressions at
       once?

Infact I cant really think of an efficient way to do this off the top
of my head - a quckie that will get you there:


#!/usr/bin/perl -w

use strict;

my @banned_words = qw(microsoft y2k work monsanto cricket crocodile);

my $string = <>;

foreach (@banned_words)
{
   if ($string =~ /$_/i )
     {
       print "Naughty, Naughty you shouldnt say - $_\n";
       last;
     }
}

Of course I'm not really sure what you mean when you say 'the user enters'
so if I have guessed wrong then perhaps you ought to post a small amount
of code that you have tried that demonstrates what you are trying to do.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 12 Jun 1999 12:41:26 GMT
From: twarren10@aol.com (Twarren10)
Subject: Re: disalowing words
Message-Id: <19990612084126.22862.00000715@ng-fu1.aol.com>

>
>if ($message =~ /any|naughty|word/) {
>    tell($mom);
>}
>
>Lee
>

That was BEAUTIFUL, thank you my friend!


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

Date: Sat, 12 Jun 1999 08:15:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: disalowing words
Message-Id: <MPG.11cc1988b278fae3989bd1@nntp.hpl.hp.com>

In article <7jtljo$1mb$1@gellyfish.btinternet.com> on 12 Jun 1999 
12:59:36 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...
> On 12 Jun 1999 11:43:23 GMT Twarren10 wrote:
> > I have what seems to be a relativly simple problem, but I cannot find the
> > answer in the books. I want to cut off to a "not allowed" message anyone who
> > enters the 8 or 9 words which are unacceptable to some people. 
 ...
> This feels like a FAQ and I may well have missed something but there is
> nothing in there that I could determine that would address this directly
> although you might want to look at perlfaq6:
> 
>        How do I efficiently match many regular expressions at
>        once?
> 
> Infact I cant really think of an efficient way to do this off the top
> of my head - a quckie that will get you there:

<SNIP> of method described in that FAQ as 'extremely inefficient'.  The 
following is efficient.


#!/usr/local/bin/perl -w
use strict;

my @banned_words = qw(microsoft y2k work monsanto cricket crocodile);
my %banned_words;
@banned_words{@banned_words} = ();

while (<DATA>) {
    exists $banned_words{+lc} and
        print "Naughty, Naughty you shouldnt say - $_\n"
            for split /\W+/;
}
__END__
This list includes Y2K and work-related issues
about not working too hard using Microsoft products.
 

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


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

Date: Sat, 12 Jun 1999 07:24:10 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: disalowing words
Message-Id: <q0gtj7.ft8.ln@magna.metronet.com>

Ron Reidy (rereidy@uswest.net) wrote:
: Twarren10 wrote:

: > I have what seems to be a relativly simple problem, but I cannot find the
: > answer in the books. I want to cut off to a "not allowed" message anyone who
: > enters the 8 or 9 words which are unacceptable to some people. I have it set
               ^^^^^^
: > with a long list of elsif statements, but I remember reading this can be done
: > on one line with a comma or something to that nature? can anyone enlighten me
: > how to avoid the long list of "elsif" statements for each word I want to
: > exclude. Thanks in advance.


: use George::Carlin;


   Then I'm wondering...

   ...


   print "one new word is: $George::Carlin::words[7]\n";
   print "maybe one more new word is: $George::Carlin::words[8]\n"
      if $George::Carlin::words[8];


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 12 Jun 1999 10:08:29 -0400
From: Rollie Kenyon <kenyon@ct1.nai.net>
Subject: FormMail Modification
Message-Id: <376269DD.DB2F3CE5@ct1.nai.net>

Hello,
After performing math calculations on my form, some fields contain a
zero value. Any ideas how to modify FormMail so it doesn't send fields
that contain 0? Thanks in advance......


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

Date: 12 Jun 1999 14:46:11 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: FormMail Modification
Message-Id: <7jtrrj$2oo$1@gellyfish.btinternet.com>

On Sat, 12 Jun 1999 10:08:29 -0400 Rollie Kenyon wrote:
> Hello,
> After performing math calculations on my form, some fields contain a
> zero value. Any ideas how to modify FormMail so it doesn't send fields
> that contain 0? Thanks in advance......

Generally it is considered poor taste to be asking for support for
some piece of software in this newsgroup - especially without any
demonstration of an attempt to sort the problem yourself or even
attempting to identify the part(s) of the program that might be at fault.

That said you will need to find the sections of the script where you find:

            if ($Config{'print_blank_fields'} || $Form{$field} ||
                $Form{$field} eq '0') {
                print MAIL "$field: $Form{$field}\n\n";
            }

And modify it to remove the test that will explicitly allow a field with
a value of 0 to be printed.

You were talking about Matt Wright's formmail werent you ?

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 12 Jun 1999 14:15:10 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: FormMail Modification
Message-Id: <37636ab1.6244268@enews.newsguy.com>

On Sat, 12 Jun 1999 10:08:29 -0400, Rollie Kenyon <kenyon@ct1.nai.net>
wrote:

>Hello,
>After performing math calculations on my form, some fields contain a
>zero value. Any ideas how to modify FormMail so it doesn't send fields
>that contain 0? Thanks in advance......

<hall monitor>
	This doesn't seem to be a Perl question...
</hall monitor>

 ... but I'll try to answer it anyway.

People in this ng don't seem to be too keen to support Matt's Scripts,
but two solutions come to mind:

Either modify the formmail script like you said, or (maybe easier) use
JavaScript (in the form's onsubmit handler) to modify the hidden field
value that instructs formmail on which fields to send by excluding any
fields whose value is 0.

HTH

Marcel



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

Date: Sat, 12 Jun 1999 14:45:13 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: FormMail Modification
Message-Id: <37656f66.7449311@enews.newsguy.com>

On Sat, 12 Jun 1999 14:15:10 GMT, marcel.grunauer@lovely.net (Marcel
Grunauer) wrote:

>On Sat, 12 Jun 1999 10:08:29 -0400, Rollie Kenyon <kenyon@ct1.nai.net>
>wrote:
>
>>Hello,
>>After performing math calculations on my form, some fields contain a
>>zero value. Any ideas how to modify FormMail so it doesn't send fields
>>that contain 0? Thanks in advance......
>
><hall monitor>
>	This doesn't seem to be a Perl question...
></hall monitor>

Correcting myself here...

Of course it was a Perl question.
But the solution I had in mind (using JavaScript) made me jump to an
illogical conclusion.

Sorry.

Marcel



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

Date: Sat, 12 Jun 1999 13:37:22 +0200
From: Dominik Leinfelder <dominikl@pyramid.de>
Subject: Re: HELP: Perl on Windows Platform???
Message-Id: <37624672.1D8DB499@pyramid.de>

seong joon bae schrieb:

> Hi everyone,
> I know that in Unix, you have to put something like....
> #!/usr/local/bin/perl in order to run CGI script.
> But how about Windows 9x?
> What do you put on the first line in order to run CGI script?
>
> Thanks.
>
> Seong

if perl is properly installed, there should be a line like
PATH = %PATH%;C:\PERL\BIN;
in your autoexec.bat
so it would be enough to write
#!perl.exe
as the first of your lines...

greetinx
Dominik Leinfelder





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

Date: Sat, 12 Jun 1999 10:38:03 -0500
From: "Walter" <walter@tscinternet.com>
Subject: I
Message-Id: <37627f45@news1.us.ibm.net>

I ran across a reference to arrays that state...

Initialize your array before adding items to increase efficiency.

   i.e.:  $#priceList = 3000;

What do you guys think?

If I know the size of my array, does this help?

Thanks

Walter







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

Date: 12 Jun 1999 12:25:45 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: importing comma-delimited data into perl?
Message-Id: <7jtjk9$1j0$1@gellyfish.btinternet.com>

[ removed the pointless alt.perl (damn my filter failed and I didnt notice
  until it was too late) ]

In comp.lang.perl.misc Kate Roberts <kate.roberts@lib.monash.edu.au> wrote:
> Dear all: I'm very new at this, so please excuse asking what might be
> obvious to others.
> 
> I have a file containing comma-delimited data (exported from EXCEL),
> egmyfile...	"field1-wanted later","field2","field3-wanted"
> 	        "field1-wanted later","field2","field3-wanted"
> 	        "field1-wanted later","field2","field3-wanted"
>  which I want to bring into perl, filter out most of the fields, and
> then output the fields of interest.
> 

You might find it usefull to look at perlfaq4:

=head2 How can I split a [character] delimited string except when inside
[character]? (Comma-separated files)

The method outlined there will allow you to deal with Comma-files which
may contain commas in the fields themselves.

Of course there are modules that will allow you to deal with these as well:

  Text::CSV - which will allow you to deal with CSV data on a line
              by line basis.

   DBD::CSV - which will allow you to treat your CSV file as an SQL
              compliant database table.  

Both of these have their merits within certain problem domains.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 12 Jun 1999 15:57:47 GMT
From: twarren10@aol.com (Twarren10)
Subject: Log file
Message-Id: <19990612115747.22408.00000834@ng-fu1.aol.com>

I am writing a simple program to log what people are seaching for and the
number of times they search. It's basic and uncomplicated, and perl gives no
error messages, but it doesn't work. Can anyone tell me what might cause this
not to work. I've gone over it several times and can't catch anything wrong.
here's the code.

sub log_searches {

$log_file = "search.log";
if ("$log_file") {
	open (FILE1, "$log_file");
	open (FILE2, ">>$log_file2");
	@LOG = <FILE1>;
	$matched = 0;
	foreach $line (@LOG) {
		($searched_word, $times) = split(/:/,$line);
		if ($searchstring eq $searched_word) {
			$times = ($times + 1);
			$matched = 1;
			print FILE2 "$searched_word:$times\n";
		}
		else {
			print FILE2 "$searched_word:$times\n";
		}
	}
	if ($matched == 0) {
		print FILE2 "$searched_word|1\n";
	}
	close (FILE1);
	close (FILE2);
	rename ("$log_file2", "$log_file");
 }
else {
exit;
}
}




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

Date: Sat, 12 Jun 1999 12:03:54 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl and sending records to filemaker: apple events?
Message-Id: <pudge-1206990804010001@192.168.0.77>

In article
<'x'campbell-lange-1106992332280001@campbell-lange.easynet.co.uk>,
'x'campbell-lange@easynet.co.uk (Rory C-L) wrote:

# Apologies if this seems to be too much of an os specific posting

Ack ... I just responded to this in alt.comp.lang.applescript.  See reply there.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Sat, 12 Jun 1999 16:39:01 +0100
From: jgrain <jgrain@yahoo.com>
Subject: Re: MIcrosofts Attack on Perl
Message-Id: <37627F15.A1AB80F7@yahoo.com>

jgrain wrote:

> "What is the current strategy of those at the very top"

If you replied to this post do you know the answer? - I hesitatingly point
that a limited number of the many respondants who spent their valuable time
first reading and then responding to this post did not reply to this
question, maybe it was because I missed out the ? after the question, for
people who English is not a first language, this may be challenging I
guess...........


> i.e. those who understand, believe and promote open source, particularly
> in reference

> to its influence on reducing the cost of computing and spreading the net
> of those involved in "serious" computing after the announcement that
> Microsoft will be "hijacking" Perls advantages, for their own commercial
> benefit.

OK, so the use of the word "hijacking" drew a range of  responses, from
passive to fairly emotive, as intended, an objective of this post although
not stated, was to see if the topic drew emotive responses, and what type of
response would be drawn.  Remember, you should carefully evaluate the source
of all information you process :-), this is typically done by those who have
had to spend time "researching" a particular domain of knowledge.


> Are people aware of the "negative" consequences of such a move,
> especially in relation to one of Perls core ojectives in relation to
> maintaining the language as "portable"?
>

Few respondees actually stated a negative consequence, this may be for a
number of reasons, I will however highlight that this could be as it is
usually very easy to take one side of a story when forming an opinion rather
than taking a "wiser" approach, by trying to form a "world view", achieved
by seeking feedback from all the stakeholders of the "system".

Personally, I am very glad to see that Microsoft have "recognised" the power
of Perl as a programming language, this may be due to a significant increase
of in the developement of applications for the internet and
intranets.........

I would hope that many of those who have contributed a significant amount of
time to the development of Perl as a programming language over the last
decade or more, can now reap & share some of the financial rewards that will
not doubt be presented to those who are "competent" in the development of
Perl applications.

> An answer to this post would be very much appreciated as I am one of the
> "few" who would actively participate in "movements" to counteract the
> negative force of "inforced capatilism".
>

Did anyone have a comment about this section, if memory and history serves
me correctly, then again there was little response to this comment.....

A wise man once said there are three types of people
Those who did not know it happened
Those who heard about it
Those who anticipated it happening

A question you should take very seriously, with thought, not emotion, is in
which category do you fit?

> Awaiting a reply from the high command!

The last one was answered...... :-)



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

Date: Sat, 12 Jun 1999 07:18:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: multiple match & replace regexp
Message-Id: <MPG.11cc0bef69a20359989bd0@nntp.hpl.hp.com>

In article <slrn7m3vvq.6t5.hasant@borg.intern.trabas.co.id> on 13 Jun 
1999 00:06:17 GMT, Hasanuddin Tamir <hasant@trabas.co.id> says...
> On Fri, 11 Jun 1999 19:18:32 +0200, Ondrej Palkovsky <xpalo03@vse.cz> wrote:
> > regurg wrote:
> > > What I don't know, however is this: what if I want to
> > > replace $1 ... $3 with something else? Analagous to this
> > > (which doesn't work):
> > >      if (/...( )...( )...( )/) {
> > >         $1 = "foo";
> > >         $2 = "bar";
> > >         $3 = "smar";
> > >      }
 ...
> > What about 
> > s/(...) (...) (...) /$1foo$2bar$3smar/;
> 
> search for `subroutine substitution'.
> shortly, you need a subroutine to process
> each match found.
> 
>    s/...(MATCH1|MATCH2).../a_function($1)/e

Why do you need a subroutine?  Any code can be evaluated; a subroutine 
call is just one special case.

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


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

Date: Sat, 12 Jun 1999 15:41:27 +0200
From: Hans Bolte <04282757-0001@t-online.de>
Subject: Prevent loading from Cache?
Message-Id: <37626387.29C0@t-online.de>

Hello,

can I prevent, that the browser loads the output from a cgi-script from
his cache?

Hans


--
Wie ist die Altersstruktur der Internetsurfer? Welche politischen
Ansichten haben sie? Wie hoch ist der Anteil der Sch|ler, Studenten,
Selbststdndigen, ...? Antworten gibt es unter
<http://www.hbolte.webprovider.com>.


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

Date: Sat, 12 Jun 1999 15:44:10 GMT
From: rsanders@ac.net
Subject: Printing
Message-Id: <37627ff6.10402054@news.ac.net>

I'm new to Perl programming and cannot find the command(s) I need to
send data to the printer.  I've been through three manuals and looked
online to no avail.  


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

Date: Sat, 12 Jun 1999 18:00:14 +0200
From: =?iso-8859-1?Q?Bj=F6rn?= Teegen <bjoern.teegen@gmx.de>
To: rsanders@ac.net
Subject: Re: Printing
Message-Id: <3762840E.2D0FF0B3@gmx.de>

> I'm new to Perl programming and cannot find the command(s) I need to
> send data to the printer.  I've been through three manuals and looked
> online to no avail.

One possibility is to write directly to the printer device:

# UNIX
open(PRINTER, '/dev/lp1');
print PRINTER "Hello, world!\n";
close(PRINTER);

# DOS
open(PRINTER, 'LPT1:');  # I am not sure if this works under DOS
print PRINTER "Hello, world!\n";
close(PRINTER);

Bjvrn



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

Date: Sat, 12 Jun 1999 11:34:11 -0500
From: "AEF" <aef@pangea.ca>
Subject: Stat mtime
Message-Id: <7ju258$8r5$1@pumpkin.pangea.ca>

I'm a newbie. Help please.

Reference my posting of a couple of days ago, and the responses,  I still
can't get stat going on to make a logical return.  The best I can do is get
the mtime  before the Epoch, (and the earliest file creation that I need to
stat is about 6 months old.)

I have tried LOTS of combinations, but obviously repeating mistakes
somewhere.

I was offered a couple of suggestions, but couldn't make them work.

Here's the clip that I want to get the mtime in a month day, year format for
the .old files.

I will worry about the sorting in order of most recent to oldest mtime, once
I can get a basic stat going on.

Thanks.

opendir(DIR, "$base_dir") || die "Can't open $base_dir\n";

  while($file = readdir(DIR)) {
        if($file =~ /.*\.$file_ext\.old/) {
            open(OLD, "$base_dir/$file") || die "Can't open $file\n";
            $data =<OLD>;
            close(OLD);
            $topic = $file;
            $topic =~ s/\..*//g;
         #do other stuff to present the information
        }
}




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

Date: Sat, 12 Jun 1999 13:28:43 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Subs that can operate on $_ in void context?
Message-Id: <37625fa6.3417363@enews.newsguy.com>

Hi,

is there a way for a sub to operate on the default variable ($_) if it
is used in a void context, much like chop and chomp do?

I'm thinking of something like

sub add1 {
	$_++ 
	# but only if used in a void context
	# this is what I don't know
}

$_ = 12;
add1;
# now $_ is 13

Can this be done?

TIA

Marcel


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

Date: 12 Jun 1999 15:09:27 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Subs that can operate on $_ in void context?
Message-Id: <7jtt77$2s0$1@gellyfish.btinternet.com>

On Sat, 12 Jun 1999 13:28:43 GMT Marcel Grunauer wrote:
> Hi,
> 
> is there a way for a sub to operate on the default variable ($_) if it
> is used in a void context, much like chop and chomp do?
> 

If you want to know the context that a subroutine was called in then
you will want to use the wantarray builtin :


#!/usr/bin/perl -w

use strict;

$_ = 12;

blah();

my $thing = blah();

my @thing = blah();


sub blah
{
  if (defined wantarray)
    {
     if (wantarray )
       {
         print "Array context\n";
       }
     else
       {
         print "Scalar context\n";
       }
    }
  else
    {
      print "Void context\n";
    }
}



> I'm thinking of something like
> 
> sub add1 {
> 	$_++ 
> 	# but only if used in a void context
> 	# this is what I don't know
> }
> 
> $_ = 12;
> add1;
> # now $_ is 13
> 

except thats not what you mean is it ? You have to be careful in the
way you use the term context - I think what you meant to ask was can
a subroutine be made to operate on $_ in the abscence of any parameters
right OK:


#!/usr/bin/perl -w

use strict;


$_ = 12;

blah();

print $_,"\n";

my $var = 12;

blah($var);

print $var,"\n";


sub blah()
{
  if (@_)
    {
      $_[0]++;
    }
  else
    {
      $_++;
    }
}

When a parameter is supplied this takes advantage of the fact that the
parameter list as supplied in @_ is aliased to the  actual parameters
supplied - if you dont want that behaviour then you need to assign the
values if @_ to something else.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Sat, 12 Jun 1999 07:07:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Verifying date data
Message-Id: <MPG.11cc09659123cd26989bcf@nntp.hpl.hp.com>

In article <slrn7m3vk0.3uj.abigail@alexandra.delanet.com> on 12 Jun 1999 
01:21:40 -0500, Abigail <abigail@delanet.com> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MMCXI September MCMXCIII in
> <URL:news:MPG.11cb4490afd9288989bc7@nntp.hpl.hp.com>:
 ...
> ""     && 0 <= $sec  && $sec  < 60
> "" } 
> 
> It doesn't deal with leap seconds!

I'm so glad you noticed.  It deals with Unix-epoch time, which doesn't 
deal with leap seconds -- all the misguided '61's (and '62's!) in the 
Unix documentation notwithstanding.

A quick peruse of deja.com for 'leap seconds' might avoid dredging this 
whole thing up again.

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


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

Date: Sat, 12 Jun 1999 16:50:31 +0200
From: Christoph Bergmann <info@java.seite.net>
Subject: Re: write the output of eval to a string?
Message-Id: <376273B7.44B4@java.seite.net>

Tom Phoenix wrote:
> 
> On Sat, 12 Jun 1999, Christoph Bergmann wrote:
> 
> > i've got a string containing perl code, which makes some output with
> > "print". i want to "eval" this code and write the output NOT to STDOUT
> > but to another string.
> 
> Use a tied filehandle. But it would be much better to fix the perl code to
> do what you want in the first place, of course. Cheers!

oops, thanx, i hoped there would be a more convenient way to do this...
;-)

but what exactly do you mean with a "tied filehandle". all i know is
that i can tie scalars, arrays and hashes - is there something like
"TIEHANDLE"? and if so, i can't see how this would help..!? please can
you give me a deeper description?

thanx,

christoph bergmann



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

Date: 12 Jun 1999 15:21:46 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: write the output of eval to a string?
Message-Id: <7jttua$2ut$1@gellyfish.btinternet.com>

On Sat, 12 Jun 1999 16:50:31 +0200 Christoph Bergmann wrote:
> Tom Phoenix wrote:
>> 
>> On Sat, 12 Jun 1999, Christoph Bergmann wrote:
>> 
>> > i've got a string containing perl code, which makes some output with
>> > "print". i want to "eval" this code and write the output NOT to STDOUT
>> > but to another string.
>> 
>> Use a tied filehandle. But it would be much better to fix the perl code to
>> do what you want in the first place, of course. Cheers!
> 
> oops, thanx, i hoped there would be a more convenient way to do this...
> ;-)
> 
> but what exactly do you mean with a "tied filehandle". all i know is
> that i can tie scalars, arrays and hashes - is there something like
> "TIEHANDLE"? and if so, i can't see how this would help..!? please can
> you give me a deeper description?
> 

In the first instance I would look at the perltie manpage and see if
it that answers your question;


       Tying FileHandles

       This is partially implemented now.

       A class implementing a tied filehandle should define the
       following methods: TIEHANDLE, at least one of PRINT,
       PRINTF, WRITE, READLINE, GETC, READ, and possibly CLOSE
       and DESTROY.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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