[7549] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1175 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 14 15:09:18 1997

Date: Tue, 14 Oct 97 12:00:47 -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           Tue, 14 Oct 1997     Volume: 8 Number: 1175

Today's topics:
     Re: [MacPerl] first file in a folder... <bbrace@get.wired.com>
     [Q] executing a perl script on a win-nt box <cjk@vms.cis.pitt.edu>
     Re: Accessing Oracle DB using Perl - What do I need? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     ANNOUNCE Date::Manip-5.20 (Sullivan N. Beck)
     CGI.pm and variable named form elements <bugaj@bell-labs.com>
     Re: CGI.pm and variable named form elements (Robert Patrick)
     Re: CGI.pm and variable named form elements <bugaj@bell-labs.com>
     Constants <achoy@us.oracle.com>
     looking for efficiency <ramon@ramonc.icix.net>
     Looking for script to parse ps output <chris@ixlabs.com>
     Re: most efficient way to find the LAST line number in  (Tad McClellan)
     Re: most efficient way to find the LAST line number in  (Tim Goodwin)
     Re: One line word count? <tycage@infi.net>
     Re: One line word count? (brian d foy)
     Problem using "Storable" module <wayne@misinfo.com.au>
     Re: Problem with Time (Clay Irving)
     Re: reg exp size limit !? <sartang@pcocd2.intel.com>
     Re: Reg expr. question (SEARCH and REPLACE) <sgordon@athena.lbl.gov>
     Re: Search: Reference Book (Christophe ODDO)
     Re: split(/$dirsep/) problem ($dirsep = "\\") (brian d foy)
     Sr. Web Architect Needed - NJ <cgaston@lds.com>
     Re: statics or const in perl ? <sartang@pcocd2.intel.com>
     sybperl/oraperl (Patrick Charles Perroud)
     Trying to pass a file handle under strict mode <achoy@us.oracle.com>
     Writing/Reading Bin Files (need example) (James A. Kivisild)
     Re: Writing/Reading Binary Files (Andrew M. Langmead)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Oct 1997 11:11:01 -0700
From: { brad brace } <bbrace@get.wired.com>
Subject: Re: [MacPerl] first file in a folder...
Message-Id: <Pine.BSI.3.95.971014110713.22237F-100000@get.wired.com>


Can anyone please suggest a script for this dialup shell-account user?



> At 15.11 10/13/97, { brad brace } wrote:
> >I'm trying to write a script that will:
> >
> >1) every 12 hours: select the first file in a folder (Mac 68K OS
> >   ideally)... I have Mac-Cron installed... and...
> >
> >2) dialup my ISP and upload the file to several FTP sites (I have
> >   Microphone-comm-software scripts that can dialup -- I can't seem to
> >   make them select a specific file though...) (I have MacPerl installed.)
> >
> >3) then, either delete or move this first file from the folder, so that
> >   the next numerically-named file will become the next 'first-one'
> >
> >4) and so on...
> 



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

Date: Tue, 14 Oct 1997 13:44:14 -0400
From: Carl Joel Kuzmich <cjk@vms.cis.pitt.edu>
Subject: [Q] executing a perl script on a win-nt box
Message-Id: <3443AF6E.5C742D2A@vms.cis.pitt.edu>

Hi all

Maybe someone could help me with a problem that I'm having. I know that
the first line of a *.pl program on a unix box starts something like so:
#!/usr/bin/perl

My question is this: What do use as the first line when the file is on
an NT-box???

Any and all help will be greatly appreciated.

Could you email me please at: cjk+@pitt.edu

thanks in advance.



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

Date: Tue, 14 Oct 97 14:06:34 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Accessing Oracle DB using Perl - What do I need?
Message-Id: <3443b4c9$2$ofn$mr2ice@speaker>

In <61tt9d$j77@crl.crl.com>, on 10/13/97 at 12,
   mjr@crl.crl.com (Matthew Rapaport) said:
+-----
| I am looking for a way to access an Oracle 7.x DB using Perl. I have a 
+--->8

Last I saw, Oracle had some Perl5 stuff for interfacing to Oracle7 on their
web site.

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                 KF8NH
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org
Memo to MLS:  End The Burn Scam --- Doug Logan MUST GO!  FORZA CREW!



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

Date: 14 Oct 1997 12:33:21 -0400
From: sbeck@cise.ufl.edu (Sullivan N. Beck)
Subject: ANNOUNCE Date::Manip-5.20
Message-Id: <xz3vhz0719q.fsf@waterspout.cise.ufl.edu>


I just added the newest version of Date::Manip to PAUSE.  It'll be at your
nearest CPAN site within a couple of days.  This incorporates a number of
bug fixes as well as adding full support for ISO 8601 date formats.  Support
for ISO 8601 introduces some incompatibilities with respect to the previous
version.

Here's the README file:
========

Copyright (c) 1995-1997 Sullivan Beck. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

For information on installing Date::Manip, see the INSTALL file included in
the distribution.

Please send questions or bug reports to me rather than posting them to
a newsgroup since I may miss them there, but read the next paragraph
before you automatically start firing off email to me!

If you have questions about Date::Manip, refer to the Date::Manip man page
included as pod documentation in the Manip.pm file.  Don't know what I'm
talking about?  Read the perlpod man page.  Alternately, an online version
of the Date::Manip man page is included in my home page given below.
PLEASE read the man page thoroughly before posting any questions about
Date::Manip to a newsgroup or emailing me.  If you've done this, I'll be
glad to answer any questions not covered in the man page.


Notes for version 5.20:
  Added ISO 8601 date formats.
  Added ParseDateString for speed.
  Changed week handling to meet ISO 8601 standards.
  Added %J and %K UnixDate formats.
  Added some speedups (more to come).
  Added more Parse formats:
     last day in mmm in YY             "last day of October"
     dofw                              "Friday" (Friday of current week)
     Nth                               "12th", "1st" (day of current month)

  
  Version 5.20 has some incompatibilities with previous versions:
    Some old formats were removed since they conflicted with ISO 8601
       formats.  MM-DD-YY (conflicts with YY-MM-DD), YYMMDD (conflicts
       with YYYYMM).
    Weekdays are now numbered 1-7 (mon-sun) instead of 0-6 (sun-sat)
    By default the week now starts with Monday instead of Sunday to meet
       ISO 8601.  The FirstDay variable can be set to 7 to set Sunday as
       the first day.
    By default, the 1st week of the year contains Jan 4 (ISO 8601).  See
       the Jan1Week1 variable for overriding this.

  ############################################################################
  If you would like to stay informed about future versions of this module,
  and especially if you are interested in beta testing future versions,
  please let me know by email at:
    sbeck@cise.ufl.edu

  The newest version (which should be considered a beta version) is available
  through my home page:
    http://www.qtp.ufl.edu/~beck
  Feel free to try it out.

  The current (non-beta) version of this module is available from you nearest
  CPAN site and is NOT available from my home page.  I will announce new
  (non-beta) releases in comp.lang.perl.misc and comp.lang.perl.announce.  
  ############################################################################


This is a set of routines designed to make any common date/time
manipulation easy to do.  Operations such as comparing two times,
calculating a time a given amount of time from another, or parsing
international times are all easily done.

Date::Manip deals only with the Gregorian calendar (the one currently in
use).  The Julian calendar defined leap years as every 4th year.  The
Gregorian calendar improved this by making every 100th year NOT a leap
year, unless it was also the 400th year.  The Gregorian calendar has been
extrapolated back to the year 1000 AD and forward to the year 9999 AD.
Note that in historical context, the Julian calendar was in use until 1582
when the Gregorian calendar was adopted by the Catholic church.  Protestant
countries did not accept it until later; Germany and Netherlands in 1698,
British Empire in 1752, Russia in 1918.  Note that the Gregorian calendar
is itself imperfect.  Each year is on average 26 seconds too long, which
means that every 3,323 years, a day should be removed from the calendar.
No attempt is made to correct for that.

Date::Manip is therefore not equipped to truly deal with historacle dates,
but should be able to perform (virtually) any operation dealing with a
modern time and date.

Among other things, Date::Manip allow you to:

1.  Enter a date and be able to choose any format conveniant

2.  Compare two dates, entered in widely different formats to determine
    which is earlier

3.  Extract any information you want from ANY date using a format string
    similar to the Unix date command

4.  Determine the amount of time between two dates

5.  Add a time offset to a date to get a second date (i.e. determine the
    date 132 days ago or 2 years and 3 months after Jan 2, 1992)

6.  Work with dates with dates using international formats (foreign month
    names, 12/10/95 referring to October rather than December, etc.).

Each of these tasks is trivial (one or two lines at most) with this package.

Although the word date is used extensively here, it is actually somewhat
misleading.  Date::Manip works with the full date AND time (year, month,
day, hour, minute, second, and will ignore fractional seconds).

In the documentation below, US formats are used, but in most (if not all)
cases, a non-English equivalent will work equally well.

EXAMPLES:

1.  Parsing a date from any conveniant format

  $date=&ParseDate("today");
  $date=&ParseDate("1st thursday in June 1992");
  $date=&ParseDate("05/10/93");
  $date=&ParseDate("12:30 Dec 12th 1880");
  $date=&ParseDate("8:00pm december tenth");
  if (! $date) {
    # Error in the date
  }

2.  Compare two dates

  $date1=&ParseDate($string1);
  $date2=&ParseDate($string2);
  if ($date1 lt $date2) {
    # date1 is earlier
  } else {
    # date2 is earlier (or the two dates are identical)
  }

3.  Extract information from a date.

  print &UnixDate("today","The time is now %T on %b %e, %Y.");
  =>  "The time is now 13:24:08 on Feb  3, 1996."

4.  The amount of time between two dates.

  $date1=&ParseDate($string1);
  $date2=&ParseDate($string2);
  $delta=&DateCalc($date1,$date2,\$err);
  => 0:0:DD:HH:MM:SS   the days, hours, minutes, and seconds between the two
  $delta=&DateCalc($date1,$date2,\$err,1);
  => YY:MM:DD:HH:MM:SS  the years, months, etc. between the two

  Read the documentation in the man page for an explanation of the difference.

5.  To determine a date a given offset from another.

  $date=&DateCalc("today","+ 3hours 12minutes 6 seconds",\$err);
  $date=&DateCalc("12 hours ago","12:30 6Jan90",\$err);

  It even works with business days:

  $date=&DateCalc("today","+ 3 business days",\$err);

6.  To work with dates in another language.

  &Date_Init("Language=French","DateFormat=non-US");
  $date=&ParseDate("1er decembre 1990");

NOTE: Some date forms do not work as well in languages other than English,
but this is not because DateManip is incapable of doing so (almost nothing
in this module is language dependent).  It is simply that I do not have the
correct translation available for some words.  If there is a date form that
works in English but does not work in a language you need, let me know and
if you can provide me the translation, I will fix DateManip.

For documentation on all of the date manipulation routines, read the
man page.

AUTHOR

Sullivan Beck (sbeck@cise.ufl.edu)



------------------------------------------------------------------------------
Sullivan Beck                      http://www.cise.ufl.edu/~sbeck/
 sbeck@cise.ufl.edu  | This space reserved for some saying demonstrating great
 PH : (352) 392-1057 | wisdom, wit, or insight.  I'll fill it in just as soon
 Fax: (352) 392-1220 | as I have any of the above.
------------------------------------------------------------------------------


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

Date: Tue, 14 Oct 1997 12:33:47 -0400
From: Stephan Vladimir Bugaj <bugaj@bell-labs.com>
Subject: CGI.pm and variable named form elements
Message-Id: <34439EEB.59E2@bell-labs.com>

I looked in the online docs at your website for CGI.pm... It clearly
explains how to use a static string as the name of a form element, but
how do I get a variable to be the name of a form element?

I tried:

$query->textfield(-name=>$foo);
$query->textfield(-name=>"$foo");

both to no avail (the form winds up with NAME=" " where $foo should have
been). Clearly '$foo' just gives the string $foo as the name of
the form field... 

I want to be able to do this

foreach $fieldname (@fields)
{
	$query->textfield(-name=>$fieldname, ...
	  ... more code... 
}

Thanks.

LL+P,
Stephan



-- 
                        "Do computers think?"
------------------------------------------------------------------------
Stephan Vladimir Bugaj		                     bugaj@bell-labs.com
Member of Technical Staff	              	          (908) 949-3875
Multimedia Communication Research Dept.              Rm. 4F-601, Holmdel
Bell Labs of Lucent Technologies            www.multimedia.bell-labs.com
PGP Key available from www.pgp.net/wwwkeys.html or your local keyserver.
Non-Lucent personal website located at
www.cthulhu-dynamics.com/stephan.  
------------------------------------------------------------------------
 STANDARD DISCLAIMER:  My opinions are NOT necessarily those of LUCENT.
------------------------------------------------------------------------
                "Do submarines swim?" - E.W. Dijkstra


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

Date: Tue, 14 Oct 1997 16:34:47 GMT
From: rpatrick@ix.netcom.com (Robert Patrick)
Subject: Re: CGI.pm and variable named form elements
Message-Id: <34449d75.4259462@nntp.ix.netcom.com>

On Tue, 14 Oct 1997 12:33:47 -0400, Stephan Vladimir Bugaj
<bugaj@bell-labs.com> wrote:

>I looked in the online docs at your website for CGI.pm... It clearly
>explains how to use a static string as the name of a form element, but
>how do I get a variable to be the name of a form element?
>
>I tried:
>
>$query->textfield(-name=>$foo);
>$query->textfield(-name=>"$foo");
>
>both to no avail (the form winds up with NAME=" " where $foo should have
>been). Clearly '$foo' just gives the string $foo as the name of
>the form field... 
>
>I want to be able to do this
>
>foreach $fieldname (@fields)
>{
>	$query->textfield(-name=>$fieldname, ...
>	  ... more code... 
>}

I am currently using both styles shown above with no problems.  Are
you sure that $foo actually has a value?  Try something like this
directly before the call to textfield() to make sure that $foo is what
you expected:

print $query->p("foo = $foo");

Just my two cents,
Robert



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

Date: Tue, 14 Oct 1997 13:31:18 -0400
From: Stephan Vladimir Bugaj <bugaj@bell-labs.com>
Subject: Re: CGI.pm and variable named form elements
Message-Id: <3443AC66.3F54@bell-labs.com>

Should have been... 

> I looked in the online docs at Lincoln Stein's website for CGI.pm...
				 ^^^^^^^^^^^^^^^
Oosp.

Anyway, please CC me in email on any answers to my question about 
variables for names of form elements in CGI.pm.

Thanks.

LL+P,
Stephan


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

Date: Tue, 14 Oct 1997 11:41:21 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Constants
Message-Id: <3443BCD1.3BE6@us.oracle.com>

Hi.

I'm sure this question has been bandied about, but I haven't seen
in FAQS or in the newsgroup, so here I go.

Is there a way to declare constants in Perl, like finals in Java?

thanks--Allen


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

Date: Tue, 14 Oct 1997 10:02:47 -0400
From: Ramon Castillo <ramon@ramonc.icix.net>
Subject: looking for efficiency
Message-Id: <34437B87.1B64@ramonc.icix.net>

I wrote a Perl Script that takes a Config. file like, declares constants
to any other Scripts. It works very well so far, but probably is not the
state of the art.

I'm not looking for criticism just an advise to do the same job more
efficiently.
 
 Plataform Perl 5.004_01 Solaris 2.5
 ---------------------------------------------------
 config.
 #######################################
 #
 # here goes any yada yada bla bla bla
 #
 ######################################
 
 foo: (anyvalue);
 
 ####notice the next is a multiline sentence
 
 hash: (joe,
        bill,
        you,
        and,
        me);
 ---------------------------------------------------
 
 #!/usr/local/bin/perl
 {
 open (CONFIG, "config") || die"Can't open Config. file: $!";
 
 while (<CONFIG>){
       next if (/^#/ || /^\s*$/ ) ;
       chop ;
       s/^\s+//g;
       s/\s+$//g;
       $strip = $strip.$_ ;
      }
 @strip = split (/;/, $strip);
 foreach $line (@strip) {
         $line =~ /^([^ ]*): * \(([^ ].*?)\)/;
         @{$1} = split (/,/, $2);
         if (!$#{$1}) {${$1} = $2};
        }
 };1
 --------------------------------------------------------
 
It returns to the caller Scripts:
 
print "$foo\n";    ####notice in this case returns a scalar context
 
>anyvalue
 
print ("@hash","\n");   ### notice in this case returns a hash
 
>joebillyouandme
 
It works pretty good for me.
 
Have a nice hacking..
 
RC
-- 
#!/usr/local/bin/perl

use Hart::WithBrain;
while ($god->bless == $Internet && $Perl == $Cool){
       $Be = "Happy";
       $Live = "Love";
       $Hack = "Fun";
}      #  RC          ray@icix.net


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

Date: Tue, 14 Oct 1997 10:44:02 -0700
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Looking for script to parse ps output
Message-Id: <3443AF61.CB1581D9@ixlabs.com>

I need a script that will parse GNU ps -aux output.
Any pointers would be appreciated.

If anyone has one, or at least some field width specifiers (it's hard to
tell looking at the output), I will convert it into a .pm and return an
array of process objects.


Thanks,
Chris


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

Date: Tue, 14 Oct 1997 10:05:57 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: most efficient way to find the LAST line number in a file
Message-Id: <lo1026.da1.ln@localhost>

Krishan Purahoo (kpur@jet.uk) wrote:
: What is the most efficient method to get the  LAST line number
: of a file, in perl (no system call). 

The *most efficient* method is to store information ahead of time
about byte offsets for each line (ie. index the file).

The filesystem has no concept of "lines". It is just a byte stream,
sometimes there is a byte whose value is 10 (decimal), but to
the filesystem it is just another byte.

"lines" are convenient for humans to deal with, so we often coerce
our programs to chunk up the byte stream into lines for us.



: Reading the file in an array seems to be quite slow

You don't need to save it in an array to count it:

   while (<>) {$linecnt++}


: Can I use seek for this?


You can 'guess' how many bytes from the end of the file a '10' byte
is, read that much and deal with

1) there was no 10 byte (read backwards some more)

2) there was more that one 10 byte (take the last one)



If it is a large file, 
   index it somehow, 
else 
   read the whole file.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 14 Oct 1997 15:33:03 GMT
From: tgoodwin@nan.cygnus.co.uk (Tim Goodwin)
Subject: Re: most efficient way to find the LAST line number in a file
Message-Id: <6203bf$io7$1@korai.cygnus.co.uk>

In article <61vv2s$8sn$1@flex.news.pipex.net>,
Krishan Purahoo <kpur@jet.uk> wrote:
>What is the most efficient method to get the  LAST line number
>of a file, in perl (no system call). 

    $ perl -ne 'END { print $., "\n" }' file

In a longer script, you could use something like this (beware that this
only counts lines if $/ == "\n").

    $line = 0;
    while (<IN>) {
            ++$line;
    }

>Reading the file in an array seems to be quite slow

If you don't need the file's contents, then you should throw each line
away after you've read it (as the above examples do).  If you store them
all in an array, then Perl has to allocate enough memory to hold the
entire file!

>Can I use seek for this?

No.  The operating system has no idea how many lines a file contains, it
sees it as merely a string of bytes.  To discover the number of lines in
a file, you must read each of those bytes, and count how many are the
newline character.

Tim.
-- 
Tim Goodwin | "Gateways are designed for the purpose of losing information;
Cygnus, UK  | some do better than others." -- Dave Crocker


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

Date: Tue, 14 Oct 1997 12:38:31 -0400
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: One line word count?
Message-Id: <3443A007.16732DDB@infi.net>

Pete Ashdown wrote:
> 
> I'm trying to figure out a single statement method of counting instances of
> a word in a line.  I've been using split (with the word as a separator),
> but I don't believe it is entirely accurate all the time.

This is what I came up with.

+---+
#!/usr/local/bin/perl -w

$line = 'This is a test. Test test test. I am testing because this is
only a tes
$wordtocount = 'test';

$number = ((undef) = $line =~ /(\b$wordtocount\b)/ig);

print "'$line' contains the word '$wordtocount' $number times\n";
+---+
which gives

'This is a test. Test test test. I am testing because this is only a
test.' contains the word 'test' 5 times'

This is off the top of my head, but it might be what you are looking
for.

Ty

+---+
Ty Cage Warren                                           tycage@infi.net
Systems Engineer                                                 InfiNet
Homepage: http://tazer.engrs.infi.net/~tycage
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: Tue, 14 Oct 1997 13:09:51 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: One line word count?
Message-Id: <comdog-ya02408000R1410971309510001@news.panix.com>

In article <61vfk6$73r@slack.xmission.com>, pashdown@slack.xmission.com (Pete Ashdown) wrote:

>I'm trying to figure out a single statement method of counting instances of
>a word in a line.  I've been using split (with the word as a separator),
>but I don't believe it is entirely accurate all the time.

it would be easier to see what you were doing if you showed a snippet :)

as for the single statement method - why?  single statements are not
necessarily better than something that works and is maintainable.  besides,
any number of statements can be collected together in a subroutine to
make a single statement.

here are three different methods to do what you want:

   #!/usr/bin/perl -wT
   
   $line = 'this one, this one, this one, but not that one';
   $word = 'this';
   
   #####################################################################
   #
   # split on $word, then count the pieces.  remember that for N
   # occurances or $word we get N+1 pieces
   $word_count_1 = scalar(@array = split /\Q$word/, $line ) - 1;
   $" = '--';
   print "@array\n\n";
   
   #####################################################################
   #
   # increment a counter while looping through a global match
   while( $line =~ m/\Q$word/go ) { $word_count_2++ }
   
   #####################################################################
   #
   # find the offsets of the $word substring.  the number of 
   # occurances is the number of offsets we find.
   $position = -1;
   $length   = length $word;
   while( ($position = index $line, $word, $position) > -1 )
      {
      push @offsets, $position;
      
      $position += $length;
      }
   $word_count_3 = scalar @offsets;
   $" = ', ';
   print "offsets = @offsets\n\n";
   
   #####################################################################
   print<<"HERE";
   word count 1: $word_count_1
   word count 2: $word_count_2
   word count 3: $word_count_3
   
   HERE
   
   __END__
   
   -- one, -- one, -- one, but not that one
   
   offsets = 0, 10, 20
   
   word count 1: 3
   word count 2: 3
   word count 3: 3

-- 
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, 15 Oct 1997 04:26:59 +1000
From: Wayne Blick <wayne@misinfo.com.au>
Subject: Problem using "Storable" module
Message-Id: <3443B973.6C90@misinfo.com.au>

Hi all!

I'm getting "Not a scalar string at ... thaw.al ..." error.

All the storable tests pass OK, and using storable freeze/thaw in same
program works OK too.

I'm trying to freeze a structure say ['abc', 'def', 'ghi'] then send it
via a socket to another program for thawing.

The string is received OK and intact (same length, and dumpvar shows
same data) but thaw croaks.

Any ideas?  May be it's platform specific.  Using Linux 1.2.13 and
latest Perl 5.4.1.

Thanks.


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

Date: 14 Oct 1997 12:07:05 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Problem with Time
Message-Id: <6205b9$1rb@panix.com>

In <3443178F.E89F58D0@sysdata.siemens.at> Csillag Csaba <Csaba.Csillag@sysdata.siemens.at> writes:

>I write a CGI script in Perl that receives two parameters, year and
>month. The script should tell how many days in the given month are .  I
>tried to use the timelocal() function, but i didn't have success. Has
>anyone an idea, how to get the number of days of the given month?
>Additionaly,I would like to know which day of the week the first day of
>the given month is.

Perl Modules are your friend.

Date::DateCalc provides this function:

  days_in_month($year,$mm)

See: http://reference.perl.com/module.cgi?Date::DateCalc

-- 
Clay Irving <clay@panix.com>                   http://www.panix.com/~clay/


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

Date: Tue, 14 Oct 1997 09:59:56 -0700
From: Saviz Artang - MPG ~ <sartang@pcocd2.intel.com>
Subject: Re: reg exp size limit !?
Message-Id: <3443A50C.59E2@pcocd2.intel.com>

ok. Just an update on the size limit. 
What I didn't mention was that I was 
using (.|\n)+ to match all characters. 
And the string that finally matched this 
was very long (~ 32776 chars long ) and it 
failed to match it if it's longer than this. 

but when I tried  using .+ and the /s operator 
it works find with bigger strings.  my problem is 
solved for now but I'm still baffled between 
the difference in handling of (.|\n) and . used 
with /s

thanks
saviz




> 
> I think we have a failure to understand the problem in all of
> the followups to date.
>


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

Date: Tue, 14 Oct 1997 11:19:21 -0700
From: Shawn Gordon <sgordon@athena.lbl.gov>
To: Vinny Carpenter <vscarpenter@qgraph.com>
Subject: Re: Reg expr. question (SEARCH and REPLACE)
Message-Id: <3443B7A9.D28A8D1A@athena.lbl.gov>

Vinny Carpenter wrote:

> Run through a text file. Find all lines that are ALL CAPS and add
> something to them.
> For example: If it encounters something like this:
>
> Before:
>
> ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU..
>
> After:
>
> <H3>ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ..</H3>
>
> There will be several other lines in that file that have mixed case that
> should be ignored.
> I've tried the following to no avail
>

  Hi Vinny,

How about the following:

while(<>) {
        chomp;
        s/^([A-Z\W]+)$/<h2>$1<\/h2>/;
        print $_,"\n";
}
The [A-Z\W]+ matches a line that is all caps which may have
non-alphanumeric characters (to match the '..')
at the end of your line above.

If you need finer control (for instance you want to match numbers as well),
then the following should
work:

[A-Z0-9]+

Shawn Gordon





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

Date: Tue, 14 Oct 1997 15:53:04 GMT
From: 2002@calva.net (Christophe ODDO)
Subject: Re: Search: Reference Book
Message-Id: <344390ca.666568@news.calvacom.fr>

On Tue, 14 Oct 1997 06:28:39 -0500, tadmc@flash.net (Tad McClellan)
wrote:

>The ultimate and definitive Perl reference is not a book at all.
>It is free!
>It comes with every proper perl distribution!
>It is the man pages  (Plain Old Documentation)   ;-)

Yeah! 
Where can I find it on the Web, please ? Have you an URL ?

>What do you mean by that?
>Do you mean "I have never programmed before"?
>Do you mean "I am a programmer, but I've never done Perl or CGI 
>programs before"?

I mean...uuhh... I'm not a professional programmer...
I programmed old languages (Basic, Turbo-Pascal) some years ago.
Now, I've some (few) rudiments of Java programming...
Consider I've a little programming background only!

In your opinion, what have I to choose:
Randall Schwartz's "Learning Perl"
or Wall's "Programming Perl" ?

Thank you for your answers, Tad!

Christophe
Marseille, France


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

Date: Tue, 14 Oct 1997 13:20:56 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: split(/$dirsep/) problem ($dirsep = "\\")
Message-Id: <comdog-ya02408000R1410971320560001@news.panix.com>

In article <61vh7o$qc9$1@pandora.cs.utwente.nl>, s.oosthoek@student.utwente.nl (Simon Oosthoek) wrote:

>$dirsep = "\\";
>$path = "C:\foo\bar\blip";
>@path = split (/$dirsep/, $path);
>
>when I run this:
>/\/: trailing \ in regexp at test.pl line 3.

   #!/usr/bin/perl -wT
   
   # using double quotes when you aren't interpolating leads to
   # headaches.  if you want exactly what you type use single
   # quotes!
   $dirsep  = '\\'; # double \, otherwise it thinks we're escaping '
   $path    = 'C:\foo\bar\blip';
   
   # use \Q, or quotemeta() when using a variable for a regex to
   # avoid acrobatics in your patterns.
   @path    = split (/\Q$dirsep/, $path);
   
   foreach( @path )
      {
      print "$_\n";
      }
      
   __END__
   
   C:
   foo
   bar
   blip

-- 
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: Tue, 14 Oct 1997 11:35:31 -0400
From: Chris Gaston <cgaston@lds.com>
Subject: Sr. Web Architect Needed - NJ
Message-Id: <34439143.7FB0363C@lds.com>

Logical Design Solutions, a leader in the design and development of
Interactive Business Communications has an immediate full-time opening
in their Morristown, NJ office for a Web Architect.

Job Description:
In this visible role, the ideal candidate will possess experience in
configuration of Internet technologies as part of a multi-tiered
information technology architecture.  Keeping up-to-date with
current technology trends is essential, as is the ability to evaluate
appropriate technology components for development and delivery
environments.  This individual must also have the ability to integrate
application support technologies with preexisting client IT
infrastructure.  Experience with C/C++, Perl, HTML, Java, CGI and
knowledge of Internet protocols and standards is required.
Knowledge of Active X a plus.

Send resume with cover letter and salary requirements or contact:

Technical Recruiter
Logical Design Solutions
Phone: (201) 971-0100
Fax:   (201) 971-0103
email: recruiter@lds.com




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

Date: Tue, 14 Oct 1997 10:13:53 -0700
From: Saviz Artang - MPG ~ <sartang@pcocd2.intel.com>
Subject: Re: statics or const in perl ?
Message-Id: <3443A850.1CFB@pcocd2.intel.com>

> It looks like you are trying to code ANSI-C using Perl syntax.  As a
> rule in Perl, we don't have all the little rules like that.  I'm not
> saying that there aren't advatages to the ANSI-C approach, just that
> this approach isn't the Perl way of thinking.   The "perlmodlib"
> documentation has the following bit


Well let me tell you what I intend to do with this capability and 
maybe then it would make perl sense.  There is a data base of 
information that I make a perl structure out of.  I wanted to 
let the user enter perl queries to this data base via the 
eval command ( this way I wont have to have bizzilion different 
commands and options for queries. A very perlish idea ! )
but I wanted to make sure that the user wont 
be able to change the data structure I created. This is the 
reason I wanted a way of locking changes to a parameter. Of course
copying also works but the problem with that is that the user 
may mistakenly taint the copied data base and get wrong results 
after that. 

Anyway a way of locking parameters to make them read only would 
have helped.  Any suggestions are appreciated. 

saviz
  




> 
> NOTE
>        Perl does not enforce private and public parts of its
>        modules as you may have been used to in other languages
>        like C++, Ada, or Modula-17.  Perl doesn't have an
>        infatuation with enforced privacy.  It would prefer that
>        you stayed out of its living room because you weren't
>        invited, not because it has a shotgun.
> 
> The same reasoning is used with parameter passing.
> 
> - doug


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

Date: Tue, 14 Oct 97 16:47:05 GMT
From: pperroud@interlog.com (Patrick Charles Perroud)
Subject: sybperl/oraperl
Message-Id: <62072r$69u$1@news.interlog.com>

I was wondering if someone could point me in the right direction?

I've read through this newsgroup picking up tidbits of info that 
should help!!

Heres what I'm looking for:

I've got sybperl installed on a SunOs 4.1.2 box and have been using 
it for several years now, accessing our SYBASE db. The version of 
perl I've got installed is an old version (4.010). Sybperl is also 
from 1993.

We have recently purchased and application that uses Oracle 7.3.x 
running on  Solaris 2.5.1 and was wondering if there was a perl 
beast out there that
would allow me to access both RDBM's. I need to select from, and 
update
tables on both Oracle and Sybase at the same time.

If this beast does not exist are there any suggestions as to how I 
would go about doing this?

Thanks in advance,

Pat Perroud
pperroud@interlog.com






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

Date: Tue, 14 Oct 1997 11:29:52 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: Trying to pass a file handle under strict mode
Message-Id: <3443BA20.6516@us.oracle.com>

Hi,

I'm trying to pass a file handle to a function using strict mode,
but I keep on getting a BAREWORD warning when I run the script
with -wc options enabled.  Adding the * to each file handle
seems to do the trick, but is this the right way of doing it?

Thanks--Allen


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

Date: 14 Oct 1997 17:49:51 GMT
From: kivisild@rs1.tcs.tulane.edu (James A. Kivisild)
Subject: Writing/Reading Bin Files (need example)
Message-Id: <620bbv$lam$1@rs10.tcs.tulane.edu>

I posted something before asking how to read from binary files in Perl.  
I should clarify
my question. I know I need to use read() and possible unpack() but I'd like an 
example of how to read from a file

The particular file I need to read from used the following struct in C


#define MAXLEN 10
typedef struct
 {
      long b; 
      long m; 
 } xint;
 struct userinfo
 {
      char name[MAXLEN];
      xint a;
      xint b;
      xint c;
      char reserved[28];
 };
 typedef struct userinfo userinfo;

Any small example of how to read in the info and make 
changes to it would help... Thanks.
(I know this might be simpler in C, but for now I'd like to use perl)

-James


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

Date: Tue, 14 Oct 1997 15:27:39 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Writing/Reading Binary Files
Message-Id: <EI1sA4.8vx@world.std.com>

kivisild@rs1.tcs.tulane.edu (James A. Kivisild) writes:

>I'm trying to read and write to a binary file using a perl script.
>I'd like to do the same thing as fread() in C where the file opened is a binary file... 
>(opened with fopen("file","rb"))
>I've tried using read() but it simply reads in the data "as is" not coverting
>it out of binary form. Has anyone done something like this or know of a way
>to accomplish this?

The first thing to point out, although I don't think it is your
problem is that the perl equivalent of "fopen("file","rb")" is:

    open FILEHANDLE, "file";
    binmode FILEHANDLE;

The call to binmode is the same as C's opening the file in binary
mode.  As in C, you need to check the success of the open() call,
which is why perl scripts at least minimally change this to:

     open FILEHANDLE,"file" or die "Can't open file: $!\n";

Anyway, as I'm sure you are aware, all the data that the computer
deals with is binary, and a lot of what computer languages do is to
give the programmer easier methods of reprsenting that binary data. In
perl, when you get data with read(), you are filling a buffer with a
the bytes in the file. For example, if you read the first couple of
bytes of a gzip file into a scalar, the scalar will contain something
like:

$buffer = "\x1f\x8b\x08\x08";

Now in C, you have an advantage for stuff like this, because there is
no distinction between numbers a characters. Where in perl, numbers
and strings are distinct. (they are still represented by the same
binary representation though. $string = "\x1f" and $number = 0x1f both
still have a memory location with the 5 low order bits set somewhere
in the computer.)

In perl data is initially read into scalars, and there are lots of
places that perl treats these scalars as strings of bytes. There are
some functions to adjust perl's understanding of this data. The most
general purpose of these is "pack" and "unpack", which is what I think
you want.

 read(STDIN, $buffer, 10);
 ($magic, $method, $flags, $extraflags, $os) = unpack 'SCCxxxxCC', $buffer;
  die "Not a gzip file\n" if $magic != 0x1f8b;

There are also the chr() and ord() functions for converting between
numbers and single characters.
-- 
Andrew Langmead


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

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

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