[22370] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4591 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 09:05:54 2003

Date: Thu, 20 Feb 2003 06:05:11 -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           Thu, 20 Feb 2003     Volume: 10 Number: 4591

Today's topics:
    Re: A simple problem befuddling my simple head <jboes@qtm.net>
    Re: A simple problem befuddling my simple head (Helgi Briem)
    Re: Also religious: brackets <ubl@schaffhausen.de>
    Re: Check for occurrence of element in Array <upro@gmx.net>
    Re: Check for occurrence of element in Array <tassilo.parseval@post.rwth-aachen.de>
    Re: Check for occurrence of element in Array <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Check for occurrence of element in Array (Anno Siegel)
    Re: Check for occurrence of element in Array <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Check for occurrence of element in Array (Tad McClellan)
    Re: Check for occurrence of element in Array (Tad McClellan)
    Re: Check for occurrence of element in Array <REMOVEsdnCAPS@comcast.net>
    Re: Having problems writing a tar file. Correction <dont@want.spam>
    Re: Having problems writing a tar file. Correction <justinagraham@hotmail.com>
    Re: Having problems writing a tar file. Correction (Helgi Briem)
    Re: Having problems writing a tar file. (Helgi Briem)
        help! (ben)
    Re: help! <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: help! (Helgi Briem)
    Re: How do I get the current date? <me@privacy.net>
    Re: How do I get the current date? <Steffen.Beyer@de.bosch.com>
    Re: How do I get the current date? <Steffen.Beyer@de.bosch.com>
    Re: How do I get the current date? (Helgi Briem)
    Re: Input file format <thens@nospam.com>
    Re: net command (Helgi Briem)
    Re: Newbie Q re form to mail script FormProcessorPro <notworking@all.com>
    Re: Newbie Q re form to mail script FormProcessorPro (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Feb 2003 15:11:08 -0500
From: Jeff Boes <jboes@qtm.net>
Subject: Re: A simple problem befuddling my simple head
Message-Id: <a0p75vgkerg68fp67cg1m4srp8me0fsmdc@4ax.com>

At some point in time, liamngs@aol.com (Liam James) wrote:

>Hello,
>
>I am just learning PERL, and I am trying to set up a simple validation
>script, it checks to set that the content of one edit box is the same
>as another. Its similar to 'choose a password - now confirm it'. No
>matter what I do I keep getting a 500 error.

Server 500 errors are almost always due to Perl compile-time errors. I wrote an
article for an online mag a long time ago:

http://perlmonth.com/perlmonth/issue11/begin.html


>
>So far I have :
>
>==============
>
>#!/bin/perl -w
>
>use CGI;
>
>$cgiobject = new CGI;
>
>$email1=$cgiobject->param("email1");
>$email2=$cgiobject->param("email2");
>
>print $cgiobject->header;
>
>test();
>
>  sub test 
>
>  {
>  
>   If ($email1 eq $email2)

"If" is not "if".

>   {print "yes they match"}
>
>   else
>   {print "no they dont"}
>
>  }
>
>

When in doubt, run your script from a command line like this:

$ perl -cw myscript.pl



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

Date: Thu, 20 Feb 2003 10:08:43 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: A simple problem befuddling my simple head
Message-Id: <3e54a89d.1117025427@news.cis.dfn.de>

On Thu, 20 Feb 2003 02:35:36 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>I' guessing this is a stealth CGI question.

Considering that the third and fifth lines in the program 
are:

use CGI;
and
$cgiobject = new CGI;

I wouldn't exactly say it was very stealthy.

Off-topic, yes.  Stealthy, no.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 20 Feb 2003 10:48:02 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Also religious: brackets
Message-Id: <b32bfo$1ko$1@news.dtag.de>

Ryan Shondell wrote:
> "Peter Cooper" <newsfeed2@boog.co.uk> writes:
> 
> 
>>>One-liners goes like this;
>>>
>>>  do if ( statement );
>>
>>If I have a 'debug' or verbose switch in a program I tend to
>>implement it like so:
>>
>>$debug && print $variable;
> 
> 
> Wow, that's almost a carbon-copy example of what perlstyle says _not_
> to do, because it hides the main point of the statement.

No it doesn't, because here you got the very import C<$debug> as the 
first word on the line. I prefer the written C<and> though.

->malte



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

Date: Thu, 20 Feb 2003 09:55:14 +0100
From: upro <upro@gmx.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <87el63qqkt.fsf@gmx.net>

tadmc@augustmail.com (Tad McClellan) writes:

> upro <upro@gmx.net> wrote:
>
>> E. g. my array contains the valuaes "de", "en", and "fr". I have
>> anther list with iso codes, and I want to check for their presence.
>
>> I have heard that it is better tpo do this with a hash but I don't
>> know how to do that.
>
>
> my %tld;
> $tld{de} = 1;
> $tld{en} = 1;
> $tld{fr} = 1;
>
> if ( $tld{$isocode} )
>    { print "found $isocode\n" }
> else
>    { print "$isocode not found\n" }


Thanks for all your answers, but I think that I can't solve it like this.

My code goes like this:

# glob the directory for .tex source files
@languages = glob("*.tex");
foreach $languages(@languages) {
chomp $languages;
$languages =~ s/(.*?)\.tex/$1/s;
# open the source files if it exists
if ($languages eq "de") {
open (DE, "$languages");
}
elsif ($languages eq "en") {
open (EN, "$languages");
}
elsif ($languages eq "it") {
open (IT, "$languages");
}
elsif ($languages eq "fr") {
open (FR, "$languages");
}
elsif ($languages eq "es") {
open (ES, "$languages");
}
elsif ($languages eq "pt") {
open (PT, "$languages");
}
}


Now I want to check if a source language .tex file exists, if yes I
want to use that one, if not I want to use a default file.

Can you help me with this, please?

Thank you in advance!

Micahel


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

Date: 20 Feb 2003 11:51:41 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Check for occurrence of element in Array
Message-Id: <b32fgd$p1m$1@nets3.rz.RWTH-Aachen.DE>

Also sprach upro:

> tadmc@augustmail.com (Tad McClellan) writes:

>> my %tld;
>> $tld{de} = 1;
>> $tld{en} = 1;
>> $tld{fr} = 1;
>>
>> if ( $tld{$isocode} )
>>    { print "found $isocode\n" }
>> else
>>    { print "$isocode not found\n" }
> 
> 
> Thanks for all your answers, but I think that I can't solve it like this.
> 
> My code goes like this:
> 
> # glob the directory for .tex source files
> @languages = glob("*.tex");
> foreach $languages(@languages) {
> chomp $languages;
> $languages =~ s/(.*?)\.tex/$1/s;
> # open the source files if it exists
> if ($languages eq "de") {
> open (DE, "$languages");
> }
> elsif ($languages eq "en") {
> open (EN, "$languages");
> }
> elsif ($languages eq "it") {
> open (IT, "$languages");
> }
> elsif ($languages eq "fr") {
> open (FR, "$languages");
> }
> elsif ($languages eq "es") {
> open (ES, "$languages");
> }
> elsif ($languages eq "pt") {
> open (PT, "$languages");
> }
> }

After the loop you may have up to six open filehandles lying around. Are
you sure you all need them? You didn't show all of your code, but I am
sure that you later have to do the above check again, namely in order to
find out from which of the six handles (DE .. PT) you have to read.

> Now I want to check if a source language .tex file exists, if yes I
> want to use that one, if not I want to use a default file.

Put the available source languages into a hash and check against that:

    my %langs;
    @langs{ qw/DE EN IT FR ES PT/ } = ();
    
    my $handle;
    while (glob "*.tex") {
        my ($lang) = /(.*?)\.tex/;
        if (exists $langs{ $lang }) {
            open $handle, $lang or die $!;
            last;       # we only want one handle
        }
    }
    
    # if no language file was found, $handle is empty: open default
    open $handle, "default.tex" or die $!
        if ! $handle;

I can't say whether the above is what you want since I am not clear
about your original code. 

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: Thu, 20 Feb 2003 11:58:43 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <Xns932883560FEBFelhber1lidotechnet@62.89.127.66>

Tassilo v. Parseval wrote:


[...]


> After the loop you may have up to six open filehandles lying around.
> Are you sure you all need them? You didn't show all of your code, but
> I am sure that you later have to do the above check again, namely in
> order to find out from which of the six handles (DE .. PT) you have to
> read. 
> 
>> Now I want to check if a source language .tex file exists, if yes I
>> want to use that one, if not I want to use a default file.
> 
> Put the available source languages into a hash and check against that:
> 
>     my %langs;
>     @langs{ qw/DE EN IT FR ES PT/ } = ();
>     
>     my $handle;


You're not setting $handle anywhere in your code.


>     while (glob "*.tex") {
>         my ($lang) = /(.*?)\.tex/;
>         if (exists $langs{ $lang }) {
>             open $handle, $lang or die $!;
>             last;       # we only want one handle
>         }
>     }
>     
>     # if no language file was found, $handle is empty: open default
>     open $handle, "default.tex" or die $!
>         if ! $handle;
> 
> I can't say whether the above is what you want since I am not clear
> about your original code. 


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: 20 Feb 2003 12:13:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Check for occurrence of element in Array
Message-Id: <b32goc$r0p$2@mamenchi.zrz.TU-Berlin.DE>

Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in comp.lang.perl.misc:
> Tassilo v. Parseval wrote:

[...]

> >     my %langs;
> >     @langs{ qw/DE EN IT FR ES PT/ } = ();
> >     
> >     my $handle;
> 
> 
> You're not setting $handle anywhere in your code.

Hmmm?  open( $handle, ...) autovivifies it.

> >     while (glob "*.tex") {
> >         my ($lang) = /(.*?)\.tex/;
> >         if (exists $langs{ $lang }) {
> >             open $handle, $lang or die $!;
                     ^^^^^^^

Anno


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

Date: Thu, 20 Feb 2003 12:14:48 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <Xns932886101D2BDelhber1lidotechnet@62.89.127.66>

Anno Siegel wrote:

> Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
> comp.lang.perl.misc: 
>> Tassilo v. Parseval wrote:
> 
> [...]
> 
>> >     my %langs;
>> >     @langs{ qw/DE EN IT FR ES PT/ } = ();
>> >     
>> >     my $handle;
>> 
>> 
>> You're not setting $handle anywhere in your code.
> 
> Hmmm?  open( $handle, ...) autovivifies it.


Oopsie.


:-)


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 20 Feb 2003 06:35:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Check for occurrence of element in Array
Message-Id: <slrnb59isi.3bs.tadmc@magna.augustmail.com>

upro <upro@gmx.net> wrote:
> tadmc@augustmail.com (Tad McClellan) writes:
>> upro <upro@gmx.net> wrote:
>>
>>> E. g. my array contains the valuaes "de", "en", and "fr". I have
>>> anther list with iso codes, and I want to check for their presence.
>>
>>> I have heard that it is better tpo do this with a hash but I don't
>>> know how to do that.

>> if ( $tld{$isocode} )
>>    { print "found $isocode\n" }

> Thanks for all your answers, but I think that I can't solve it like this.


It is almost for sure that a hash will help you do what you want 
to do, but I'm still not clear on what it is that you want to do...

Your code doesn't show any access for "anther list with iso codes",
what form is that list in? What do you do with the elements in
that list?


> My code goes like this:

> # open the source files if it exists
> if ($languages eq "de") {
> open (DE, "$languages");
> }
> elsif ($languages eq "en") {
> open (EN, "$languages");
> }


Why are you using a different filehandle name for each alternative?

Every time you want to print() you'll have to check to see which
filehandle you should print to.

Your code only opens one filehandle anyway, why not use a single
name (eg. LANG) so you don't have to do a check before every output?

If the directory contains both 'de.tex' and 'en.tex' you want
to open 'de.tex' with filehandle DE and do nothing for the
English one? That is what the code you've shown will do...

I can't make sense of your problem description nor your code.
Please try again to explain what you need to accomplish.

[ You should have a look at the Posting Guidelines before you
  do that too:

     http://mail.augustmail.com/~tadmc/clpmisc.shtml
]


> Now I want to check if a source language .tex file exists, 


glob() will not return it if it does not exist, so you don't
need to do any such checking...


> if yes I
> want to use that one, 


What if there is _more_ than one?


> if not I want to use a default file.
> 
> Can you help me with this, please?


If your specification was good enough, someone could help
you with Real Code. 

But it isn't, so we can't.  :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 20 Feb 2003 06:51:49 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Check for occurrence of element in Array
Message-Id: <slrnb59jr4.3bs.tadmc@magna.augustmail.com>

upro <upro@gmx.net> wrote:

> My code goes like this:
> 
> # glob the directory for .tex source files
> @languages = glob("*.tex");


You should have "use strict" enabled.

You should use single quotes unless you _make use_ of one of the
two "extra" things that double quotes provide (backslash escapes
and/or variable interpolation).

   my @languages = glob( '*.tex' );


> foreach $languages(@languages) {


You should not have 2 completely separate variables ($languages,
@languages) with the same name. You are going to confuse yourself
sooner or later if you do that.

   $languages[2]; # accesses @languages, has nothing to do with $languages

You should not name a singular thing (scalar) with a plural name.
You are going to confuse yourself sooner or later if you do that.
$languages does NOT contain languages, it contains a single _language_.

You do not need the @languages temporary variable at all, you can
loop directly over the list returned from glob():

   foreach my $language ( glob '*.tex' ) {


> chomp $languages;


glob() does not return lines, so you do not need to remove line endings.

Even worse, if a filename actually does end with a newline, you
will strip it here, then later use the wrong filename.


> $languages =~ s/(.*?)\.tex/$1/s;


That would change 'en.texas' (with "ya'll" and "fixen to" in it :-)
to 'enas'. Is that what you want to do? Probably not. You need to
anchor the end of the pattern.

Do you really want to allow filenames with newlines in them?
Probably not, so you don't need the s///s option.

   $language =~ s/(.*)\.tex$/$1/;

But if you just want to strip ".tex" from the end, then just
strip ".tex" from the end:

   $language =~ s/\.tex$//;


> # open the source files if it exists
> if ($languages eq "de") {


Why bother stripping the filename extension?

   if ($language eq 'de.tex') {

Then you don't need any s/// at all...


> open (DE, "$languages");
            ^          ^
            ^          ^

Those quotes do not do anything useful, so they should not be there.

You should always, yes *always*, check the return value from open():

   open(DE, $language) or die "could not open '$language'  $!";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 20 Feb 2003 07:20:06 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <Xns932854C56C383sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

upro <upro@gmx.net> wrote in news:87el63qqkt.fsf@gmx.net:

> tadmc@augustmail.com (Tad McClellan) writes:
> 
>> upro <upro@gmx.net> wrote:
>>
>>> E. g. my array contains the valuaes "de", "en", and "fr". I have
>>> anther list with iso codes, and I want to check for their
presence.
>>
>>> I have heard that it is better tpo do this with a hash but I
don't
>>> know how to do that.
>>
>>
>> my %tld;
>> $tld{de} = 1;
>> $tld{en} = 1;
>> $tld{fr} = 1;
>>
>> if ( $tld{$isocode} )
>>    { print "found $isocode\n" }
>> else
>>    { print "$isocode not found\n" }
> 
> 
> Thanks for all your answers, but I think that I can't solve it like
this.
> 
> My code goes like this:
> 
> # glob the directory for .tex source files
> @languages = glob("*.tex");
> foreach $languages(@languages) {
> chomp $languages;
> $languages =~ s/(.*?)\.tex/$1/s;
> # open the source files if it exists
> if ($languages eq "de") {
> open (DE, "$languages");
> }
> elsif ($languages eq "en") {
> open (EN, "$languages");
> }
> elsif ($languages eq "it") {
> open (IT, "$languages");
> }
> elsif ($languages eq "fr") {
> open (FR, "$languages");
> }
> elsif ($languages eq "es") {
> open (ES, "$languages");
> }
> elsif ($languages eq "pt") {
> open (PT, "$languages");
> }
> }
> 
> 
> Now I want to check if a source language .tex file exists, if yes
I
> want to use that one, if not I want to use a default file.

Please please please learn to indent.  It's very hard to follow your
code.

You want six (or so) filehandles open at the same time, and you want
to be able to look up which one to use based on a language code,
right?
Okay, how about this:

    my @languages = glob ("*.tex");
    my %handle;
    foreach my $file (@languages)
    {
        my $lang = $file;
        $lang =~ s/\.tex$//;

        # open file if it exists
        my $handle;
        if (open $handle, $file)
        {
            $handle{$lang} = $handle;
        }
        else
        {
            warn "some dire message"
        }
    }

later in your program:

    my $lang = 'DE';  # or whatever
    $line = readline $handle{$lang};

Is that what you're looking for?

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+VNX8Y96i4h5M0egRAh/zAKDZHPgzCfJdZB3wt4tkuXfgN+/v+ACeKQfC
3EpB8zERRfMsCRDk6JKyPBc=
=5Yfl
-----END PGP SIGNATURE-----


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

Date: Thu, 20 Feb 2003 08:23:45 +0000
From: Chris Lowth <dont@want.spam>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <Co05a.207$J77.11275@newsfep2-win.server.ntli.net>

Justin A. Graham wrote:

> Ron Reidy wrote:
>> perldoc Archive::Tar shows the write() metjod takes 2 arguments.  Did
>> you try it this way?
>> 
>> --
>> Ron Reidy
>> Oracle DBA
>> 
> 
> I'll give it a try...

Do you have the latest version of the tar module? (try CPAN)

Chris
-- 
My real e-mail address is
chris <at> lowth <dot> com


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

Date: Thu, 20 Feb 2003 09:17:20 GMT
From: "Justin A. Graham" <justinagraham@hotmail.com>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3E549D2C.4060805@hotmail.com>

Chris Lowth wrote:
> Justin A. Graham wrote:
> 
> 
>>Ron Reidy wrote:
>>
>>>perldoc Archive::Tar shows the write() metjod takes 2 arguments.  Did
>>>you try it this way?
>>>
>>>--
>>>Ron Reidy
>>>Oracle DBA
>>>
>>
>>I'll give it a try...
> 
> 
> Do you have the latest version of the tar module? (try CPAN)
> 
> Chris

I figured it out. I had a newline at the end of each filename, which I 
had to strip before adding to the archive.

Cheers
Justin



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

Date: Thu, 20 Feb 2003 12:33:00 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3e54cae4.1125800986@news.cis.dfn.de>

On Thu, 20 Feb 2003 00:51:12 GMT, "Justin A. Graham"
<justinagraham@hotmail.com> wrote:

>I am trying to tar a list of file with the following snippet;
>
># Archive files
>$tar = Archive::Tar->new();
>$tar->add_files(@files);
>$tar->write($filename);
>
>@files and $filename are valid...
>
>The result is the tar file $filename filled with zeroes.
>
>What am I doing wrong?

Posting the same question twice.  Read the
other thread.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 20 Feb 2003 12:32:04 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Having problems writing a tar file.
Message-Id: <3e54c9f6.1125562763@news.cis.dfn.de>

On Thu, 20 Feb 2003 00:49:34 GMT, "Justin A. Graham"
<justinagraham@hotmail.com> wrote:

>I am trying to tar a list of file with the following snippet;
>
># Archive files
>$tar = Archive::Tar->new();
>$tar->add_files(@files);
>$tar->write($filename);
>
>@files and $filename are valid...
>
>The result is the list @files written serially to the file $filename. 
>I.e. all the filenames are just concatenated together and written to the 
>tar file.
>
>What am I doing wrong?

You probably forgot to either chdir to the place where the
files are kept OR add the full path to the filenames.

You also forgot to enable warnings and strictures
although in this particular case, that would not
have helped.

#!perl
use warnings;
use strict;
use Archive::Tar;
my $dir = '/some/path/';
opendir DIR, $dir or die "Cannot opendir $dir:$!\n";
my @files = grep !/^\.{1,2}$/i,readdir DIR;
closedir DIR;

chdir $dir or die "Cannot cd to $dir:$!\n";
my $filename = "csv.tar";
my $tar = Archive::Tar->new();
$tar->add_files(@files);
$tar->write($filename);
_END_
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: 20 Feb 2003 05:30:13 -0800
From: ayouze@yahoo.com (ben)
Subject: help!
Message-Id: <f155f1c.0302200530.50e35064@posting.google.com>

hello,
 I have a file which loks like the following example:
  
+   10..20      0 
+   15..35      1 
+   37..40      2 
+   51..73      0 
+   81..100     2 
+   111..117    1 
+   120..123    0 
+   130..142    0 
+   150..155    1 
+   171..240    2 
so on...  

I would like to get the blocks of the lines which have a continuation
0 1 2 as it is the case for the three first and the three last lines. 
The goal then is  to get the intervals of each blocs(ex 10 to 40 for
the first three lines and 130 to 240 for the last ones);
thank you for your assistance

Ben


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

Date: Thu, 20 Feb 2003 13:31:17 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: help!
Message-Id: <Xns93289307BD552elhber1lidotechnet@62.89.127.66>

ben wrote:

> hello,
>  I have a file which loks like the following example:
>   
> +   10..20      0 
> +   15..35      1 
> +   37..40      2 
> +   51..73      0 
> +   81..100     2 
> +   111..117    1 
> +   120..123    0 
> +   130..142    0 
> +   150..155    1 
> +   171..240    2 
> so on...  
> 
> I would like to get the blocks of the lines which have a continuation
> 0 1 2 as it is the case for the three first and the three last lines. 
> The goal then is  to get the intervals of each blocs(ex 10 to 40 for
> the first three lines and 130 to 240 for the last ones);
> thank you for your assistance


What have you tried so far?


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 20 Feb 2003 13:44:58 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: help!
Message-Id: <3e54d9a8.1129580550@news.cis.dfn.de>

On 20 Feb 2003 05:30:13 -0800, ayouze@yahoo.com (ben) wrote:

> I have a file which loks like the following example:
>  
>+   10..20      0 
>+   15..35      1 
>+   37..40      2 
>+   51..73      0 
>+   81..100     2 
>+   111..117    1 
>+   120..123    0 
>+   130..142    0 
>+   150..155    1 
>+   171..240    2 
>so on...  

Exon, reading frame?

I don't understand exactly what you are trying
to say, but this may help get you part of the way there:

#!perl
use warnings;
use strict;
my %hash;
while (<DATA>)
{
 next if (/^\s+$/ or /^#/);
 chomp;
 my (undef,$block,$var) = split;
 push @{$hash{$var}}, $block;
}
for (keys %hash) 
{ 
  print "$_:\t@{$hash{$_}}\n"; 
}
__END__
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 20 Feb 2003 23:03:17 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: How do I get the current date?
Message-Id: <b32g6a$1dthq0$1@ID-172104.news.dfncis.de>


"Abigail" <abigail@abigail.nl> wrote in message
news:slrnb583h5.1ea.abigail@alexandra.abigail.nl...
> Hmmm. There is no "the ISO date format". The ISO standard dealing with
> dates defines a whole army of allowed formats.

OK.  ISO 8601




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

Date: Thu, 20 Feb 2003 13:18:53 +0100
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: How do I get the current date?
Message-Id: <b32h3e$6pl$1@ns2.fe.internet.bosch.com>


"Tintin" <me@privacy.net> wrote in message
news:b32g6a$1dthq0$1@ID-172104.news.dfncis.de...
>
> "Abigail" <abigail@abigail.nl> wrote in message
> news:slrnb583h5.1ea.abigail@alexandra.abigail.nl...
> > Hmmm. There is no "the ISO date format". The ISO standard dealing with
> > dates defines a whole army of allowed formats.
>
> OK.  ISO 8601

And even though ISO 8601 also defines several possible variations,
they all have in common the order year-month-day (or somesuch
sensible order) which makes them easily sortable, which was the
point in question in the first place. :-)

Cheers,
--
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)

    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)

    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)




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

Date: Thu, 20 Feb 2003 13:25:25 +0100
From: "Steffen Beyer" <Steffen.Beyer@de.bosch.com>
Subject: Re: How do I get the current date?
Message-Id: <b32hfn$712$1@ns2.fe.internet.bosch.com>


"John W. Krahn" <krahnj@acm.org> wrote in message
news:3E53FB7A.EB02001E@acm.org...
> "Justin A. Graham" wrote:
> >
> > I want to write a script that zip up files, and names the archive
> > file-month-day-year.zip
> >
> > How do I get the current date in a perl script?
>
> use POSIX qw(strftime);
>
> my $file = strftime( 'file-%m-%d-%Y.zip', localtime );
>
>
> John
> --
> use Perl;
> program
> fulfillment

Without the penalty for loading an additional module,
how about this:

my @now = localtime();
$now[4]++;
$now[5] += 1900;
my $file = sprintf("file-%04d%02d%02d.zip", @now[5,4,3]);

And yes, this has a Y10K bug (sort of). ;-)

Cheers,
--

    Steffen Beyer <sb@engelschall.com>

    http://www.engelschall.com/u/sb/whoami/ (Who am I)

    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)

    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)




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

Date: Thu, 20 Feb 2003 13:21:43 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How do I get the current date?
Message-Id: <3e54d614.1128664573@news.cis.dfn.de>

On Thu, 20 Feb 2003 13:25:25 +0100, "Steffen Beyer"
<Steffen.Beyer@de.bosch.com> wrote:
>Without the penalty for loading an additional module,
>how about this:

Please, please don't spread misinformation about
the "penalty for loading an additional module".

If the nanoseconds/kilobytes penalty of loading
a module is actually important to you, you shouldn't
be programming in Perl.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 20 Feb 2003 14:21:05 +0530
From: Thens <thens@nospam.com>
Subject: Re: Input file format
Message-Id: <20030220142105.31314dd5.thens@nospam.com>


On Wed, 19 Feb 2003 08:54:08 -0500
Joel Konkle-Parker <j.j.konkle-parker@larc.nasa.gov> wrote:

> I need to create an input file format for my perl script that will allow 
> a user to input different numerical parameters, based on which the 
> script will perform different tasks, repeat certain steps, et c.
> 
 [ example ]

> So my question: what's the best input file format to use for this type 
> of thing? Easiest for me, the programmer? Easiest for the (professional) 
> user? Most flexible?

   use Config::General

It satisifies all your conditions. It is best suited for applications
that reads config files. It allows multiple values, multiline values,
Interpolation of variables and even allows you to write the config file 
back

http://search.cpan.org/author/TLINDEN/Config-General/

-thens

> - Joel
> 


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

Date: Thu, 20 Feb 2003 12:37:47 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: net command
Message-Id: <3e54cb11.1125845780@news.cis.dfn.de>

On Thu, 20 Feb 2003 03:21:11 -0000, "No Name"
<no.name@eidosnet.co.uk> wrote:

>Does anyone here know if it is possible to connect to 
>netbios shares using perl?

Use the open function, Luke.

my $server = 'Fileserver';
my $share = 'Share';
my $dir = 'Directory';

my $path = "//$server/$share/$dir";
opendir DIR, $path or die "Cannot opendir $path:$!\n";
print join "\n",readdir DIR;
closedir DIR;
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Thu, 20 Feb 2003 12:19:13 -0000
From: Trilby <notworking@all.com>
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <MPG.18bed5459e3ba91c9896e4@news.iol.ie>

While busily concocting a devastating reply tiltonj@erols.com retorted
>  Do I take it that there is no 'obvious' solution ?
> 
> No idea.  It may be obvious to someone familiar with the package,
> which Perl programmers are evidently not.  Not many will go to the
> trouble of acquiring and studying a package to debug somebody else's
> hangup.  Not for free, anyway.

Jeeez I just asked a simple question, mate.  I didn't ask anyone to 
'study a package' or debug someone else's script.  No need to the 
sarcasm.
> 
> Best guess, and it's a real WAG, is there's some CRLF mistranslation
> going on when the template is uploaded onto the server.
> 
> 
And that was so difficult, was it ?


Trilby


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

Date: 20 Feb 2003 13:32:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <b32ldu$r0p$3@mamenchi.zrz.TU-Berlin.DE>

Trilby  <notworking@all.com> wrote in comp.lang.perl.misc:
> While busily concocting a devastating reply tiltonj@erols.com retorted
> >  Do I take it that there is no 'obvious' solution ?
> > 
> > No idea.  It may be obvious to someone familiar with the package,
> > which Perl programmers are evidently not.  Not many will go to the
> > trouble of acquiring and studying a package to debug somebody else's
> > hangup.  Not for free, anyway.
> 
> Jeeez I just asked a simple question, mate.  I didn't ask anyone to 
> 'study a package' or debug someone else's script.  No need to the 
> sarcasm.

You asked what you *think* is a simple question.  What you did ask
is for somebody to debug your script.  Since you didn't give any
information, the request to study the package was implicit.

> > Best guess, and it's a real WAG, is there's some CRLF mistranslation
> > going on when the template is uploaded onto the server.
> > 
> > 
> And that was so difficult, was it ?

Haughty remarks about things you don't understand won't make you
any friends.

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


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