[22284] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4505 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 3 09:05:41 2003

Date: Mon, 3 Feb 2003 06:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 3 Feb 2003     Volume: 10 Number: 4505

Today's topics:
    Re: APL's relation to perl <bik.mido@tiscalinet.it>
    Re: APL's relation to perl <tassilo.parseval@post.rwth-aachen.de>
    Re: Attitude to Perl in academia <ubl@schaffhausen.de>
    Re: byte array in perl, how? pack, unpack? java to perl (vientoloco)
    Re: creating a binary file with desired size <nobull@mail.com>
    Re: Crossposting (was: Fetchrow Question) <nobull@mail.com>
    Re: inconsistent handling of undefined values? <nobull@mail.com>
    Re: Newbie question about getstore (Helgi Briem)
    Re: Parse a logfile - 1st column DateStamp; extract lat (shree)
    Re: Parse a logfile - 1st column DateStamp; extract lat <yliu@stemnet.nf.ca.remove_this>
    Re: passing arguments as key=>value pairs & setting def <bik.mido@tiscalinet.it>
    Re: Perl and ActiveDirectory Question (Helgi Briem)
    Re: Perl Operations (docs) (Helgi Briem)
        perl simple script (zr)
    Re: perl simple script (Tony L. Svanstrom)
    Re: perl simple script <tassilo.parseval@post.rwth-aachen.de>
    Re: perl simple script <josef.moellers@fujitsu-siemens.com>
    Re: perl simple script <admin@-NOSPAM-2host.com>
    Re: print if ... <admin@-NOSPAM-2host.com>
    Re: Suggest new answer to FAQ: detecting numbers with i (=?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?=)
    Re: Suggest new answer to FAQ: detecting numbers with i (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 03 Feb 2003 10:14:44 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: APL's relation to perl
Message-Id: <svas3v4juk3eoalcg26fcf8dk0ll9psdpu@4ax.com>

On Sun, 02 Feb 2003 22:13:38 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

>Indeed -- I made a mistake.  What I meant was, that particular construct
                    ^^^^^^^
>would have the effect of iterating over @foo, two elements at a time.

I don't think you really made a *mistake*: the difference is IMHO more
psycological/conceptual than practical.

>It does not operate on a list of 'pair' objects (such as the things
>constructed by perl6's "=>" operator).  Err, well, it could, but it

BTW: will "=>" operator be associative and thus enable to build
triples, etc.?

>Not to mention that one would likely lose the aliasing effect that perl
>automatically provides when iterating over a list with foreach().

Sorry for my dumb question, but... are you referring to the automatic
variable "$_"? If so, then this doesn't seem a major concern: one
array automatic variable might be used instead (or along as), to be
set with the n entries of a n-tuple (if a n-tuple type will exist,
considering a scalar as 1-tuple).

>You do realize that in perl6, all of perl's types will be objects?

All I know about perl6 I'm learning from this thread (and a few
others): incidentally I thank you very much for the provided
information - I know that I might find them on my own, OTOH it's nicer
to gather them in an informal discussion.

That all of perl's types will be objects is not too surprising after
all: AFAIK it's a common trend in modern languages...

>Alternatively, consider that perl6 programmers will probably be able to
>create their own binary operators...  So, one could create an '(x)'
>operator as follows:
>
>   my sub operator:(x) is prec(\&operator:+) (@a, @b) {
>      map { my $x = $_; map { $x, $_ } @b } @a;

This would be great in any case!! I wonder, just for curiosity, to
what extent this might be doable with perl5 and some OO+overloading
trickery...

Do you happen to know if perl6 will support functional-languages-like
features too?


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: 3 Feb 2003 09:49:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: APL's relation to perl
Message-Id: <b1ldvi$ei4$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Michele Dondi:

> On Sun, 02 Feb 2003 22:13:38 -0500, Benjamin Goldberg
><goldbb2@earthlink.net> wrote:

>>Alternatively, consider that perl6 programmers will probably be able to
>>create their own binary operators...  So, one could create an '(x)'
>>operator as follows:
>>
>>   my sub operator:(x) is prec(\&operator:+) (@a, @b) {
>>      map { my $x = $_; map { $x, $_ } @b } @a;
> 
> This would be great in any case!! I wonder, just for curiosity, to
> what extent this might be doable with perl5 and some OO+overloading
> trickery...

It's hardly doable now. Perl5 does not allow to define new operators. It
only allows to change the behaviour of already existing ops but then
you are still somewhat limited. AFAIK you currently can't for instance
turn a binary operator into a unary one (or vice versa). A binary
operator will still need two operands regardless of overloading. That's
because operators are processed by the parser at a time where perl does
not yet know about overloading. It just sees that there is an operand
missing and complains.

> Do you happen to know if perl6 will support functional-languages-like
> features too?

Which ones do you have in mind? 
I heard that Perl6 will have the lambda operator. That's not as
spectacular as it sounds since similar functionality can already be
achieved in Perl5 using closures (which themselves have a functional
background) and code-refs.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 03 Feb 2003 13:53:02 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Attitude to Perl in academia
Message-Id: <b1lrv0$fgo$1@news.dtag.de>

Benjamin Goldberg wrote:
> Malte Ubl wrote:
> 
>>Benjamin Goldberg wrote:
>>
>>>>   Actually, I think you'll find that Perl does have a typing
>>>>system, but it's of the form of languages like ML or Smalltalk;
>>>>it's an implicit typing system.
>>>
>>>
>>>No -- with ML and Smalltalk, every variable's type is inferred *at
>>>the time that the function is typed in*... in other words, at
>>>compile time.
>>
>>Are you sure about this?
> 
> 
> No. :)  I'm a perl programmer, and haven't touched Smalltalk for many
> years.
> 
> [snip stuff showing when SmallTalk infers types]
> 
> Well, I was kind of thinking of "inferring a type" as being similar to
> how C++'s templates magically handles inferring of types, or at least of
> the *abilities* a type needs to have to be used with that template.

> AFAIK, C++ is able, at the time it compiles foo, to know that 'blat'
> won't have an xyzzy method, even though T is unknown and vector<T> isn't
> quite a "real" type yet.

This is pretty much what Interfaces in Java do:

interface Runnable {
	public void run();
}

class Thread implements Runnable {
	public void run() {}
	public void baz() {}
}


somewhere in the code

public void foo(Runnable bar) {
	bar.run();
	bar.baz(); // This is a compile time error
}

Really, all this is doing is helping you to get your method names right. 
Since, pre/post-conditions/invariants are missing, it won't help you to 
get anything else right.

Plus, it all fails if you get things out of generic Collections, because 
you have to do a cast to actually be allowed to call methods on the 
objects. Whether the cast succeeds can only be know at runtime.


->malte



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

Date: 3 Feb 2003 05:51:23 -0800
From: vientoloco@msn.com (vientoloco)
Subject: Re: byte array in perl, how? pack, unpack? java to perl
Message-Id: <e7f013a1.0302030551.58b82349@posting.google.com>

How to send/receive the array of bytes through socket?

vientoloco@msn.com (vientoloco) wrote in message news:<e7f013a1.0301271042.759e1a6a@posting.google.com>...
> Hi, 
> This funtions are in java.
> I'll try to find similar functions in perl.
> Help, please :)
> Any tutorial?
> 
> 
> /**
>   * transforms a hexadecimal string to a byte array
>   * @return the byte array, or null if the passed String is null
>   * @exception IllegalArgumentException if the passed String is not
> haxadecimal encoded
>   */
>  public static byte[] fromHex(String hex) {
>    if (hex == null) {
>      return null;
>    }
>    else if ((hex.length() % 2) != 0) {
>      throw new IllegalArgumentException("Hex String length must be a
> multiple of 2.");
>    }
> 
>    int length = hex.length() / 2;
>    byte[] result = new byte[length];
>    String hits = "0123456789ABCDEF";
>    String h = hex.toUpperCase();
> 
>    for (int i = 0; i < length; i++) {
>      char c = h.charAt(2 * i);
>      int index = hits.indexOf(c);
>      if (index == -1) {
>        throw new IllegalArgumentException("Hex String can't contain '"
> + c +"'");
>      }
> 
>      int j = 16 * index;
>      c = h.charAt((2 * i) + 1);
>      index = hits.indexOf(c);
>      if (index == -1) {
>        throw new IllegalArgumentException("Hex String can't contain '"
> + c +"'");
>      }
> 
>      j += index;
> 
>      result[i] = (byte) (j & 0xFF);
>    }
> 
>    return result;
>  }
> 
> 
>   /**
>    * transforms a byte array into a hexadecimal String
>    * @return the hexadecimal String, or null if the passed array is
> null
>    */
>   public static String toHex(byte[] b) {
>     if (b == null) {
>       return null;
>     }
>     String hits = "0123456789ABCDEF";
>     StringBuffer sb = new StringBuffer();
> 
>     for (int i = 0; i < b.length; i++) {
>       int j = ((int) b[i]) & 0xFF;
> 
>       char first = hits.charAt(j / 16);
>       char second = hits.charAt(j % 16);
> 
>       sb.append(first);
>       sb.append(second);
>     }
> 
>     return sb.toString();
>   }
> 
> S. C. Mikel B. H.
> vientoloco@msn.com


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

Date: 3 Feb 2003 08:49:40 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: creating a binary file with desired size
Message-Id: <u9r8apzp53.fsf@wcl-l.bham.ac.uk>

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:

> In article <146277ca.0301301646.62e40a15@posting.google.com>,
> James Lee <csejl@yahoo.com> wrote:
> :i have a script that takes file name and size and creates a file of
> :the size specified.  this is currently done with texts and i was
> :wondering if i can do this with binary files.  thanks for your help in
> :advance.
> 
> Should be the same method either way: open the file for writing,
> invoke the perl function 'truncate' giving the length you want it
> to be.

I know this is OT, but you should be aware that on most Unix-like OSs
this will create a file that while logically full of zero-bytes
doesn't yet occupy any data blocks.  

I'm guessing the OP wants a way of pre-alocating disk space to avoid
unexpected ENOSPC later on.  For this truncate() is useless.

Of course on non-simple (e.g. journaled or compressed) filesystems
even filling the file with data is potentially not enough to avoid
ENOSPC.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 03 Feb 2003 12:12:03 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <u9bs1tzhpo.fsf@wcl-l.bham.ac.uk>

"mgarrish" <mgarrish@rogers.com> writes:

> "Brian McCauley" <nobull@mail.com> wrote in message
> news:u9hebp1amw.fsf_-_@wcl-l.bham.ac.uk...
> >
> > The whole point crossposted article is that is a single article that
> > appears in multiple groups because is has multiple items in the
> > Newsgroup line.
> >
> 
> Is that actually a sentence?

No, it is total gibberish.  Inserting the words "of" and "it",
and replacing "is" with "it" is left as an exercise for the reader.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 03 Feb 2003 12:11:41 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: inconsistent handling of undefined values?
Message-Id: <u9el6pzhqa.fsf@wcl-l.bham.ac.uk>

RA Jones <ra.jones@NO_UCE*cwcom.net> writes:

>  From there on I do some further manipulations on %results, but the
> essence of the problem is that if I try to print the contents of
> %results either via CGI to the browser or to a debug text-file, the
> system hangs indefinitely on my PC test-bed, but works fine on the
> UNIX production server.

I have observed exactly the same too.

I don't think it's a Perl thing.  

I think it's an CGI-Apache-windows thing.

Caused a bit of a panic here - we were moving a snapshot of one of our
projects from the Linux development platform to Windoze notebook demo
platform and suddenly it stopped working.  I dove in to debug it, and
in passing noticed the warning so I shoved in a "no warnings
qw(uninitialized)" arround the line and suddenly the demo worked.

I've not had time to look into it deeply but from what I've observed
so far I guess that if the CGI script emits anything on its STDERR
after it has started emitting stuff[1] on STDOUT then Apache freezes.

[1] I don't know if this means any bytes at all or the start of the
body or if it only takes effect after a certain number of bytes have
gone through.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 03 Feb 2003 13:31:19 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Newbie question about getstore
Message-Id: <3e3e6e3b.422178230@news.cis.dfn.de>

On Sun, 2 Feb 2003 01:40:27 -0000, "Tubs"
<dlaw001@yahoo.co.uk> wrote:

>I'm trying to grab some files from the internet on a regular basis, now I've
>been doing some reading and come across the getstore command....

Good.

>Now my test script is the following
>
>#!/usr/bin/perl
>
>use LWP::Simple;
>getstore("http://www.cygwin.com","tmp.html");
>
>Now after running the script (the system reports no errors), but it doesn't
>seem to have created the the file tmp.html. Now am I not doing something 
>or is there something else is going a bit a skew.

Your script works just fine for me.  You probably have
one of two problems.

1) You are not looking for tmp.html in the right place.
Give it a full path, something like:

my $file = '/usr/home/tubs/tmp.html';
my $url  = 'http://www.cygwin.com';
getstore ($url,$file);

2) You have not configured your firewall/proxy correctly.
You need to have an environment variable HTTP_PROXY 
set to something like: 
http://yourproxy.yourdomain:port_num

Look in your browser settings inf you are not sure what
this setting should be.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: 2 Feb 2003 21:32:45 -0800
From: srigowrisn@hotmail.com (shree)
Subject: Re: Parse a logfile - 1st column DateStamp; extract latest mods to an ItemNumber
Message-Id: <49b5740e.0302022132.50829136@posting.google.com>

ptjm@interlog.com (Patrick TJ McPhee) wrote in message news:<cuc%9.3084$Sq1.1315946@news.ca.inter.net>...
> In article <49b5740e.0302010535.7ee87eca@posting.google.com>,
> shree <srigowrisn@hotmail.com> wrote:
> 
> % I have a pipe separated log file of over 100,000 lines - a small
> % section of it is shown below. Its made up of
> % 
> % TimeStamp in YYYYMMDDHHMMSS
> % format|ItemNumber|Attribute1|Attribute2|Attribute3
> 
> [...]
> 
> % different dates over time. I need to find a way to extract the latest
> % modified line of each ItemNumber. For any given ItemNumber, all date
> 
> Assuming memory's not a problem (i.e., the total number if item numbers
> isn't too high), you could keep an array of all the latest versions and
> one of the latest dates, and test each new line against the date array:
> 
>   nawk -F"|" '$1 > dates[$2] { dates[$2] = $1; lines[$2] = $0 }
>               END { for (item in lines) print lines[item] }' logfile
> 
> Here are some long-winded explanations:
> 
>  nawk: I used awk because I'm answering from comp.lang.awk, to which I've
>        directed follow-ups. On your platform, /usr/bin/awk is the pre-1987
>        version of awk, and is not especially useful. The standard advice
>        is to use /usr/bin/nawk or /usr/xpg4/bin/awk. On Solaris, you should
>        generally put /usr/xpg4/bin first in your path, and send a complaint
>        to your vendor about the state of /usr/bin.
> 
> 
>  -F"|": this sets the default input delimiter to a pipe.
> 
>  $1 > dates[$2]: tests whether the first field is greater than the element
>        of the array `dates', which is indexed on the second field. If the
>        array element hasn't been set, it's initialised to "", and the test
>        will be true. If the test is true, the bit in braces executes, which
>        sets the dates array element to the date in the current record, and
>        the corresponding element of the array `lines' to the current record
> 
>  END:  this is a special pattern which is true after the input data has been
>        read. The associated action walks through the array `lines' and sets
>        `item' to the value of each array index, then prints the corresponding
>        line. This will come out in a seemingly arbitrary order.
> 
> 
> If memory is a problem, I suggest sorting by item number and doing something
> similar with scalar variables:
> 
>   sort -t'|' +1 logfile | awk 'litem && litem != $2 { print lrec; ldate = "" }
>                                $1 > ldate { ldate = $1; litem = $2; lrec = $0 }
>                                END { if (litem) print lrec }'

Hello everyone,

Thanks so much for showing me how to do this. I tried the various
awk/nawk and perl suggestions - all of the worked correctly and took
about the same time. I couldn't tell which one(s) are better than
others in terms of taking less system memory/resources. Thanks again
and hope someday I can return the favor.

Regards,
Shree


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

Date: Mon, 03 Feb 2003 06:56:59 GMT
From: "Dr. Yuan Liu" <yliu@stemnet.nf.ca.remove_this>
Subject: Re: Parse a logfile - 1st column DateStamp; extract latest mods to an ItemNumber
Message-Id: <3E3E14D0.8060205@stemnet.nf.ca.remove_this>

shree wrote:
[snip]
> about the same time. I couldn't tell which one(s) are better than
> others in terms of taking less system memory/resources. Thanks again
> and hope someday I can return the favor.

You can lauch with time(1) to see time difference, and use /usr/ucb/ps 
to see memory usage (or use top).  Ordinarily sed is lighter but this 
one requies iteration, only real data can tell.

Yuan Liu



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

Date: Mon, 03 Feb 2003 09:06:52 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: passing arguments as key=>value pairs & setting default options
Message-Id: <obeq3vkjtn26hbs4t13k0foi5dog1jh1pc@4ax.com>

On 1 Feb 2003 10:36:09 GMT, Tina Mueller <usenet@tinita.de> wrote:

>sub test {
>  my %options = (
>    foo => "foo-default",
>    bar => "bar-default",
>    baz => "baz-default",
>    @_
>  );
>  # ...
>}

I feel like an idiot for not having thought of this myself... of
course everything seems easy and straightforward after someone told it
to you!!


Thanks,
Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Mon, 03 Feb 2003 13:14:19 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl and ActiveDirectory Question
Message-Id: <3e3e6a0a.421104606@news.cis.dfn.de>

On Sun, 2 Feb 2003 11:07:18 -0500, "zoomtown"
<jdavis_5@zoomtown.com> wrote:

DON'T TOP POST!!

It annoys the regulars and severely damages your
chances of receiving a useful reply.

If you don't know what top-posting is and why it is
annoying, read: 

http://jargon.watson-net.com/jargon.asp?w=top%2Dpost

>> >> Is it possible to query the Active Directory
>> >> from Perl to find a specific user
>> >
>> > What is an "Active Directory" ?
>>
>> Instead of read, write, and execute, it has regular workouts and exercise.

>You are right, I made a bad assumption that everyone had at 
>least heard of AD. I apologize for my assumptions..

Even if they had and many properly have, they wouldn't 
answer questions about it here.

Dave Roth has written a multitude of modules useful
for Windows system administration.  

They are available from http://www.roth.net/perl/ and
http://search.cpan.org/author/DAVEROTH/
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Mon, 03 Feb 2003 12:53:44 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl Operations (docs)
Message-Id: <3e3e4890.412534262@news.cis.dfn.de>

On Fri, 31 Jan 2003 21:02:29 GMT, "Dick Penny"
<penny1482@attbi.com> wrote:

>
>> Further, the exhortation to look up perldoc X, is
>> shorthand to look up X in the standard Perl
>> documentation that comes standard with every
>> Perl installation.  It can be browsed and searched
>> with all kinds of tools, although the perldoc program
>> is bundled for that purpose.  On Activestate Perl
>> installations a copy of it is found in HTML format
>> under C:/Perl/html/ and it can be read online
>
>Au countraire my dear Helgi, searching Perldocs is most 
>DIFFICULT on my Win2K box, 

No it isn't.  I use it through the standard Windows
command prompt (cmd.exe) many, many times every
day.  I have absolutely no problem with it.  You are
probably doing something wrong.

>and the CPAN search mechanism is close to useless (not
>totally).

Useless?? In what way is it useless?

>The prior docs (from AS of course)((don't know how much prior)), 
>were GREAT. One could do a global search  in the MS 'help' tool/file
>format/distribution, a *.chm file I think.

God, I hated those.   I suppose an option for which
kind of documentation format you like might be nice
for those who actually like the Windows Help format.
The Pod::Text or Pod::Hlp modules might help.

>I have no idea why AS decided on the 'pure' html and browser
> approach - it stinks.

Au contraire.  I find it very useful, but then, 95% of the
time I know which document to read, and unlike most
man pages, the perl docs stick what you *really* need to
know in the first 10-20 lines most of the time.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: 3 Feb 2003 01:28:49 -0800
From: zabo@mixmail.com (zr)
Subject: perl simple script
Message-Id: <70ac9e9a.0302030128.20fb5e10@posting.google.com>

hi,

I work in java, I have to program a very basic perl scipt. I have
never done anything in perl, but I hoped the script is so simple, it
would only take me an hour at
most...but I have already spent an hour with no results. I am sure
perl is great, but as I dont intend to need perl in the near future,
investing the
time needed to follow a tutorial etc would not pay off. 
So I hope someone can invest a minute to program my script...
-input params: a filename, and a regexp expresion
-output: boolean indication wether the regexp is contianed in the file

thansk indeed


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

Date: Mon, 03 Feb 2003 09:55:09 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: perl simple script
Message-Id: <1fpswuy.19d5oschmfxm4N%tony@svanstrom.com>

zr <zabo@mixmail.com> wrote:

> I work in java, I have to program a very basic perl scipt. I have never
> done anything in perl, but I hoped the script is so simple, it would only
> take me an hour at most...but I have already spent an hour with no
> results. I am sure perl is great, but as I dont intend to need perl in the
> near future, investing the time needed to follow a tutorial etc would not
> pay off.
> So I hope someone can invest a minute to program my script...
> -input params: a filename, and a regexp expresion
> -output: boolean indication wether the regexp is contianed in the file

 Sorry, too lazy, but...

 This is what a oneliner might look like:

perl -e '$a = "^b{3}c"; $d = "bbbbc"; print "ok\n" if $d =~ /$a/'

 That along with `perldoc CGI` and `perldoc -f open` ought to be enough
for you to complete your task within an hour. =)


-- 
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #

    perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'


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

Date: 3 Feb 2003 09:56:15 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: perl simple script
Message-Id: <b1lebv$etu$1@nets3.rz.RWTH-Aachen.DE>

Also sprach zr:

> I work in java, I have to program a very basic perl scipt. I have
> never done anything in perl, but I hoped the script is so simple, it
> would only take me an hour at
> most...but I have already spent an hour with no results. I am sure
> perl is great, but as I dont intend to need perl in the near future,
> investing the
> time needed to follow a tutorial etc would not pay off. 
> So I hope someone can invest a minute to program my script...

You must be kidding. I re-hash: You need to do a programming-task in
Perl but don't think investing some time into Perl would pay off. And
now you expect us to do your work. Is that right?

> -input params: a filename, and a regexp expresion
> -output: boolean indication wether the regexp is contianed in the file

This is probably just three lines of Perl but don't expect anyone to
help you with this attitude of yours. Either show us what you have tried
so far (that is, show us your Perl code) or go away.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 03 Feb 2003 11:30:18 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: perl simple script
Message-Id: <3E3E44BA.F2D1FE8F@fujitsu-siemens.com>

zr wrote:
> =

> hi,
> =

> I work in java, I have to program a very basic perl scipt. I have
> never done anything in perl, but I hoped the script is so simple, it
> would only take me an hour at
> most...but I have already spent an hour with no results. I am sure
> perl is great, but as I dont intend to need perl in the near future,
> investing the
> time needed to follow a tutorial etc would not pay off.
> So I hope someone can invest a minute to program my script...
> -input params: a filename, and a regexp expresion
> -output: boolean indication wether the regexp is contianed in the file

Why the insistence in Perl, inarguably a very good language.
This one can be solved with a call to grep.

grep <regex> <filename>
The exit status of grep is 0 (success) if the regex occurs in filename
and nonzero (failure) if it doesn't.

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Mon, 03 Feb 2003 03:35:20 -0800
From: "2Host.com - Robert" <admin@-NOSPAM-2host.com>
Subject: Re: perl simple script
Message-Id: <3E3E53F8.F9EEE404@-NOSPAM-2host.com>



zr wrote:
> 
> hi,
> 
> I work in java, I have to program a very basic perl scipt. I have
> never done anything in perl, but I hoped the script is so simple, it
> would only take me an hour at
> most...but I have already spent an hour with no results. I am sure
> perl is great, but as I dont intend to need perl in the near future,
> investing the
> time needed to follow a tutorial etc would not pay off.
> So I hope someone can invest a minute to program my script...
> -input params: a filename, and a regexp expresion
> -output: boolean indication wether the regexp is contianed in the file
> 
> thansk indeed

I'm left wondering, do you _have_ to do this in Perl? Perhaps you can
just code it in a language you are more familiar with, or just use some
common command line program(s)?
-- 
Regards,
Robert McGregor - Email: admin@(remove)2host.com. Phone: 530-941-0690
Server admin, support & programing for shared & dedicated web servers
Secure, reliable hosting you expect and deserve! http://www.2host.com


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

Date: Mon, 03 Feb 2003 03:37:47 -0800
From: "2Host.com - Robert" <admin@-NOSPAM-2host.com>
Subject: Re: print if ...
Message-Id: <3E3E548B.2B147E6E@-NOSPAM-2host.com>



Walter Roberson wrote:
> 
> In article <3E3DD50E.A0A2A24A@real.bad.com>,
> istink  <istink@real.bad.com> wrote:
> :I think I saw something like this:
> :print if ($a == $b)...
> :or am I having one of my many delusions?
> :an if inside of an existing line of code?

What is your question? What are you trying to do? If you are asking if
your can "print $value if ($value == $othervalue); (if you're working
with numerals), yes. You can use eq for strings. What's your specific
question/problem?
-- 
Regards,
Robert McGregor - Email: admin@(remove)2host.com. Phone: 530-941-0690
Server admin, support & programing for shared & dedicated web servers
Secure, reliable hosting you expect and deserve! http://www.2host.com


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

Date: 3 Feb 2003 01:19:26 -0800
From: peter@morch.com (=?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?=)
Subject: Re: Suggest new answer to FAQ: detecting numbers with is_numeric
Message-Id: <5233f254.0302030119.7d32e374@posting.google.com>

Oh, Anno, I like your solution _so_ much better.... However, the no
warnings you suggest is necessary to be on the safe side if I 'use
warnings' somewhere else. So - in summary:

sub is_numeric {
  no warnings;
  use warnings FATAL => 'numeric';
  return defined eval { $_[ 0] == 0 };
}

Could we put this in the FAQ? It is so much more elegant than what is
there now.

Regards,

Peter

-------------------------------------
I minor anal comment... 
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b1b8vq$pil$1@mamenchi.zrz.TU-Berlin.DE>...
> >   return ($warned) ? 0 : 1;
> 
> Just return $warned (same thing).
That would be (!$warned), right?


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

Date: 3 Feb 2003 10:34:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Suggest new answer to FAQ: detecting numbers with is_numeric
Message-Id: <b1lgj2$afr$1@mamenchi.zrz.TU-Berlin.DE>

Peter Valdemar Mørch <peter@morch.com> wrote in comp.lang.perl.misc:
> Oh, Anno, I like your solution _so_ much better.... However, the no
> warnings you suggest is necessary to be on the safe side if I 'use
> warnings' somewhere else. So - in summary:

I don't see the need to disable other warnings, but one should make
sure 'numeric' is the only FATAL one in the scope.

    use warnings NONFATAL => 'all', FATAL => 'numeric'

should do that.  If other warnings are triggered by the code, the user
should see them if they are enabled.

> sub is_numeric {
>   no warnings;
>   use warnings FATAL => 'numeric';
>   return defined eval { $_[ 0] == 0 };
> }
> 
> Could we put this in the FAQ? It is so much more elegant than what is
> there now.

It has another problem.  If "is_numeric( $x)" is called, and $x is
a tied (or otherwise magic) variable, other fatal errors could happen
which would be veiled by eval().  Likewise if $x contains an object
that has "0+" (nummification) overloaded.

To catch these cases we'd have to go back to checking $@ after the eval().

Anno


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 4505
***************************************


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