[29117] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 361 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 21:09:56 2007

Date: Thu, 19 Apr 2007 18:09:14 -0700 (PDT)
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, 19 Apr 2007     Volume: 11 Number: 361

Today's topics:
    Re: ActiveState vs. "C:\Program Files\" and "C:\Progra~ <mnemotronic@gmail.com>
    Re: Any Help? Stuck trying to create cgi perl program <tadmc@augustmail.com>
        Compressing Files - Help <pankaj_wolfhunter@yahoo.co.in>
    Re: Compressing Files - Help <jgibson@mail.arc.nasa.gov>
    Re: die problem? <tadmc@augustmail.com>
        From zero to dogfood widgets in one day PERL <vaj@tempinbox.com>
        How do I use a literal comma in a system command <tbrazil@perforce.com>
    Re: How do I use a literal comma in a system command (Gary E. Ansok)
    Re: How do I use a literal comma in a system command <tbrazil@perforce.com>
    Re: Lexical reference to an anonymous recursive subrout <lorian@fsavigny.de>
    Re: Lexical reference to an anonymous recursive subrout <wahab-mail@gmx.de>
    Re: Lexical reference to an anonymous recursive subrout <uri@stemsystems.com>
        Printing the next line of text of the file <rodbass63@gmail.com>
    Re: Printing the next line of text of the file <wahab-mail@gmx.de>
    Re: Printing the next line of text of the file <rodbass63@gmail.com>
    Re: Printing the next line of text of the file <jgibson@mail.arc.nasa.gov>
    Re: Printing the next line of text of the file <wahab-mail@gmx.de>
    Re: Printing the next line of text of the file <tadmc@augustmail.com>
    Re: Server For Rent? Where? <tadmc@augustmail.com>
    Re: Server For Rent? Where? <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Apr 2007 15:53:08 -0700
From: pt <mnemotronic@gmail.com>
Subject: Re: ActiveState vs. "C:\Program Files\" and "C:\Progra~1\"
Message-Id: <1177023188.257991.310850@l77g2000hsb.googlegroups.com>

On Apr 15, 12:50 am, "pt" <mnemotro...@gmail.com> wrote:
> note:  this post started off as a question, but turned into a blog and

[snip-tumalu-madarlin]

First off, thanks to all the folks who took the time to wade through
my OP and reply.  A moderate razz to Goggle who lost my previous reply
to this thread.  A few vectored "thank you"s to sisyphus, Mirco, and
M.Dondi.  I used the "junction" utility (
http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx
) from SysInternals-now-Microsoft-all-hail-on-bended-knee to create a
"C:\Perl" dir linked to "C:\Program Files\ActiveState.com\Perl".  Then
re-installed Activestate 5.8.8.820 into "C:\Perl".  I could have done
that without the whole "C:\Program Files\ActiveState.com" dir and
link, but I have this personal bias against installing everything
right at the root, even though it it IS like pissing upstream into a
brick wall.  I like the ideas expressed in the Hierarchical File
System Standard ( http://www.pathname.com/fhs/ ), so I'm trying to do
things that way.

I am now much closer to a working solution.  As it turns out, Perl 5.6
vs. 5.8 is NOT the problem (at least, not the current problem).  The
CPAN modules I'm using (BitTorrent , Net::BitTorrent::*) are
problematic.  For example, "BitTorrent-V0.02" actually requires PHP to
be installed.  This isn't well documented (as in "not even hinted
at").  I was a bit surprised at PHP code being part of a CPAN Perl
module, but decided to "go with the flow".  Since undocumented
alternate language requirements are "l'ordre du jour", I've taken it
upon myself to re-write the module to use the Chinese language version
of ALGOL-68, and the Aore dialect of SQL

BTW, for freeware archivers, I suggest 7-Zip (http://www.7-zip.org/).



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

Date: Thu, 19 Apr 2007 20:26:06 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Any Help? Stuck trying to create cgi perl program
Message-Id: <slrnf2g5le.fk3.tadmc@tadmc30.august.net>

shadkeene@hotmail.com <shadkeene@hotmail.com> wrote:
> On Apr 19, 8:48 am, shadke...@hotmail.com wrote:

>> my %form;
>> foreach my $p (param())  {
>>   $form($p) = param($);
          ^  ^
          ^  ^
>>   print OUT "$form{$p},";
>>
>> }
>>
>> Shad- Hide quoted text -
>>
>> - Show quoted text -
>
> The msg I just posted has an error...


"an" is singular, you have plural errors. :-(


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


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

Date: 19 Apr 2007 16:19:07 -0700
From: "pankaj_wolfhunter@yahoo.co.in" <pankaj_wolfhunter@yahoo.co.in>
Subject: Compressing Files - Help
Message-Id: <1177024747.413642.44790@n59g2000hsh.googlegroups.com>

Greetings,
                 In Unix we have a function called compress/gzip in
order to zip a file with the a particular extension.

I need to zip some files with the extension .Z in perl.

I looked through the documentation for Compress:Zlib and Archive::Zip
but didnt find how to go about it

All I want is to zip a file with a particular format like .Z

Can someone please point me to right direction?

Help would be appreciated

Sorry for posting it on comp.lang.perl.tk

TIA



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

Date: Thu, 19 Apr 2007 17:22:58 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Compressing Files - Help
Message-Id: <190420071722584492%jgibson@mail.arc.nasa.gov>

In article <1177024747.413642.44790@n59g2000hsh.googlegroups.com>,
<"pankaj_wolfhunter@yahoo.co.in"> wrote:

> Greetings,
>                  In Unix we have a function called compress/gzip in
> order to zip a file with the a particular extension.

Unix 'zip', 'gzip', and 'compress' are three different programs that I
believe use three different but similar compression algorithms.
Compatibility among the three is mixed and may depend upon your
operating system distribution, version, and platform. For example, on
my system, 'man gzip' says that gzip can decompress files compressed
with 'compress', but not compress (create) them. There is also a 'zlib'
library that compresses stuff, and this adds to the confusion.

> 
> I need to zip some files with the extension .Z in perl.

 .Z is the file extension used by 'compress', not 'zip'. Please be more
precise in what you are trying to accomplish so we can help you better.
Are you trying to create 'compress'- or 'zip'-like files?

> 
> I looked through the documentation for Compress:Zlib and Archive::Zip
> but didnt find how to go about it

The FAQ for Compress::Zlib
(<http://search.cpan.org/~pmqs/Compress-Zlib-2.004/pod/FAQ.pod>) says
it is not compatible with 'compress'.

> 
> All I want is to zip a file with a particular format like .Z

Do you want a file that is compressed with 'compress'?

See the above FAQ for a way to compress files using 'compress':

    open F, "| compress -c $filename ";
    print F "data";
    ...
    close F ;

You can also call the compress program with the system function:

  system("compress $file");

See 'perldoc -f system'

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Thu, 19 Apr 2007 20:46:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: die problem?
Message-Id: <slrnf2g6sg.fk3.tadmc@tadmc30.august.net>

Purl Gurl <purlgurl@purlgurl.net> wrote:
> g4173c wrote:
>
>
>>     system ("cleatool co -unr -nc $revfilename") || die "Error:
>> Couldn't Check Out $revfilename: $!\n";
>
>> The system call has a typo for the command. I thought that it should
>> have stopped there, however I get this:
>
>> Can't exec "cleatool": No such file or directory at ba line 83,
>> <ALTERA> line 6.
>
> Your system call is successful. An error message is returned to
> your call, 


No it isn't.


> which is success. Your argument "cleatool" is incorrect
> but your "system" call successfully runs and completes; no system
> error code is returned.


Yes it is.

   perl -le '$ret = system "bad"; print $ret'

   -1


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


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

Date: 19 Apr 2007 15:56:53 -0700
From: Rico <vaj@tempinbox.com>
Subject: From zero to dogfood widgets in one day PERL
Message-Id: <1177023413.470329.304200@o5g2000hsb.googlegroups.com>

>From zero to dogfood widgets in one day
http://widget.teenwag.com/widget



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

Date: 19 Apr 2007 15:52:52 -0700
From: Tim <tbrazil@perforce.com>
Subject: How do I use a literal comma in a system command
Message-Id: <1177023172.675724.213680@b58g2000hsg.googlegroups.com>

Hi

I'm trying to use a comma a part of my system/exe/open command however
it is interpreted as a delimiter. The actural command I'm trying to
execute is:

p4 obliterate -y @813, 813     # the amperstands and comma are
meaningful to the command.

If I use a single  obliterate (e.g. "$p4 obliterate -y  \@
$changenumber") the command executes properly. Once I add the comma
and second \@$changenumber it is interpreted as an additional shell
command.
I've tried escaping the comma, double quoting, double escapes, etc.
Does anyone know how I can successfully passed the comma + second
argument to the actual "p4" command. Thanks in advance.

Tim

The perl looks something like this. $changenumber = 813

 $cmd="$p4 obliterate -y  \@$changenumber, \@$changenumber";
open(OBLITERATE,"$cmd|");
close(OBLITERATE)

sh: line 1: ,@813: command not found



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

Date: Thu, 19 Apr 2007 23:18:06 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: How do I use a literal comma in a system command
Message-Id: <f08tbe$s1v$1@naig.caltech.edu>

In article <1177023172.675724.213680@b58g2000hsg.googlegroups.com>,
Tim  <tbrazil@perforce.com> wrote:
>The perl looks something like this. $changenumber = 813
>
> $cmd="$p4 obliterate -y  \@$changenumber, \@$changenumber";
>open(OBLITERATE,"$cmd|");
>close(OBLITERATE)
>
>sh: line 1: ,@813: command not found

Commas (within quoted strings) are not special to Perl or to the shell,
so I doubt that that is causing your problem.

I'm going to take a wild guess and say that you are reading
$changenumber from a file (or from the terminal), and you aren't 
using chomp() to remove the newline from the end of the string.

Gary
-- 
Customer: "There are smoke and flames coming from my computer." 
Tech Support: "Uh, hang up, unplug the computer from the wall, 
               and call the local fire department." 
Customer: "No, I need to know how to do a backup. Fastest possible method." 


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

Date: 19 Apr 2007 17:10:55 -0700
From: Tim <tbrazil@perforce.com>
Subject: Re: How do I use a literal comma in a system command
Message-Id: <1177027855.340997.296340@e65g2000hsc.googlegroups.com>


> Commas (within quoted strings) are not special to Perl or to the shell,
> so I doubt that that is causing your problem.
>
> I'm going to take a wild guess and say that you are reading
> $changenumber from a file (or from the terminal), and you aren't
> using chomp() to remove the newline from the end of the string.
>
> Gary
> --

Hi Gary

Ooopps..  As soon as I saw the word chomp I knew you were right. I
wasn't reading from a file but was indeed reading from a pipe of
another command. The newline was THERE! Thanks for the help.

Tim



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

Date: 19 Apr 2007 15:25:39 -0700
From: florian <lorian@fsavigny.de>
Subject: Re: Lexical reference to an anonymous recursive subroutine: impossible?
Message-Id: <1177021538.974315.212630@y5g2000hsa.googlegroups.com>

On Apr 19, 7:42 pm, Brian McCauley <nobul...@gmail.com> wrote:

> You forgot to use strict. Had you used strict you've had got a
> different (and much more helpful) error. How much pain do you need
> before you use strict?

Hmm ...

> Exactly the same reason as you'll get an error from
>
> use strict;
> my $foo = $foo;

Frankly, I wouldn't have seen the similarity without knowing. But
you're probably right with using strict. I tried this out on my
example, and

use strict;
use warnings;

$main::times = 0;

{
my $code_ref = sub {
  $main::times++;
  print "Hello, there!\n";
  $code_ref->() until ($main::times == 3); # (line 12)
};

$code_ref->();

}

yielded the error

    Global symbol "$code_ref" requires explicit package name at script
line 12.

which, in fact, tells me that $code_ref in this line is not the
lexical one, while the one in line 15 apparently is. (Not at the very
first glance, but on second look, yes.)



> Note the final undef. This is because you've created a circular
> reference. Without the explicit undef, when the execution pointer
> passes the point where the variable $code_ref goes out of scope the
> closure will not get garbage collected.

> For details see my previous posts on this matter: ...

I've looked into these, and also read the discussion about garbage
collection in this thread. The Camel Book seems to confirm what you
say, but I'm actually rather confused about this, as I'm not advanced
enough (in particular, I've shunned OO and some related stuff so far)
to follow the discussions. But if I've understood the book correctly,
the lexical variable references the anonymous subroutine, while
something inside the subroutine references the variable in turn, which
is why their 'internal reference counts' (whatever that may be) can
never go to zero, even though they go out of scope when the block is
left. I also understand why undef-ing the variable should break this
circle, so I'll do this. Thanks very much for pointing this out!

> Personally I don't like having to manually make sure that $code_ref
> gets undef()ed on _every_ _possible_ execution path so I use a package
> variable and local.

Where I intend to apply it it is never invoked casually but only
inside a certain block in the module file, so it should not be a
problem, I think. (That was actually the point - making it private to
one function.) I know I could have achieved a comparable effect by
using an ordinary subroutine, using Exporter and disallowing to export
the subroutine, which would have restricted it to the module file, but
this seems even more compelling.

Thanks very much for your help!

Florian



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

Date: Fri, 20 Apr 2007 00:47:29 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Lexical reference to an anonymous recursive subroutine: impossible?
Message-Id: <f08rtj$lmd$1@mlucom4.urz.uni-halle.de>

florian wrote:
> I've looked into these, and also read the discussion about garbage
> collection in this thread. The Camel Book seems to confirm what you
> say, but I'm actually rather confused about this, as I'm not advanced
> enough (in particular, I've shunned OO and some related stuff so far)
> to follow the discussions. But if I've understood the book correctly,
> the lexical variable references the anonymous subroutine, while
> something inside the subroutine references the variable in turn, which
> is why their 'internal reference counts' (whatever that may be) can
> never go to zero, even though they go out of scope when the block is
> left. I also understand why undef-ing the variable should break this
> circle, so I'll do this. Thanks very much for pointing this out!

You can also spot the closure disaster
by using the use Devel::Cycle module,
in your case (in my code variant):

    use strict;
    use warnings;
    use Devel::Cycle;

   {
     my $code_ref;
     $code_ref = sub {
         print "@_\n";
         push@_,-1+pop@_ and $_[1] and &$code_ref
     };

     $code_ref->('Hello, there!', 3);
     find_cycle($code_ref);
   }

Would print (here):

    Hello, there! 3
    Hello, there! 2
    Hello, there! 1
    Cycle (1):
	            $A variable $code_ref => \&A

Adding the Devel::Peek module would show the
reference count before leaving the braces:

    ...
    find_cycle($code_ref);
    Dump($code_ref);
   }
   ...

(will print "2"!)

Regards

M.



Regards

M.




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

Date: Thu, 19 Apr 2007 18:29:42 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Lexical reference to an anonymous recursive subroutine: impossible?
Message-Id: <x7ps60ov55.fsf@mail.sysarch.com>

>>>>> "BM" == Brian McCauley <nobull67@gmail.com> writes:

  BM> On Apr 19, 9:08 pm, Uri Guttman <u...@stemsystems.com> wrote:

  >> that code ref should be garbage collected even without the undef as it
  >> leaves scope. nothing outside that block refers to it so it has only one
  >> ref count which goes to 0 upon block exit. should be very simple to test
  >> for this by also blessing it and creating a DESTROY method to print that
  >> it was destroyed.

  BM> Please see the previous thread (2nd one referenced in my post) where
  BM> you asserted exactly the same thing.  You were wrong then (and you
  BM> admitted it). You're wrong again.

i bet you are right because of the ref inside the closure. i was
definitely groggy when i posted that earlier. :) i do use closures a bit
but rarely recursive ones and even more rarely recursive ones that i
need to destroy.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 19 Apr 2007 15:37:27 -0700
From: Nene <rodbass63@gmail.com>
Subject: Printing the next line of text of the file
Message-Id: <1177022247.155505.118120@e65g2000hsc.googlegroups.com>

I wrote a perl script  that opens a file. I wrote a regex that
captures $1 $2 and prints it to output. What I want it to do which I
can't figure out is to print the next line (which has a regex that I
need to capture as well) under the line that has the the regex but I
can't figure it out so far. Any help will be greatly appreciated.

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


open( FILE, $ARGV[0] ) || die "can't open file!";
my @TEST = <FILE>;

foreach my $current_line (@TEST) {

if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+
\S+/) {
print  "$1 $2\n";
##  But I also want to print a regex from the line underneath the
$current_line ###
          }
          }



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

Date: Fri, 20 Apr 2007 00:58:41 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Printing the next line of text of the file
Message-Id: <f08tob$m6e$1@mlucom4.urz.uni-halle.de>

Nene wrote:
> I wrote a perl script  that opens a file. I wrote a regex that
> captures $1 $2 and prints it to output. What I want it to do which I
> can't figure out is to print the next line (which has a regex that I
> need to capture as well) under the line that has the the regex but I
> can't figure it out so far. Any help will be greatly appreciated.
> 
> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
> open( FILE, $ARGV[0] ) || die "can't open file!";
> my @TEST = <FILE>;
> foreach my $current_line (@TEST) {
> if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+
> \S+/) {
> print  "$1 $2\n";
> ##  But I also want to print a regex from the line underneath the
> $current_line ###

I don't really know what you mean with all these 'regex  in the line's,
but if you want to match regex_2 only after regex_1 matched a line
before, then the following *could* work (depending on your data,
which nobody knows).

  use strict;
  use warnings;

  open( my $fh, '<', shift ) or die "can't open file $!";

  my $cnt = 1;
  my $rg_1 = qr/^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+ \S+(?{$cnt=0})/;
  my $rg_2 = qr/(.)(.+)(?{$cnt=1})/;

  for( <$fh> ) {
     print "$1 $2\n" if /$rg_1/ || (!$cnt++ && /$rg_2/)
  }
  ...

Maybe there are better solutions, but an
understanding of your concrete problem
would be the prerequisite ...

Regards

Mirco


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

Date: 19 Apr 2007 16:39:59 -0700
From: Nene <rodbass63@gmail.com>
Subject: Re: Printing the next line of text of the file
Message-Id: <1177025999.889002.306710@b58g2000hsg.googlegroups.com>

On Apr 19, 6:58 pm, Mirco Wahab <wahab-m...@gmx.de> wrote:
> Nene wrote:
> > I wrote a perl script  that opens a file. I wrote a regex that
> > captures $1 $2 and prints it to output. What I want it to do which I
> > can't figure out is to print the next line (which has a regex that I
> > need to capture as well) under the line that has the the regex but I
> > can't figure it out so far. Any help will be greatly appreciated.
>
> > #!/usr/bin/perl -w
> > use strict;
> > use diagnostics;
> > open( FILE, $ARGV[0] ) || die "can't open file!";
> > my @TEST = <FILE>;
> > foreach my $current_line (@TEST) {
> > if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+
> > \S+/) {
> > print  "$1 $2\n";
> > ##  But I also want to print a regex from the line underneath the
> > $current_line ###
>
> I don't really know what you mean with all these 'regex  in the line's,
> but if you want to match regex_2 only after regex_1 matched a line
> before, then the following *could* work (depending on your data,
> which nobody knows).
>
>   use strict;
>   use warnings;
>
>   open( my $fh, '<', shift ) or die "can't open file $!";
>
>   my $cnt = 1;
>   my $rg_1 = qr/^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+ \S+(?{$cnt=0})/;
>   my $rg_2 = qr/(.)(.+)(?{$cnt=1})/;
>
>   for( <$fh> ) {
>      print "$1 $2\n" if /$rg_1/ || (!$cnt++ && /$rg_2/)
>   }
>   ...
>
> Maybe there are better solutions, but an
> understanding of your concrete problem
> would be the prerequisite ...
>
> Regards
>
> Mirco

Thank you for responding and I apologize for not being clear.

I want to print (2007-04-18) and  (00:05:05) and I want to print where
(login_id = 'XSKW0010') which is the next line following this huge
select query.

Here is the data: (remember, everything from  00004C09 to 'restrict
ip' ) is one line.

00004C09 2007-04-18 00:05:05 12241 554188953 " select user.status,
user.user_id, user.company_id, isnull(t.detail1),'-1',t.detail1) as
ExpirationDate , if(isnull(t2.detail1),'0',t2.detail1) as inhouse,
c.company_status,c.company_name , a.line1 as address1 , a.city as
city ,a.state as state ,a.zip as zip, t3.detail1 as iprestricted from
hello.user as user , crapwise.company c  LEFT JOIN crapwise.address a
ON c.main_address_id = a.address_id  LEFT JOIN crapwise.tag_table t ON
t.user_id = user.user_id and t.company_id = user.company_id and
t.category = 'UserFlag' and t.sub_category = 'ExpirationDate' LEFT
JOIN crapwise.tag_table t2 ON t2.user_id = user.user_id and
t2.company_id = user.company_id and t2.category = 'User Options' and
t2.sub_category = 'InhouseSOAPUser'  LEFT JOIN crapwise.tag_table t3
ON t3.company_id = user.company_id and t3.category =
'company security' and t3.sub_category = 'restrict ip'
where login_id = 'WSKW0010'  and password = 'xxxxxxxxx'  and
c.company_id =



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

Date: Thu, 19 Apr 2007 17:03:15 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Printing the next line of text of the file
Message-Id: <190420071703153476%jgibson@mail.arc.nasa.gov>

In article <1177025999.889002.306710@b58g2000hsg.googlegroups.com>,
Nene <rodbass63@gmail.com> wrote:

> On Apr 19, 6:58 pm, Mirco Wahab <wahab-m...@gmx.de> wrote:

[suggested program snipped]

> 
> Thank you for responding and I apologize for not being clear.
> 
> I want to print (2007-04-18) and  (00:05:05) and I want to print where
> (login_id = 'XSKW0010') which is the next line following this huge
> select query.
> 
> Here is the data: (remember, everything from  00004C09 to 'restrict
> ip' ) is one line.
> 
> 00004C09 2007-04-18 00:05:05 12241 554188953 " select user.status,
> user.user_id, user.company_id, isnull(t.detail1),'-1',t.detail1) as
> ExpirationDate , if(isnull(t2.detail1),'0',t2.detail1) as inhouse,
> c.company_status,c.company_name , a.line1 as address1 , a.city as
> city ,a.state as state ,a.zip as zip, t3.detail1 as iprestricted from
> hello.user as user , crapwise.company c  LEFT JOIN crapwise.address a
> ON c.main_address_id = a.address_id  LEFT JOIN crapwise.tag_table t ON
> t.user_id = user.user_id and t.company_id = user.company_id and
> t.category = 'UserFlag' and t.sub_category = 'ExpirationDate' LEFT
> JOIN crapwise.tag_table t2 ON t2.user_id = user.user_id and
> t2.company_id = user.company_id and t2.category = 'User Options' and
> t2.sub_category = 'InhouseSOAPUser'  LEFT JOIN crapwise.tag_table t3
> ON t3.company_id = user.company_id and t3.category =
> 'company security' and t3.sub_category = 'restrict ip'
> where login_id = 'WSKW0010'  and password = 'xxxxxxxxx'  and
> c.company_id =

Please reduce your examples to something reasonable. E.g.

00004C09 2007-04-18 00:05:05 12241 554188953
where login_id = 'WSKW0010'

The concept is the same for this shorter data set but much easier to
understand. You are more likely to get useful help this way.

When you find a match, read the next line and test it (derived from
Mirco's solution and untested):

use strict;
use warnings;

open( my $fh, '<', shift ) or die "can't open file $!";

my $rg_1 = qr/^\S+ (\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d) \S+/;
my $rg_2 = qr/^where login_id = '(\w+)'/;

for( <$fh> ) {
  if( /$rg_1/ ) {
    print "$1 $2\n" 
    my $next = <$fh>;
    if( $next =~ /$rg_2/ ) {
      print "$1\n"
    }
  }
}

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Fri, 20 Apr 2007 01:53:00 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Printing the next line of text of the file
Message-Id: <f090u7$n5h$1@mlucom4.urz.uni-halle.de>

Nene wrote:
> I want to print (2007-04-18) and  (00:05:05) and I want to print where
> (login_id = 'XSKW0010') which is the next line following this huge
> select query.
> 
> Here is the data: (remember, everything from  00004C09 to 'restrict
> ip' ) is one line.

If I understood correctly, you want simply
print [always] the line following your match,
which contains a date and a time?

Then something like this should work:


  open( my $fh, '<', shift ) or die "can't open file $!";

  my $flag = 1;
  my $rg = qr/^\w+\s+(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})(?{$flag=0})/;

  while( <$fh> ) {
     if( /$rg/ ) {
       print "$1 $2\n"
     }
    else {
       print unless $flag++
    }
  }

Regards

M.


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

Date: Thu, 19 Apr 2007 21:02:36 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Printing the next line of text of the file
Message-Id: <slrnf2g7ps.fk3.tadmc@tadmc30.august.net>

Nene <rodbass63@gmail.com> wrote:

> Subject: Printing the next line of text of the file


But you don't what to do that.

You want to print the next line of text of the array.


> I wrote a perl script  that opens a file. I wrote a regex that
> captures $1 $2 and prints it to output. 


It is impossible for a regex to print.


> What I want it to do which I
> can't figure out is to print the next line (which has a regex that I
> need to capture as well) under the line that has the the regex but I
> can't figure it out so far. Any help will be greatly appreciated.


You need to make a distinction that you seem to be missing.

There are 2 components to a pattern match, the pattern and the
string that the pattern is to be matched against.

The next line does not "have a regex", it has a string (that matches
a regex).


> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
>
>
> open( FILE, $ARGV[0] ) || die "can't open file!";
> my @TEST = <FILE>;


You should not slurp the entire file into an array unless your
algorithm requires it.

The solution to your problem is very easy if you had not fallen
into that bad habit.


> foreach my $current_line (@TEST) {
>
> if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+
> \S+/) {
> print  "$1 $2\n";
> ##  But I also want to print a regex from the line underneath the
> $current_line ###
>           }
>           }


   while ( my $current_line = <FILE> ) { 
      if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+ \S+/) {
         print  "$1 $2\n";
         my $next_line = <FILE>;
         if ( $next_line =~ /some other regex/ ) {
            ...


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


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

Date: Thu, 19 Apr 2007 20:39:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Server For Rent? Where?
Message-Id: <slrnf2g6ea.fk3.tadmc@tadmc30.august.net>

skieros <nikos1337@gmail.com> wrote:
> On Apr 19, 5:37 pm, "Jürgen Exner" <jurge...@hotmail.com> wrote:
>> skieros wrote:
>> >>> Well does someone of you want to give me access to a server of his
>> >> From now and one
>>
>> What do you mean with "now and one"? I am not familiar with this term.
>>
>> > please only people answerign this post with a "yes"
>> >> i
>> > can rent you a linxu server answer my offer, not every and each of you
>> > posting to just say no...
>>
>> You don't get it, do you? Once again very slowly, such that maybe even you
>> can understand:
>>
>>     THIS USENET NEWSGROUP IS FOR DISCUSSING THE Perl PROGRAMMING LANGUAGE.
>>
>> This group has nothing to do with CGI and it has nothing to do with web
>> servers and it certainly has nothing to do with aquiring whatever server it
>> is you are looking for, no matter if for rent or for free.
>>
>> jue
>
> I knwo whats this group is about but sometiems you cna get help from
> anywhere.


Please stop littering in our park.


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


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

Date: Thu, 19 Apr 2007 20:41:04 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Server For Rent? Where?
Message-Id: <slrnf2g6hg.fk3.tadmc@tadmc30.august.net>

skieros <nikos1337@gmail.com> wrote:
> On Apr 19, 7:03 pm, "Jürgen Exner" <jurge...@hotmail.com> wrote:

>> *PLONK*

> Couldnt care less....


Then feel free to have another.

*plonk*


> and i dotn have an online spelling checker, the
> typos are due to speed iam writing...


Your typos convey that you do not value the time of your audience.

That is likely to piss them off too.


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


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 361
**************************************


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