Determine return value of new CGI::Session(...)

2003-10-21 Thread perl
How can I determine if the return value if it is a new or current session?

$session=new CGI::Session(driver:File, $cgi, {Directory='/tmp'});

This calls return a $session but I can't determin in the program if it was
new or current. I'm looking for something like below:

if($session=new CGI::Session(driver:File, $cgi, {Directory='/tmp'}))
{ print this is a new session; }
else
{ print this is a current session; }

thanks


-
eMail solutions by 
http://www.swanmail.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tokens??

2003-10-21 Thread PerlDiscuss - Perl Newsgroups and mailing lists
HI,

I am brand new to Perl and I am trying to modify a script that someone
else wrote.


I have this line where primaryntaccount = something like this
domainname\userid

Token=primaryntaccount:: %ntaccount% = (\\w+).*$

I want to pass a different value for primaryntaccount which I am getting
by the following line. 

where $UPN = [EMAIL PROTECTED]

@array = split/([EMAIL PROTECTED])/, $UPN;
$UPN2 = @array[0];
Token=$UPN2:: %ntaccount% = (\\w+).*$;

Like I said I am totally new to perl and I don't even really understand
how the token line really works.  The best I can ascertain is that it is
passing something back up to DRA.  What is DRA?

What does this bit do is this simply formatting the data or is it parsing
the variable (\\w+).*$ ?

Any help is appreciated.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: call one perl script within another

2003-10-21 Thread Geer, David van der
 How Can I call a perl script within my main script
   If I do
 $response=`perl $somescript $args`;

This will fork and open a shell so is slow

do  $somescript $args;
 But How do I get the reponse of the script.
 Is there a way or should I just use the backticks

Please look at system() and exec() this should help you out.

Regs David

 Thanks
 Ram


*
This message is intended only for the person or entity to 
which it is addressed and may contain confidential and/or
privileged information, the disclosure of which is prohibited.
If you are not the intended recipient you may not read, 
use, disseminate or copy the information transmitted. If 
you have received this message in error, please contact 
the sender and delete the material from any computer.
Dit bericht is uitsluitend bestemd voor de (rechts)persoon
aan welke het is gericht. Het kan vertrouwelijke of
alleen voor deze bestemde informatie bevatten, die niet
mag worden geopenbaard. Als dit bericht niet voor u
bestemd is, mag u de ontvangen informatie niet lezen,
gebruiken, verspreiden of kopieren. Als u dit bericht 
abusievelijk hebt ontvangen, gelieve u het te deleten en
contact op te nemen met de afzender.




**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File sorting by a specific date

2003-10-21 Thread Paul Harwood
 This isn't working for some reason. The $date scalar seems unchanged throughout. 

Paul Harwood wrote:

 I want to search a directory of log files and populate a list of those
 log files ONLY if they match today's date (localtime).

 $logs = 'c:\logs\W3SVC1';
 opendir LOGS, $logs or die Can't open directory:  $!\n;
 my @files = grep /\.TXT$/, readdir LOGS;

 #Right here, I am wondering if there is a simple way of populating @files
 by using a date comparison operation of each file to the local time. I've
 tried long complicated methods of using 'stat' and Time::Local but I was
 hoping for a simpler solution.

Ah, a simple solution.  :-)

( my $date = localtime ) =~ s'\d+:\d+:\d+'\d+:\d+:\d+';

my @files = grep localtime( (stat)[9] ) =~ $date, c:/logs/W3SVC1/*.TXT;

print @files\n;



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: Beginning beginner needing references help

2003-10-21 Thread Darin McBride
Jonathan Mangin wrote:

 Jeez, this is a beginner's list? Y'all are defining my ignorance of this
 here purrl stuff. I hope someone with patience can help me out. In a
 simple login/registration program using 5.6.1...
 
 #!/usr/bin/perl -wT
 use strict;
 
 [CGI and DBI stuff]

IOW, important stuff removed.

 $countryid=1;
 $statename=$gotcha;
 @r_states=getStates([EMAIL PROTECTED], \%states1, \%states2);
 $stateid=$states2{$statename};
 @r_counties=getCounties([EMAIL PROTECTED], \%counties1);
 
 if ($CGI-param(Register)) {
Register($CGI, \%$counties1);
 }
 elsif ($CGI-param(Verify)) {
Verify($CGI);
 }
 else {
displayLoginScreen($CGI);
 }
 sub displayLoginScreen {
[misc stuff]

IOW, even more important stuff removed.

foreach $state(@states) {# I already have the state, of course
   print option$state;   # Still here for historical/testing
}
 
[more stuff]

Probably irrelevant stuff here.

 }
 
 Through the scope(?) of displayLoginScreen (main?) all of the state/county
 arrays/hashes are available, though note the @states syntax instead of
 @$states. (Why is this syntax working?) The states data is more persistent
 (I'll later figure out why if ever a pattern emerges), but Verify knows
 the county stuff only until the first validation error.

I'm not seeing all your declarations, nor how you handle parameters to
displayLoginScreen.

Further, I'd suggest using a framework (I use CGI::Application) rather
than coding CGI directly.  It can make a lot of this stuff make more
sense because it will greatly discourage global variables (which is
what you have).  Global scope is only evil because of scope issues. 
(If you know what you're doing, this can be used for great good, but
not usually.)

 Instead of making subsequent db fetches I want to send(?) any/all of these
 to any/all subsequent (inner?) subroutines that may need them. Is this
 possible and what might the referencing/dereferencing look like?

You can put your data into a hash, as an example, and pass around the
hash ref.  With CGI::Application (hereafter C::A), you would put the
data into your C::A object, and thus have access to it where you need
it via $self.

 Verify calls other subroutines and then another HTML page. That page calls
 Register. Do I need to send references to Verify before sending them to
 the other subs?
 
 You can see what I'm trying with Register. After many fanciful iterations

Actually, I'm not entirely sure.  Perhaps you could look at C::A (it's
on CPAN) and figure out how to reformulate your ideas into the neatly
partitioned framework that C::A provides.

 of code I'm still clueless. My wordiness is to encourage you to the same.
 Thanks to all.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Apache::Session vs CGI::Session

2003-10-21 Thread Andrew Shitov
Does opening a new browser causes a new session in either of the two?
What for are you going to use sessions? I mean: is threr a real 
necessity of using some modules?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: call one perl script within another

2003-10-21 Thread Andrew Shitov
This will call a new perl process, and may be more expensive on the 
system. On the other hand I can do
...
But How do I get the reponse of the script.
Probably the simpliest way is to make called script a module and run it 
using either 'use' or 'require'.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Beginning beginner needing references help

2003-10-21 Thread Rob Dixon
Jonathan Mangin wrote:

 Jeez, this is a beginner's list? Y'all are defining my
 ignorance of this here purrl stuff. I hope someone with
 patience can help me out. In a simple login/registration
 program using 5.6.1...

 #!/usr/bin/perl -wT
 use strict;

 [CGI and DBI stuff]

 $countryid=1;
 $statename=$gotcha;
 @r_states=getStates([EMAIL PROTECTED], \%states1, \%states2);
 $stateid=$states2{$statename};
 @r_counties=getCounties([EMAIL PROTECTED], \%counties1);

 if ($CGI-param(Register)) {
Register($CGI, \%$counties1);
 }
 elsif ($CGI-param(Verify)) {
Verify($CGI);
 }
 else {
displayLoginScreen($CGI);
 }
 sub displayLoginScreen {
[misc stuff]

foreach $state(@states) {# I already have the state, of
course
   print option$state;   # Still here for
historical/testing
}

[more stuff]
 }

 Through the scope(?) of displayLoginScreen (main?) all of the
 state/county arrays/hashes are available, though note the
 @states syntax instead of @$states. (Why is this syntax
 working?) The states data is more persistent (I'll later
 figure out why if ever a pattern emerges), but Verify knows
 the county stuff only until the first validation error.

All of the variables that you've declared ouside any subroutines
are accessible throughout the rest of the file, both within and
outside subroutines. You're simply accessing the common
'@states' variable in 'displayLoginScreen'. '@states' and
'$states' are totally unrealted: they just happen to have the
same identifier. The syntax '@$states' is an attempt to
dereference the value in the '$states' scalar as an array. This
will fail unless '$states' holds an array reference. I don't
understand what you mean by more persistent or by 'Verify'
knows the county stuff only until the first validation error.
You're passing no references to 'Verify' so it can only be
accessing the common variables like '@states'.

 Instead of making subsequent db fetches I want to send(?)
 any/all of these to any/all subsequent (inner?) subroutines
 that may need them. Is this possible and what might the
 referencing/dereferencing look like?

You can either do what you've done above, and simply declare
common variables at a wider scope so that they're accessible
everywhere or - more properly - pass references to all of the
data as as parameters. You'd then have something like

  displayLoginScreen($CGI, [EMAIL PROTECTED]);

  sub displayLoginScreen {
my ($CGI, $states) = @_;
foreach my $state (@$states) {
  :
}
  }

 Verify calls other subroutines and then another HTML page.
 That page calls Register. Do I need to send references to
 Verify before sending them to the other subs?

If you're expecting the call to the other subroutines to pass
all of the data they need, then clearly the calling code has to
have access to that data to be able to pass it on. This is where
parameterising all data can get messy, and it becomes more
appropriate to use common data accessible everywhere, preferably
with some naming convention that makes it clear that it is
global data.

 You can see what I'm trying with Register. After many fanciful
 iterations of code I'm still clueless. My wordiness is to
 encourage you to the same. Thanks to all.

You've called

  Register($CGI, \%$counties1)

which first of all dereferences '$counties1' (which, remember is
totally independent of '%counties1') as a hash. It then takes a
reference to that hash so the resulting value should be the same
as '$counties1' (if that variable held a hash reference in the
first place). Without seeing what '%counties1' might be I can
only guess that your call should be

  Register($CGI, \%counties1)

but you seemed to know what to do in the previous call to
'getStates', like this.

  getStates([EMAIL PROTECTED], \%states1, \%states2)

I hope that helps.

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



javascript Parsing

2003-10-21 Thread Francesco del Vecchio
Hi to all,

I need to parse javascript into web pages to substitute all relative addresses to 
absolute ones. 

I do this job in the HTML using LWP but I'm having bad times trying to do it into 
javascript
contained in the page.

Can anyone help me?

Frank

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: call one perl script within another

2003-10-21 Thread Ramprasad A Padmanabhan
Andrew Shitov wrote:
This will call a new perl process, and may be more expensive on the 
system. On the other hand I can do
...

But How do I get the reponse of the script.


Probably the simpliest way is to make called script a module and run it 
using either 'use' or 'require'.

Precisely , But That is something I cannot do because the script is in a 
file which is written on the fly by the client end settings.

Ideally it should have been such a way that The client settings are 
written into a configuration file  and the program reads the 
configuraton file and runs the condition.

The point over here is , Is it possible to use the existing instance of 
perl running main to run the child program and return the output

THanks
Ram


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How do you find out the size of a file

2003-10-21 Thread Rob Dixon
John W. Krahn wrote:
 Chinku Simon wrote:

  I have a requirement to find out the size of a file existing
  in an NTFS file system.

 my $file_size = -s $file_name;

 perldoc -f -s

Thanks John.

It's also worth pointing out that the '-s' operator is
/indentical/ to calling 'stat' and taking the eighth element
from the returned list.

Cheers,

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: call one perl script within another

2003-10-21 Thread Randal L. Schwartz
 David == David Van Der Geer [EMAIL PROTECTED] writes:

David *
David This message is intended only for the person or entity to 
David which it is addressed and may contain confidential and/or
David privileged information, the disclosure of which is prohibited.
David If you are not the intended recipient you may not read, 
David use, disseminate or copy the information transmitted. If 
David you have received this message in error, please contact 
David the sender and delete the material from any computer.
David Dit bericht is uitsluitend bestemd voor de (rechts)persoon
David aan welke het is gericht. Het kan vertrouwelijke of
David alleen voor deze bestemde informatie bevatten, die niet
David mag worden geopenbaard. Als dit bericht niet voor u
David bestemd is, mag u de ontvangen informatie niet lezen,
David gebruiken, verspreiden of kopieren. Als u dit bericht 
David abusievelijk hebt ontvangen, gelieve u het te deleten en
David contact op te nemen met de afzender.
David 



David **
David This email and any files transmitted with it are confidential and
David intended solely for the use of the individual or entity to whom they
David are addressed. If you have received this email in error please notify
David the system manager.

David This footnote also confirms that this email message has been swept by
David MIMEsweeper for the presence of computer viruses.

David www.mimesweeper.com
David **

Goodness, Gracious!

31 lines of disclaimer, attached to a 15 line message (counting
the quoted material).

As I've said before:

You have exceeded the 4-line .sig boilerplate limit with a
worthless unenforcable disclaimer.  Please remove this text from
future postings to this mailing list.  If you cannot do so for
mail from your domain, please get a freemail account and rejoin
the list from there.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Beginning beginner needing references help

2003-10-21 Thread R. Joseph Newton
Jonathan Mangin wrote:

 Jeez, this is a beginner's list? Y'all are defining my ignorance of this here purrl 
 stuff.
 I hope someone with patience can help me out. In a simple login/registration program
 using 5.6.1...

 #!/usr/bin/perl -wT
 use strict;

Something is screwy here ...

 [CGI and DBI stuff]

 $countryid=1;

Where did this come from if you are using strict?  Unless you declared $countryid 
elsewhere [not a good idea], you should have received an error on this line.

Note:  You can, and really should, have whitespace between binary operators and their 
operands.  You gain no efficiency by torturing your eyes unnecessarily.

Please repost with more context, particularly showing the declarations of te variables 
used.


Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Beginning beginner needing references help

2003-10-21 Thread Rob Dixon
Hi Joseph.

R. Joseph Newton  wrote:

 Jonathan Mangin wrote:
 
  Jeez, this is a beginner's list? Y'all are defining my
  ignorance of this here purrl stuff. I hope someone with
  patience can help me out. In a simple login/registration
  program using 5.6.1...
 
  #!/usr/bin/perl -wT
  use strict;

 Something is screwy here ...

  [CGI and DBI stuff]
 
  $countryid=1;

 Where did this come from if you are using strict?  Unless you
 declared $countryid elsewhere [not a good idea], you should
 have received an error on this line.

As a beginner it's difficult to know what of your code is
relevant to the question and what's not. Perl suffers from being
programmed as if it were C, C++, or shell script instead of what
it actually is. This looks like C programming to me, where all
the variables are declared at the beginning of the file and then
forgotten about. Whatever, since there's a 'use strict' in there
there can be no mistyped identifiers and the code is unambiguous
at this point: '$countryid' must have been declared and now has
the value '1' (albeit a string).

 Note:  You can, and really should, have whitespace between
 binary operators and their operands.  You gain no efficiency
 by torturing your eyes unnecessarily.

This is a good place to mention

  perldoc perlstyle

which is as good a set of layout rules as any.

 Please repost with more context, particularly showing the
 declarations of te variables used.

The problem seems to be a misunderstanding of both references
and declarations. Feedback from Jonathan will hopefully tell us!

Cheers,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: call one perl script within another

2003-10-21 Thread Geer, David van der
 As I've said before:
 
You have exceeded the 4-line .sig boilerplate limit with a
worthless unenforcable disclaimer.  Please remove this text from
future postings to this mailing list.  If you cannot do so for
mail from your domain, please get a freemail account and rejoin
the list from there.

I will unsubscribe, it's not possible to get rid of the nasty lines.
If it is a problem to look over the last lines, I will leave.

Bye.

P.S. : It's against the rules to mail persons in private.

David


*
This message is intended only for the person or entity to 
which it is addressed and may contain confidential and/or
privileged information, the disclosure of which is prohibited.
If you are not the intended recipient you may not read, 
use, disseminate or copy the information transmitted. If 
you have received this message in error, please contact 
the sender and delete the material from any computer.
Dit bericht is uitsluitend bestemd voor de (rechts)persoon
aan welke het is gericht. Het kan vertrouwelijke of
alleen voor deze bestemde informatie bevatten, die niet
mag worden geopenbaard. Als dit bericht niet voor u
bestemd is, mag u de ontvangen informatie niet lezen,
gebruiken, verspreiden of kopieren. Als u dit bericht 
abusievelijk hebt ontvangen, gelieve u het te deleten en
contact op te nemen met de afzender.




**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: call one perl script within another

2003-10-21 Thread Wiggins d Anconia


 Andrew Shitov wrote:
  This will call a new perl process, and may be more expensive on the 
  system. On the other hand I can do
  
  ...
  
  But How do I get the reponse of the script.
  
  
  Probably the simpliest way is to make called script a module and run it 
  using either 'use' or 'require'.
  
 
 Precisely , But That is something I cannot do because the script is in a 
 file which is written on the fly by the client end settings.
 
 Ideally it should have been such a way that The client settings are 
 written into a configuration file  and the program reads the 
 configuraton file and runs the condition.
 
 The point over here is , Is it possible to use the existing instance of 
 perl running main to run the child program and return the output
 

'require' is runtime not compile time, so assuming you can regulate the
sequence of events, aka the file is known to be written (or testable in
a loop) before the call to require then this will still work even if the
file does not exist at runtime.  If you are worried about the require
failing because of a missing file then wrap the whole construct in an
'eval' and catch the exceptions (which you should do anyways). 

... still isn't a compelling reason to call one Perl script from another...

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: call one perl script within another

2003-10-21 Thread Dan Anderson
I think there's a function called eval which lets you evaluate perl code
on the fly.  http://www.perldoc.com/perl5.8.0/pod/func/eval.html  

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Beginning beginner needing references help

2003-10-21 Thread Jonathan Mangin

- Original Message -
From: Rob Dixon [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 21, 2003 4:31 AM
Subject: Re: Beginning beginner needing references help


 Jonathan Mangin wrote:
 
  Jeez, this is a beginner's list?
 
Thank you for all the responses. I'll try to answer everyone's concerns
here.
This is an inherited project I'm converting from cgi-lib.pl to cgi.pm. I'm
purposely doing everything the hard way in an effort to learn more core
perl.
Session management is next, then converting to C::A. That's the plan.?

  #!/usr/bin/perl -wT
  use strict;
 
  [CGI and DBI stuff]
 
  $countryid=1;

$countryid is being declared globally with use vars. It's processed and
stored where
needed but is meaningless at this time.

  $statename=$gotcha;
  @r_states=getStates([EMAIL PROTECTED], \%states1, \%states2);
  $stateid=$states2{$statename};
  @r_counties=getCounties([EMAIL PROTECTED], \%counties1);
 
Best practices or less, I intended (at this time) these arrays/hashii to be
global. More later...

  if ($CGI-param(Register)) {
 Register($CGI, \%$counties1);
  }

Hmm, I truly thought the syntax should be: Register($CGI, \%counties1);
I cut and pasted one of my fanciful iterations.

  elsif ($CGI-param(Verify)) {
 Verify($CGI);
  }
  else {
 displayLoginScreen($CGI);
  }
  sub displayLoginScreen {
 [misc stuff]
 
Let's add to the following for a test:

 foreach $state(@states) {
print option$state;
 }
foreach $county(@counties) {
   print option$county;
}

Now the list of states also includes the counties (fetched previously based
on $stateid).

 
 [more stuff]
  }
 
  Through the scope(?) of displayLoginScreen (main?) all of the
  state/county arrays/hashes are available, though note the
  @states syntax instead of @$states. (Why is this syntax
  working?) The states data is more persistent (I'll later
  figure out why if ever a pattern emerges), but Verify knows
  the county stuff only until the first validation error.

 All of the variables that you've declared ouside any subroutines
 are accessible throughout the rest of the file, both within and
 outside subroutines. You're simply accessing the common
 '@states' variable in 'displayLoginScreen'. '@states' and
 '$states' are totally unrealted: they just happen to have the
 same identifier. The syntax '@$states' is an attempt to
 dereference the value in the '$states' scalar as an array. This
 will fail unless '$states' holds an array reference. I don't
 understand what you mean by more persistent or by 'Verify'
 knows the county stuff only until the first validation error.
 You're passing no references to 'Verify' so it can only be
 accessing the common variables like '@states'.

Subroutine 'Verify' processes the fields from displayLoginScreen,
validates the input and checks the db for existing records. (We're
actually attempting a new registration here.) i.e.:

sub Verify {
   my $cgi=shift;
   $uid=$cgi-param(-name='uid');
   if (length($uid)  6) {
  displayLoginScreen($cgi);
   }
   elsif (nextErrorCondition) {
  displayLoginScreen($cgi);
   } else {
  [more stuff]
  if ([more stuff] =OK) {
 displayRegisterScreen($cgi);
  }
   }
}

Upon the first error condition being true (or true again) and subroutine
displayLoginScreen being [re]called, my list of select options still
includes
@states but not @counties. Are these not global, or is @counties being
undefined somehow?

  Instead of making subsequent db fetches I want to send(?)
  any/all of these to any/all subsequent (inner?) subroutines
  that may need them. Is this possible and what might the
  referencing/dereferencing look like?

 You can either do what you've done above, and simply declare
 common variables at a wider scope so that they're accessible
 everywhere or - more properly - pass references to all of the
 data as as parameters. You'd then have something like

   displayLoginScreen($CGI, [EMAIL PROTECTED]);

   sub displayLoginScreen {
 my ($CGI, $states) = @_;
 foreach my $state (@$states) {
   :
 }
   }

  Verify calls other subroutines and then another HTML page.
  That page calls Register. Do I need to send references to
  Verify before sending them to the other subs?

 If you're expecting the call to the other subroutines to pass
 all of the data they need, then clearly the calling code has to
 have access to that data to be able to pass it on. This is where
 parameterising all data can get messy, and it becomes more
 appropriate to use common data accessible everywhere, preferably
 with some naming convention that makes it clear that it is
 global data.

If I need to explicitly pass data (references) to subroutines that's OK
cause that's what I'm trying to learn. The @states vs. @counties
inconsistency has me confused.

 but you seemed to know what to do in the previous call to
 'getStates', like this.

   getStates([EMAIL PROTECTED], \%states1, \%states2)

 I hope that helps.

Rob


Parsing pipe delimited file

2003-10-21 Thread Kevin Old
Hello everyone,

Thanks to everyone who helped with my last problem last week.  I've hit
a snag in another problem this week.

I need to parse the following data:

COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2||COUNTRY FEMALE
PARTY SONGS VOL. 2  UPC#:  0-84296-28682-9||COUNTRY MALE PARTY
SONGS VOL. 2   UPC#:  0-84296-28652-2||| ||
|||
|||
TRACK|||MADE FAMOUS BY|||TRACK|||MADE FAMOUS BY|||TRACK|||MADE
FAMOUS BY
 1. CRAZY|||PATSY CLINE||| 1. SOME DAYS YOU GOTTA DANCE|||DIXIE
CHICKS||| 1. THE LONG GOODBYE|||BROOKS  DUNN
 2. ANGELS AMONG US|||ALABAMA||| 2. BLESSED|||MARTINA McBRIDE|||
2. MY LIST|||TOBY KEITH
 3. I WILL ALWAYS LOVE YOU|||DOLLY PARTON||| 3. BRING ON THE
RAIN|||JO DEE MESSINA W/ TIM McGRAW||| 3. THE COWBOY IN ME|||TIM
McGRAW
 4. ON THE ROAD AGAIN|||WILLIE NELSON||| 4. CAN'T FIGHT THE
MOONLIGHT|||LEANN RIMES||| 4. I BREATHE IN, I BREATHE OUT|||CHRIS
CAGLE
 5. STAND BY YOUR MAN|||TAMMY WYNETTE||| 5. I'LL FLY
AWAY|||ALISON KRAUSS W/ GILLIAN WELCH||| 5. YOUNG|||KENNY CHESNEY
 6. FOREVER AND EVER AMEN|||RANDY TRAVIS||| 6. I HOPE YOU
DANCE|||LEE ANN WOMACK||| 6. GOOD MORNING BEAUTIFUL|||STEVE HOLY
 7. SMALL TOWN GIRL|||STEVE WARINER||| 7. I KEEP LOOKING|||SARA
EVANS||| 7. WRAPPED AROUND|||BRAD PAISLEY
 8. GRANDPA|||THE JUDDS||| 8. WHEN YOU LIE NEXT TO ME|||KELLIE
COFFEY||| 8. THAT'S WHEN I LOVE YOU|||PHIL VASSAR
 9. BORN TO BOOGIE|||HANK WILLIAMS, JR.||| 9. DOWNTIME|||JO DEE
MESSINA||| 9. WHAT IF SHE'S AN ANGEL|||TOMMY SHANE STEINER
10. YOU NEEDED ME|||ANNE MURRAY|||10. MAYBE, MAYBE NOT|||MINDY
McCREADY|||10. MODERN DAY BONNIE  CLYDE|||TRAVIS TRITT
11. THE GAMBLER|||KENNY ROGERS|||11. INSIDE OUT|||TRISHA
YEARWOOD|||11. IN ANOTHER WORLD|||JOE DIFFIE
12. I FALL TO PIECES|||PATSY CLINE|||12. THERE YOU'LL BE|||FAITH
HILL|||12. I AM A MAN OF CONSTANT SORROW|||SOGGY BOTTOM BOYS
13. SNAP YOUR FINGERS|||RONNIE MILSAP|||13. I DON'T WANT YOU TO
GO|||CAROLYN DAWN JOHNSON|||13. WRAPPED UP IN YOU|||GARTH BROOKS
14. TWO MORE BOTTLES OF WINE|||EMMYLOU HARRIS|||14. I NEED
YOU|||LEANN RIMES|||14. NOT A DAY GOES BY|||LONESTAR
15. OCEAN FRONT PROPERTY|||GEORGE STRAIT|||15. WHAT I REALLY MEANT
TO SAY|||CYNDI THOMSON|||15. I SHOULD BE SLEEPING|||EMERSON DRIVE
16. SOME KIND OF TROUBLE|||TANYA TUCKER|||16. THAT'S THE WAY|||JO
DEE MESSINA|||16. I WANNA TALK ABOUT ME|||TOBY KEITH


Now, let me explain the data.  There are 3 albums here.  The titles and
UPC's are in the first line.  I have a loop that separates the title and
the piece of the UPC that I need and puts it into a hash.

my %titles = ();
while(KB) {

my @songs;
my @artist;
my @line = split/\|/,$_;
foreach ($line[0], $line[6], $line[12]) {

if($_
$_ =~ s///g;
$_ =~ /^(.*?)\s+UPC#:\s+0-84296-(\d+)-\d/g;
my $title = $1;
my $upc = $2;
$titles{$upc}{title} = $title;
}

}

Then the rest of the lines are Tracks and Artists.  What I need to
do is get the appropriate tracks and artists in respective (@tracks,
@artists) arrays inside the hash.

Basically, I need to know how to write code that does this:

Get the 3 albums to be processed, put title in hash with UPC as key
(done with code above)

Parse next 16 lines (3 tracks and artists on each line) and associate
them with the proper song  artist arrays in the hash.

I know this is rather confusing, but any help is appreciated!

Kevin

-- 
Kevin Old [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Beginning beginner needing references help

2003-10-21 Thread Rob Dixon
Hi Jonathan.

This thread needs splitting. And you need to formulate and ask
one question at a time. There's no use in starting with an
entire program that doesn't work and trying to fix it. Model
each of your problems in a tiny piece of Perl and fix them
one at a time. It will help you as well as ourselves.

Jonathan Mangin wrote:

 Thank you for all the responses. I'll try to answer everyone's
 concerns here. This is an inherited project I'm converting
 from cgi-lib.pl to cgi.pm. I'm purposely doing everything the
 hard way in an effort to learn more core perl. Session
 management is next, then converting to C::A. That's the plan.?

   #!/usr/bin/perl -wT
   use strict;
  
   [CGI and DBI stuff]
  
   $countryid=1;

 $countryid is being declared globally with use vars. It's
 processed and stored where needed but is meaningless at this
 time.

What version of Perl are you running? 'use vars' has been
superseded by 'our' for a long time. Also you need to be sure
that you use 'our' variables as little as possible.

   $statename=$gotcha;
   @r_states=getStates([EMAIL PROTECTED], \%states1, \%states2);
   $stateid=$states2{$statename};
   @r_counties=getCounties([EMAIL PROTECTED], \%counties1);
  

 Best practices or less, I intended (at this time) these
 arrays/hashii to be global. More later...

That doesn't look like a bad decision, as long as you've made a
design choice about exactly /which/ variables should be
global.

   if ($CGI-param(Register)) {
  Register($CGI, \%$counties1);
   }

 Hmm, I truly thought the syntax should be: Register($CGI,
 \%counties1); I cut and pasted one of my fanciful iterations.

Your thoughts were right. But if '%counties1' is a global
variable then it would be very wrong to pass it to a subroutine
in any way.

   elsif ($CGI-param(Verify)) {
  Verify($CGI);
   }
   else {
  displayLoginScreen($CGI);
   }
   sub displayLoginScreen {
  [misc stuff]
  

 Let's add to the following for a test:

  foreach $state(@states) {
 print option$state;
  }

 foreach $county(@counties) {
print option$county;
 }

 Now the list of states also includes the counties (fetched
 previously based on $stateid).

Hmm. I don't have a panoramic view on your brain and can't
understand this at all.

[snip content]

 
  All of the variables that you've declared ouside any
  subroutines are accessible throughout the rest of the file,
  both within and outside subroutines. You're simply accessing
  the common '@states' variable in 'displayLoginScreen'.
  '@states' and '$states' are totally unrealted: they just
  happen to have the same identifier. The syntax '@$states' is
  an attempt to dereference the value in the '$states' scalar
  as an array. This will fail unless '$states' holds an array
  reference. I don't understand what you mean by more
  persistent or by 'Verify' knows the county stuff only until
  the first validation error. You're passing no references to
  'Verify' so it can only be accessing the common variables
  like '@states'.

 Subroutine 'Verify' processes the fields from
 displayLoginScreen, validates the input and checks the db for
 existing records. (We're actually attempting a new
 registration here.) i.e.:

Once more, we have no idea what 'attempting a new registration'
means. Remember that we cannot see anything of your system and
your application other than what you tell us. We know Perl plus
most popular modules. Period.

 sub Verify {
my $cgi=shift;
$uid=$cgi-param(-name='uid');
if (length($uid)  6) {
   displayLoginScreen($cgi);
}
elsif (nextErrorCondition) {
   displayLoginScreen($cgi);
} else {
   [more stuff]
   if ([more stuff] =OK) {
  displayRegisterScreen($cgi);
   }
}
 }

 Upon the first error condition being true (or true again) and
 subroutine displayLoginScreen being [re]called, my list of
 select options still includes @states but not @counties. Are
 these not global, or is @counties being undefined somehow?

You must tell us what you are seeing within Perl. What appears
on your screen will be several levels down from 'Verify', and
any one of those levels may have a problem. If you have a
problem with a single piece of independent code then we can
start to guess.

   Instead of making subsequent db fetches I want to send(?)
   any/all of these to any/all subsequent (inner?)
   subroutines that may need them. Is this possible and what
   might the referencing/dereferencing look like?
 
  You can either do what you've done above, and simply declare
  common variables at a wider scope so that they're accessible
  everywhere or - more properly - pass references to all of
  the data as as parameters. You'd then have something like
 
displayLoginScreen($CGI, [EMAIL PROTECTED]);
 
sub displayLoginScreen {
  my ($CGI, $states) = @_;
  foreach my $state (@$states) {
:
  }
}
 
   Verify calls other subroutines and then another HTML page.
   That page 

Re: Parsing pipe delimited file

2003-10-21 Thread Rob Dixon
Kevin Old wrote:

 Thanks to everyone who helped with my last problem last week.  I've hit
 a snag in another problem this week.

 I need to parse the following data:

[snip]

groan

I'd like to help Kevin, but please post your data
as an attachment or (even better) as an Internet
link. Line wrapping in the text of your message
is bad enough, but makes binary data strings useless.

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



IO::Filter::gzip question

2003-10-21 Thread Jose Malacara
Can someone tell me how to extract the uncompressed data from the returned value using 
the script below? I try and print the $fio variable, but I get some hash reference. Do 
I need to iterate through this hash and then print the values or am I just going about 
this all wrong? I am trying to just open the gzip file and read the contents. I am 
using this module because I am limed to a box running 5.6.

Thanks in advance.

script:
===
#!/usr/bin/perl
use IO::Filter::gzip;
$io = denver.gz;
$fio = new IO::Filter::gzip ($io, r);
print $fio\n;

ouput:
===
$./test.pl 
IO::Filter::gzip=HASH(0x8132004)


--
Jose Malacara
[EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread Kevin Old
On Tue, 2003-10-21 at 13:54, Rob Dixon wrote:
 Kevin Old wrote:
 
  Thanks to everyone who helped with my last problem last week.  I've hit
  a snag in another problem this week.
 
  I need to parse the following data:
 
 [snip]
 
 groan
 
 I'd like to help Kevin, but please post your data
 as an attachment or (even better) as an Internet
 link. Line wrapping in the text of your message
 is bad enough, but makes binary data strings useless.

Rob,

No problem.didn't know attachments were acceptable againI
remember back a few years ago getting slapped on the wrist cause I
posted attachments..Oh well

Any help appreciated!

Thanks,
Kevin

-- 
Kevin Old [EMAIL PROTECTED]
K|||
|||
|||
||KARAOKE CD'S|
|||CD+G 16 TRACK SELECTIONS
|||
|||
|||
|||
|||
|||
|||
|||
|||
ALL-TIME FAVORITE COUNTRY LOVE SONGS UPC#: 0-84296-33172-7||COUNTRY MALE PARTY 
SONGS VOL. 1 UPC#: 0-84296-21772-4||COUNTRY FEMALE PARTY SONGS VOL. 1 UPC#: 
0-84296-21712-0|||
|||
|||
TRACK|||MADE FAMOUS BY|||TRACK|||MADE FAMOUS BY|||TRACK|||MADE FAMOUS BY
 1. AMAZED|||LONESTAR||| 1. POP A TOP|||ALAN JACKSON||| 1. BREATHE|||FAITH 
HILL
 2. YOU WERE MINE|||DIXIE CHICKS||| 2. LONGNECK BOTTLE|||GARTH BROOKS||| 2. 
YOU'RE STILL THE ONE|||SHANIA TWAIN
 3. I COULD NOT ASK FOR MORE|||SARA EVANS||| 3. AMAZED|||LONESTAR||| 3. THERE'S 
YOUR TROUBLE|||DIXIE CHICKS
 4. YOU LIGHT UP MY LIFE|||LEANN RIMES||| 4. WHEN I SAID I DO|||CLINT 
BLACK||| 4. INDEPENDENCE DAY|||MARTINA McBRIDE
 5. YOUR LOVE AMAZES ME|||MICHAEL ENGLISH||| 5. REFRIED DREAMS|||TIM 
McGRAW||| 5. HOW DO I LIVE|||LEANN RIMES
 6. YOU'RE STILL THE ONE|||SHANIA TWAIN||| 6. I SWEAR|||JOHN MICHAEL 
MONTGOMERY||| 6. XXX's AND OOO's|||TRISHA YEARWOOD
 7. I SWEAR|||JOHN MICHAEL MONTGOMERY||| 7. PROP ME UP BESIDE THE JUKEBOX (IF I 
DIE)|||JOE DIFFIE||| 7. I TRY TO THINK ABOUT ELVIS|||PATTY LOVELESS
 8. CRAZY|||PATSY CLINE||| 8. IF I COULD MAKE A LIVING|||CLAY WALKER||| 8. WE 
DANCED ANYWAY|||DEANA CARTER
 9. WHEN LOVE FINDS YOU|||VINCE GILL||| 9. SHOULD'VE BEEN A COWBOY|||TOBY 
KEITH||| 9. CLOWN IN YOUR RODEO|||KATHY MATTEA
10. BREATHE|||FAITH HILL|||10. ROCK MY WORLD (LITTLE COUNTRY GIRL)|||BROOKS  
DUNN|||10. DOWN TO MY LAST TEARDROP|||TANYA TUCKER
11. BUTTERFLY KISSES|||BOB CARLISLE|||11. TOO COLD AT HOME|||MARK 
CHESNUTT|||11. NO ONE ELSE ON EARTH|||WYNONNA JUDD
12. UNCHAINED MELODY|||LEANN RIMES|||12. BUBBA HYDE|||DIAMOND RIO|||12. HOW 
WAS I TO KNOW|||REBA McENTIRE
13. THE DANCE|||GARTH  BROOKS|||13. KEEPER OF THE STARS|||TRACY BYRD|||13. I 
GUESS YOU HAD TO BE THERE|||LORRIE MORGAN
14. WHEN I SAID I DO|||CLINT BLACK|||14. THE BIG ONE|||GEORGE STRAIT|||14. 
WILD ONE|||FAITH HILL
15. CAN I TRUST YOU WITH MY HEART|||TRAVIS TRITT|||15. THAT'S MY STORY|||COLLIN 
RAYE|||15. YOU WERE MINE|||DIXIE CHICKS
16. WHAT ABOUT NOW|||LONESTAR|||16. T.L.C.A.S.A.P.|||ALABAMA|||16. DON'T BE 
STUPID (YOU KNOW I LOVE YOU)|||SHANIA TWAIN
|||
|||
||| 
COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2||COUNTRY FEMALE PARTY SONGS 
VOL. 2  UPC#:  0-84296-28682-9||COUNTRY MALE PARTY SONGS VOL. 2   UPC#:  
0-84296-28652-2||| ||
TRACK|||MADE FAMOUS BY|||TRACK|||MADE FAMOUS BY|||TRACK|||MADE FAMOUS BY
 1. CRAZY|||PATSY CLINE||| 1. SOME DAYS YOU GOTTA DANCE|||DIXIE CHICKS||| 1. 
THE LONG GOODBYE|||BROOKS  DUNN
 2. ANGELS AMONG US|||ALABAMA||| 2. BLESSED|||MARTINA McBRIDE||| 2. MY 
LIST|||TOBY KEITH
 3. I WILL ALWAYS LOVE YOU|||DOLLY PARTON||| 3. BRING ON THE RAIN|||JO DEE 
MESSINA W/ TIM McGRAW||| 3. THE COWBOY IN ME|||TIM McGRAW
 4. ON THE ROAD AGAIN|||WILLIE NELSON||| 4. CAN'T FIGHT THE MOONLIGHT|||LEANN 
RIMES||| 4. I BREATHE IN, I BREATHE OUT|||CHRIS CAGLE
 5. STAND BY YOUR MAN|||TAMMY WYNETTE||| 5. I'LL FLY AWAY|||ALISON KRAUSS W/ 
GILLIAN WELCH||| 5. YOUNG|||KENNY CHESNEY
 6. FOREVER AND EVER AMEN|||RANDY TRAVIS||| 6. I HOPE YOU DANCE|||LEE ANN 
WOMACK||| 6. GOOD MORNING BEAUTIFUL|||STEVE HOLY
 7. SMALL TOWN GIRL|||STEVE WARINER||| 7. I KEEP LOOKING|||SARA EVANS||| 7. 
WRAPPED AROUND|||BRAD PAISLEY
 8. GRANDPA|||THE JUDDS||| 8. WHEN YOU LIE NEXT TO ME|||KELLIE COFFEY||| 8. 
THAT'S WHEN I LOVE YOU|||PHIL VASSAR
 9. BORN TO BOOGIE|||HANK WILLIAMS, JR.||| 9. DOWNTIME|||JO DEE MESSINA||| 9. 
WHAT IF SHE'S AN ANGEL|||TOMMY SHANE STEINER
10. YOU NEEDED ME|||ANNE MURRAY|||10. MAYBE, MAYBE NOT|||MINDY McCREADY|||10. 
MODERN DAY BONNIE  CLYDE|||TRAVIS TRITT
11. THE GAMBLER|||KENNY ROGERS|||11. INSIDE OUT|||TRISHA YEARWOOD|||11. IN 
ANOTHER WORLD|||JOE DIFFIE
12. I FALL TO PIECES|||PATSY CLINE|||12. THERE YOU'LL BE|||FAITH HILL|||12. I 
AM A MAN OF CONSTANT SORROW|||SOGGY BOTTOM BOYS
13. SNAP YOUR FINGERS|||RONNIE MILSAP|||13. I DON'T WANT YOU TO GO|||CAROLYN 
DAWN JOHNSON|||13. WRAPPED UP IN YOU|||GARTH BROOKS
14. TWO MORE BOTTLES OF WINE|||EMMYLOU 

Re: File sorting by a specific date

2003-10-21 Thread Kevin Pfeiffer
Hi,

In article [EMAIL PROTECTED],
Paul Harwood purportedly wrote:

  This isn't working for some reason. The $date scalar seems unchanged
  throughout.
 
 Paul Harwood wrote:

 I want to search a directory of log files and populate a list of those
 log files ONLY if they match today's date (localtime).

 $logs = 'c:\logs\W3SVC1';
 opendir LOGS, $logs or die Can't open directory:  $!\n;
 my @files = grep /\.TXT$/, readdir LOGS;

 #Right here, I am wondering if there is a simple way of populating @files
 by using a date comparison operation of each file to the local time. I've
 tried long complicated methods of using 'stat' and Time::Local but I was
 hoping for a simpler solution.
 
 Ah, a simple solution.  :-)
[...]

Please quote accurately if you are going to include (what should be) quoted
material.

-K

-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: call one perl script within another

2003-10-21 Thread Andrew Shitov
my $return_value = eval {$code_or_sub_programme};

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Parsing pipe delimited file

2003-10-21 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Rob Dixon wrote:

 Kevin Old wrote:

 Thanks to everyone who helped with my last problem last week.  I've hit
 a snag in another problem this week.

 I need to parse the following data:
 
 [snip]
 
 groan
 
 I'd like to help Kevin, but please post your data
 as an attachment or (even better) as an Internet
 link. Line wrapping in the text of your message
 is bad enough, but makes binary data strings useless.

Seconding the plea. I like the these sort of challenges, but not the
challenge of unwrapping, counting commas, pipes and quote marks, etc.

I don't know if it's the best solution (perhaps an attachment is better),
but I will usually send code unwrapped (during the rare moments when I have
something to offer) and then hard-warp the 'splanatory' text.

(the/another Kevin)
-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: alias in the shell

2003-10-21 Thread LoBue, Mark
Someone is missing the point, I'm not sure who yet.

 -Original Message-
 From: Steve Grazzini [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 17, 2003 10:10 PM
 To: Smoot Carl-Mitchell
 Cc: [EMAIL PROTECTED]
 Subject: Re: alias in the shell
 
 
 On Fri, Oct 17, 2003 at 04:05:10PM -0700, Smoot Carl-Mitchell wrote:
  Steve Grazzini [EMAIL PROTECTED] wrote:
  
   Have you actually tried . perlscript ?  :-)
  
  This will not work.
 
 Yes, anyone who tries it will realize this immediately. :-)

Well, I guessed wrong, but I use exec in place of the dot, and it works
fine.

 
  system(ENVVAR=whatever; export ENVVAR; command);
 

This doesn't address the problem, environment variables can be handled
native, but alias assignments can not.  Also, you can't export aliases.
However, system forks a child, so the export only affects the child, this
doesn't get back to the parent.  I think the problem was changed to make the
answer easy.

The other suggestion of returning the alias as:

$aliascmd = `aliasProg.pl`;

Still doesn't address the problem.  So now you know the alias command to
run, but, how do you run it, maybe:

system($aliascmd);

No, that won't work, because the alias command is running in a forked child.
I still think you need to:

exec(aliasProg.pl);

Then, at the end of aliasProg.pl, exec($shell);

The $shell variable doesn't have to be hardcoded, it can be read from the
environment (at least on my system).

-Mark

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Sed command in Perl

2003-10-21 Thread Raghu Murthy
How do I include a sed command in perl.

If i do sed -es\./  file_name it works fine at the command prompt. But 
if i include the sed command in perl it does not return any value.

I tried doing system(sed -es\./.. file_name); it does not do anything. 
Is there something wrong in how i have done it in perl.

_
Want to check if your PC is virus-infected?  Get a FREE computer virus scan 
online from McAfee.
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: alias in the shell

2003-10-21 Thread Steve Grazzini
On Tue, Oct 21, 2003 at 11:35:15AM -0700, LoBue, Mark wrote:
 Someone is missing the point, I'm not sure who yet.

I'll admit to going on a tangent... :-)  The original topic was how
to create a shell alias from Perl.

 No, that won't work, because the alias command is running in a forked child.
 I still think you need to:
 
 exec(aliasProg.pl);
 
 Then, at the end of aliasProg.pl, exec($shell);

I don't know what else you were planning to do in aliasProg.pl, but
the *only* way to create a shell alias is to have the shell interpret
a line that looks like alias this=that.

Since the list of aliases is the shell's internal data, you can't expect
it to survive across an exec()...

Now: the easiest way to create a shell alias from Perl is

#
# in the shell
#
eval `script.pl`

#
# in Perl
#
print alias this=that;

Or you could arrange for Perl to write a little shell script and for
the shell to source that script.  But as I'm sure someone has already
suggested, the thing to do is write everything in 100% Pure Perl(tm).

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Trivial 'unless' Question

2003-10-21 Thread Jeff Westman
Hi . very trivial ... is there a way or correct syntax to add an 'if' tp
the following 'unless' statement?

# this works fine ...
print first\n unless ($counter);
# ... but can I do something like
print first\n unless ($counter) else { print second\n;
# (syntax error)

I know I can do this:

#!/usr/bin/perl
use warnings;
use strict;
my $counter = 0;

unless ($counter) {
print first\n;
} else {
print second\n;
}

 but I wanted to put the 'unless' later in the statement.  I couldn't
find anything in the FAQ or perldoc on this one.

TIA!

-JW




__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Sed command in Perl

2003-10-21 Thread Steve Grazzini
On Tue, Oct 21, 2003 at 02:45:50PM -0400, Raghu Murthy wrote:
 How do I include a sed command in perl.
 
 If i do sed -es\./  file_name it works fine at the command prompt. 
 But if i include the sed command in perl it does not return any value.
 
 I tried doing system(sed -es\./.. file_name); it does not do anything. 
 Is there something wrong in how i have done it in perl.

Yep. :-)

Check this FAQ

% perldoc -q output of a command
Why can't I get the output of a command with system()?

You're confusing the purpose of system() and backticks (``).
...

And the manual for system

% perldoc -f system
...
This is *not* what you want to use to capture the output
from a command, for that you should use merely backticks or
qx//, as described in `STRING` in perlop.

So for your example, you'd need something like

my $output = qx{ sed s/foo/bar/ filename };

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trivial 'unless' Question

2003-10-21 Thread Steve Grazzini
On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote:
 # ... but can I do something like
 print first\n unless ($counter) else { print second\n;

Not really.  You could use the conditional operator, though.

  print $counter ? second\n : first\n;

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: alias in the shell

2003-10-21 Thread LoBue, Mark
 -Original Message-
 From: Steve Grazzini [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, October 21, 2003 11:43 AM
 To: LoBue, Mark
 Cc: [EMAIL PROTECTED]
 Subject: Re: alias in the shell
 
 
 On Tue, Oct 21, 2003 at 11:35:15AM -0700, LoBue, Mark wrote:
  Someone is missing the point, I'm not sure who yet.
 
 I'll admit to going on a tangent... :-)  The original topic was how
 to create a shell alias from Perl.
 
Yep, it was me, I got turned around.  I write so few shell scripts anymore..

-Mark

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trivial 'unless' Question

2003-10-21 Thread Jeff Westman
Steve Grazzini [EMAIL PROTECTED] wrote:

 On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote:
  # ... but can I do something like
  print first\n unless ($counter) else { print second\n;
 
 Not really.  You could use the conditional operator, though.
 
   print $counter ? second\n : first\n;

True, but I was looking for a way to do this with a somewhat buried unless
keyword.

TA

-JW

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trivial 'unless' Question

2003-10-21 Thread Steve Grazzini
On Tue, Oct 21, 2003 at 01:06:44PM -0700, Jeff Westman wrote:
 Steve Grazzini [EMAIL PROTECTED] wrote:
  On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote:
   # ... but can I do something like
   print first\n unless ($counter) else { print second\n;
  
  Not really.  You could use the conditional operator, though.
  
print $counter ? second\n : first\n;
 
 True, but I was looking for a way to do this with a somewhat buried
 unless keyword.

  print +( qw(second first -- unless --) )[ not $counter ];

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Kevin Old wrote:
[...]
 I need to parse the following data:
 
 COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2||COUNTRY FEMALE
 PARTY SONGS VOL. 2  UPC#:  0-84296-28682-9||COUNTRY MALE PARTY
 SONGS VOL. 2   UPC#:  0-84296-28652-2||| ||
[...]

I'm working on this myself and am wondering if -- er, what the better way is
to split the header line into 3 pieces.

# get header
if (/^[^|]/ and [EMAIL PROTECTED]) {
@header = split(/?[|]+?/, $_, 5);
pop @header; shift @header;
}

Data (see below) looks something like:
Piece One||Piece Two||Piece Three|||

I'm splitting as you see, but into 5 pieces in order to get rid of quote marks 
and all pipes; then I have to throw out the first and last item.

-K

__DATA__
ALL-TIME FAVORITE COUNTRY LOVE SONGS UPC#: 0-84296-33172-7||COUNTRY MALE PARTY 
SONGS VOL. 1 UPC#: 0-84296-21772-4||COUNTRY FEMALE PARTY SONGS VOL. 1 UPC#: 
0-84296-21712-0|||

-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread Katy Brownfield
Exactly what structure you want to end up with isn't clear, but I assume 
you that you need to keep the tracks and artists associated with their 
UPCs. If there were only one upc and one track/artist per line, grouped by 
upc, it would be easier. The position of the track/artist on each line is 
what tells you which UPC it is for, but you're losing the position of the 
UPC when you parse that line.

Katy

On 21 Oct 2003 12:43:45 -0400, Kevin Old [EMAIL PROTECTED] wrote:

Hello everyone,

Thanks to everyone who helped with my last problem last week.  I've hit
a snag in another problem this week.
I need to parse the following data:

COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2||COUNTRY FEMALE
PARTY SONGS VOL. 2  UPC#:  0-84296-28682-9||COUNTRY MALE PARTY
SONGS VOL. 2   UPC#:  0-84296-28652-2
()
 1. CRAZY|||PATSY CLINE||| 1. SOME DAYS YOU GOTTA DANCE|||DIXIE
CHICKS||| 1. THE LONG GOODBYE|||BROOKS  DUNN
 2. ANGELS AMONG US|||ALABAMA||| 2. BLESSED|||MARTINA McBRIDE|||
2. MY LIST|||TOBY KEITH
()
Now, let me explain the data.  There are 3 albums here.  The titles and
UPC's are in the first line.  I have a loop that separates the title and
the piece of the UPC that I need and puts it into a hash.
my %titles = ();
while(KB) {
my @songs;
my @artist;
my @line = split/\|/,$_;
foreach ($line[0], $line[6], $line[12]) {
if($_
$_ =~ s///g;
$_ =~ /^(.*?)\s+UPC#:\s+0-84296-(\d+)-\d/g;
my $title = $1;
my $upc = $2;
$titles{$upc}{title} = $title;
}
}

Then the rest of the lines are Tracks and Artists.  What I need to
do is get the appropriate tracks and artists in respective (@tracks,
@artists) arrays inside the hash.
Basically, I need to know how to write code that does this:

Get the 3 albums to be processed, put title in hash with UPC as key
(done with code above)
Parse next 16 lines (3 tracks and artists on each line) and associate
them with the proper song  artist arrays in the hash.
I know this is rather confusing, but any help is appreciated!

Kevin





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Trivial 'unless' Question

2003-10-21 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Steve Grazzini wrote:

 On Tue, Oct 21, 2003 at 01:06:44PM -0700, Jeff Westman wrote:
 Steve Grazzini [EMAIL PROTECTED] wrote:
  On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote:
   # ... but can I do something like
   print first\n unless ($counter) else { print second\n;
  
  Not really.  You could use the conditional operator, though.
  
print $counter ? second\n : first\n;
 
 True, but I was looking for a way to do this with a somewhat buried
 unless keyword.
 
   print +( qw(second first -- unless --) )[ not $counter ];

???   :-|


-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread Kevin Old
On Tue, 2003-10-21 at 16:49, Kevin Pfeiffer wrote:
 In article [EMAIL PROTECTED], Kevin Old wrote:
 [...]
  I need to parse the following data:
  
  COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2||COUNTRY FEMALE
  PARTY SONGS VOL. 2  UPC#:  0-84296-28682-9||COUNTRY MALE PARTY
  SONGS VOL. 2   UPC#:  0-84296-28652-2||| ||
 [...]
 
 I'm working on this myself and am wondering if -- er, what the better way is
 to split the header line into 3 pieces.
 
 # get header
 if (/^[^|]/ and [EMAIL PROTECTED]) {
 @header = split(/?[|]+?/, $_, 5);
 pop @header; shift @header;
 }
 
 Data (see below) looks something like:
 Piece One||Piece Two||Piece Three|||
 
 I'm splitting as you see, but into 5 pieces in order to get rid of quote marks 
 and all pipes; then I have to throw out the first and last item.
 
 -K
 
 __DATA__
 ALL-TIME FAVORITE COUNTRY LOVE SONGS UPC#: 0-84296-33172-7||COUNTRY MALE 
 PARTY SONGS VOL. 1 UPC#: 0-84296-21772-4||COUNTRY FEMALE PARTY SONGS VOL. 1 
 UPC#: 0-84296-21712-0|||

Here's what I've got so far on this issue:

while(KB) {
chomp;
while(/^(.*?)\s+UPC#:\s+0-84296-(\d+)-\d/g) {
print Title: $1 UPC: $2\n;
}
}

* OUTPUT (for entire file) *
Title: ALL-TIME FAVORITE COUNTRY LOVE SONGS UPC: 33172
Title: COUNTRY MUSIC HALL OF FAME UPC: 22922
Title: GREAT COUNTRY LOVE SONGS VOL. 2 UPC: 30662
Title: POP/RB FEMALE PARTY SONGS UPC: 3
Title: CRAZY PARTY SONGS VOL. 1 UPC: 30582
Title: CLASSIC HITS FROM THE MOVIES UPC: 33162
Title: AMERICAN GRAFFITI 50'S UPC: 22972
Title: THOSE 70'S HITS UPC: 30982
Title: ROCK  ROLL PARTY SONGS UPC: 30432
Title: PURE FUNK UPC: 22962
Title: DUET HITS UPC: 30752
Title: STORMY MONDAY BLUES UPC: 30702
Title: CHICKS RULE THE CHARTS UPC: 30652

Now, just getting the tracks associated with them is the next step.

I'll let you know as I come up with more

Kevin
-- 
Kevin Old [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: IO::Filter::gzip question

2003-10-21 Thread Wiggins d Anconia
 Can someone tell me how to extract the uncompressed data from the
returned value using the script below? I try and print the $fio
variable, but I get some hash reference. Do I need to iterate through
this hash and then print the values or am I just going about this all
wrong? I am trying to just open the gzip file and read the contents. I
am using this module because I am limed to a box running 5.6.
 
 Thanks in advance.
 
 script:
 ===
 #!/usr/bin/perl
 use IO::Filter::gzip;
 $io = denver.gz;
 $fio = new IO::Filter::gzip ($io, r);
 print $fio\n;
 
 ouput:
 ===
 $./test.pl 
 IO::Filter::gzip=HASH(0x8132004)
 

First I will suggest you should use Compress::Zlib which should be
available for just about any Perl version, and certainly works in 5.6.x.

Having said that, it isn't really what you asked, so I would suggest
taking a look at the base IO::Filter module's documentation, as it
appears that IO::Filter::gzip inherits most of its good stuff from
that, it can be found here:

http://search.cpan.org/~rwmj/IO-Filter-0.01/lib/IO/Filter.pm

Also be warned that you have to have 'gzip' installed and in your path
for it to work (which if you do presumably the zlibs are available, and
you should go back to using Compress::Zlib)...

Assuming we are still here, then what you are getting in your $fio is a
blessed reference, aka an IO::Filter object, that you can then apply a
method tu, tu get your data... However what you pass to the constructor
also needs to be an opened file handle rather than the path to a file to
open, and you need to call the proper directional constructor, aka you
want to unzip rather than zip, so you end up with something like:

-- UNTESTED --

#!/usr/bin/perl
use strict;# always
use warnings;  # usually

use IO::Filter::gunzip;

my $zipped_file = denver.gz;
my $READHANDLE;
open($READHANDLE, $zipped_file) or die Can't open handle on zipped
file: $!;  # you may want to set the binmode on this guy

my $fio = new IO::Filter::gunzip ($READHANDLE, r);
$fio-print;
$fio-close;  # or close($READHANDLE);

But seriously, let us know why Compress::Zlib won't work

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Trivial 'unless' Question

2003-10-21 Thread Perry, Alan
On Tuesday, October 21, 2003 16:01, Kevin Pfeiffer wrote:

In article [EMAIL PROTECTED], Steve Grazzini wrote:

 On Tue, Oct 21, 2003 at 01:06:44PM -0700, Jeff Westman wrote:
 Steve Grazzini [EMAIL PROTECTED] wrote:
  On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote:
   # ... but can I do something like
   print first\n unless ($counter) else { print second\n;
  
  Not really.  You could use the conditional operator, though.
  
print $counter ? second\n : first\n;
 
 True, but I was looking for a way to do this with a somewhat buried
 unless keyword.
 
   print +( qw(second first -- unless --) )[ not $counter ];

???   :-|


I think the author was trying to be cute...  I got a chuckle out of it!

print +( qw(second first -- unless --) )[ not $counter ];

Basically, you are creating an anonymous (right term?) array, and printing
the not $counter'th element.  So if $counter is 0, you print first,
otherwise you print second.  The other stuff in the array is there just to
satisfy the buried unless requested by the OP.  However, as you see here,
it does not use the keyword unless, just a string unless.  The only
elements that will ever be accessed are second and first...

It could also be written as:

print +( qw(second first) )[ not $counter ];

HTH
Alan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Kevin Old wrote:
[...] 
 Then the rest of the lines are Tracks and Artists.  What I need to
 do is get the appropriate tracks and artists in respective (@tracks,
 @artists) arrays inside the hash.
 
 Basically, I need to know how to write code that does this:
 
 Get the 3 albums to be processed, put title in hash with UPC as key
 (done with code above)
 
 Parse next 16 lines (3 tracks and artists on each line) and associate
 them with the proper song  artist arrays in the hash.
 
This is what I have so far (using slightly different variable names).
I still need to strip out the first line (MADE FAMOUS BY and TRACK)
and remove quote marks, but is the format you want? 

The thing to add (I'd have to check the Perl Cookbook for the terminology) 
is a reverse lookup(?) so that in addition to:

$album{$upc} 

you could also access your data via:

$album{$album_name}

(I think -- trying to remember this from what I've read)...

$VAR1 = {
  '0-84296-21712-0' = {
 'artists' = [
'MADE FAMOUS BY',
'BROOKS  DUNN',
'TOBY KEITH',
'TIM McGRAW',
'CHRIS CAGLE',
'KENNY CHESNEY',
'STEVE HOLY',
'BRAD PAISLEY',
'PHIL VASSAR',
'TOMMY SHANE STEINER',
'TRAVIS TRITT',
'JOE DIFFIE',
'SOGGY BOTTOM BOYS',
'GARTH BROOKS',
'LONESTAR',
'EMERSON DRIVE',
'TOBY KEITH'
  ],
 'tracks' = [
   'TRACK',
   ' 1. THE LONG GOODBYE',
   ' 2. MY LIST',
   ' 3. THE COWBOY IN ME',
   ' 4. I BREATHE IN...',
   ' 5. YOUNG',
   ' 6. GOOD MORNING BEAUTIFUL',
   ' 7. WRAPPED AROUND',
   ' 8. THAT\'S WHEN I LOVE YOU',
   ' 9. WHAT IF SHE\'S AN ANGEL',
   '10. MODERN DAY BONNIE  CLYDE',
   '11. IN ANOTHER WORLD',
   '12. I AM A MAN OF CONSTANT SORROW',
   '13. WRAPPED UP IN YOU',
   '14. NOT A DAY GOES BY',
   '15. I SHOULD BE SLEEPING',
   '16. I WANNA TALK ABOUT ME'
 ],
 'name' = 'COUNTRY FEMALE PARTY SONGS VOL. 1'
   },
  '0-84296-33172-7' = {
 'artists' = [
'MADE FAMOUS BY',
'PATSY CLINE',
'ALABAMA',
'DOLLY PARTON',
ETC




-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Kevin Pfeiffer wrote:
[...]
 The thing to add (I'd have to check the Perl Cookbook for the terminology)
 is a reverse lookup(?) so that in addition to:
 
 $album{$upc}
 
 you could also access your data via:
 
 $album{$album_name}
 
 (I think -- trying to remember this from what I've read)...

Just looked -- page 382 talks about constructing useful record data types
using references. So that you could also have (something like): 
$byAlbumName{Country Male...}-{track}[1] eq Some Days Ya Gotta Dance

Sorry if this is all old news -- it's still new to me. 

-K
-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



how to extract data in specified format to another file

2003-10-21 Thread Mythili, Chandrasekaran (C.)
HI,

I am new to Perl and I need some help regarding tranfering the contents of
one file to other file in specified format using perl.

the problem is i have one file with data(data is in hex) as follows:
48
30
20
2E
2E
2E
0
0
0

i want to copy the contents of this file to another file till 0 is
encountered.that is i want the resultant file to have

4830202E2E2E

what command should i use get all the data in the same line?

any help ASAP is appreciated

Thanks.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tokens??

2003-10-21 Thread R. Joseph Newton
PerlDiscuss - Perl Newsgroups and mailing lists wrote:

 HI,

 I am brand new to Perl and I am trying to modify a script that someone
 else wrote.

Please don't.  That is not the way to learn Perl.  Learn Perl first, get very
confortable with it, starting with the basics, then try to adapt existing
scripts.  Program maintenance is one of the most difficult tasks in
programming, so it is not a good place to make your entry.

 I have this line where primaryntaccount = something like this
 domainname\userid

 Token=primaryntaccount:: %ntaccount% = (\\w+).*$

This is not Perl. AFAIK.  Without context, it is pretty hard to tell,
though.  If it is Perl code, then it is very non-standard.



 I want to pass a different value for primaryntaccount which I am getting
 by the following line.

 where $UPN = [EMAIL PROTECTED]

 @array = split/([EMAIL PROTECTED])/, $UPN;
 $UPN2 = @array[0];
 Token=$UPN2:: %ntaccount% = (\\w+).*$;

 Like I said I am totally new to perl and I don't even really understand
 how the token line really works.  The best I can ascertain is that it is
 passing something back up to DRA.  What is DRA?

 What does this bit do is this simply formatting the data or is it parsing
 the variable (\\w+).*$ ?

 Any help is appreciated.

Can you post the script as a whole?

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: javascript Parsing

2003-10-21 Thread R. Joseph Newton
Francesco del Vecchio wrote:

 Hi to all,

 I need to parse javascript into web pages to substitute all relative addresses to 
 absolute ones.

Why?  Are you in a masochistic frame of mind?



 I do this job in the HTML using LWP but I'm having bad times trying to do it into 
 javascript
 contained in the page.

 Can anyone help me?

Can you show us the material you are working with, and identify the problems you have 
encountered?

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Parsing pipe delimited file

2003-10-21 Thread R. Joseph Newton
Kevin Old wrote:

 Hello everyone,

 Thanks to everyone who helped with my last problem last week.  I've hit
 a snag in another problem this week.

 I need to parse the following data:

 COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2||COUNTRY FEMALE
 PARTY SONGS VOL. 2  UPC#:  0-84296-28682-9||COUNTRY MALE PARTY
 SONGS VOL. 2   UPC#:  0-84296-28652-2||| ||
 |||
 |||
 TRACK|||MADE FAMOUS BY|||TRACK|||MADE FAMOUS BY|||TRACK|||MADE
 FAMOUS BY
  1. CRAZY|||PATSY CLINE||| 1. SOME DAYS YOU GOTTA DANCE|||DIXIE
 CHICKS||| 1. THE LONG GOODBYE|||BROOKS  DUNN
  2. ANGELS AMONG US|||ALABAMA||| 2. BLESSED|||MARTINA McBRIDE|||
 2. MY LIST|||TOBY KEITH
  3. I WILL ALWAYS LOVE YOU|||DOLLY PARTON||| 3. BRING ON THE
 RAIN|||JO DEE MESSINA W/ TIM McGRAW||| 3. THE COWBOY IN ME|||TIM
 McGRAW
  4. ON THE ROAD AGAIN|||WILLIE NELSON||| 4. CAN'T FIGHT THE
 MOONLIGHT|||LEANN RIMES||| 4. I BREATHE IN, I BREATHE OUT|||CHRIS
 CAGLE
  5. STAND BY YOUR MAN|||TAMMY WYNETTE||| 5. I'LL FLY
 AWAY|||ALISON KRAUSS W/ GILLIAN WELCH||| 5. YOUNG|||KENNY CHESNEY
  6. FOREVER AND EVER AMEN|||RANDY TRAVIS||| 6. I HOPE YOU
 DANCE|||LEE ANN WOMACK||| 6. GOOD MORNING BEAUTIFUL|||STEVE HOLY
  7. SMALL TOWN GIRL|||STEVE WARINER||| 7. I KEEP LOOKING|||SARA
 EVANS||| 7. WRAPPED AROUND|||BRAD PAISLEY
  8. GRANDPA|||THE JUDDS||| 8. WHEN YOU LIE NEXT TO ME|||KELLIE
 COFFEY||| 8. THAT'S WHEN I LOVE YOU|||PHIL VASSAR
  9. BORN TO BOOGIE|||HANK WILLIAMS, JR.||| 9. DOWNTIME|||JO DEE
 MESSINA||| 9. WHAT IF SHE'S AN ANGEL|||TOMMY SHANE STEINER
 10. YOU NEEDED ME|||ANNE MURRAY|||10. MAYBE, MAYBE NOT|||MINDY
 McCREADY|||10. MODERN DAY BONNIE  CLYDE|||TRAVIS TRITT
 11. THE GAMBLER|||KENNY ROGERS|||11. INSIDE OUT|||TRISHA
 YEARWOOD|||11. IN ANOTHER WORLD|||JOE DIFFIE
 12. I FALL TO PIECES|||PATSY CLINE|||12. THERE YOU'LL BE|||FAITH
 HILL|||12. I AM A MAN OF CONSTANT SORROW|||SOGGY BOTTOM BOYS
 13. SNAP YOUR FINGERS|||RONNIE MILSAP|||13. I DON'T WANT YOU TO
 GO|||CAROLYN DAWN JOHNSON|||13. WRAPPED UP IN YOU|||GARTH BROOKS
 14. TWO MORE BOTTLES OF WINE|||EMMYLOU HARRIS|||14. I NEED
 YOU|||LEANN RIMES|||14. NOT A DAY GOES BY|||LONESTAR
 15. OCEAN FRONT PROPERTY|||GEORGE STRAIT|||15. WHAT I REALLY MEANT
 TO SAY|||CYNDI THOMSON|||15. I SHOULD BE SLEEPING|||EMERSON DRIVE
 16. SOME KIND OF TROUBLE|||TANYA TUCKER|||16. THAT'S THE WAY|||JO
 DEE MESSINA|||16. I WANNA TALK ABOUT ME|||TOBY KEITH

 Now, let me explain the data.  There are 3 albums here.  The titles and
 UPC's are in the first line.  I have a loop that separates the title and
 the piece of the UPC that I need and puts it into a hash.

 my %titles = ();
 while(KB) {

 my @songs;
 my @artist;
 my @line = split/\|/,$_;
 foreach ($line[0], $line[6], $line[12]) {

Are your lines really all uniform?  It certainly doesn't look that way in
the file you attach farther down the thread.  I'd say the outer while loop
is alright, since it just keeps you moving through the file, but it seems
pretty clear That there is a mutlilevel organization here.



 if($_
 $_ =~ s///g;
 $_ =~ /^(.*?)\s+UPC#:\s+0-84296-(\d+)-\d/g;
 my $title = $1;
 my $upc = $2;
 $titles{$upc}{title} = $title;
 }

 }

 Then the rest of the lines are Tracks and Artists.  What I need to
 do is get the appropriate tracks and artists in respective (@tracks,
 @artists) arrays inside the hash.

 Basically, I need to know how to write code that does this:

 Get the 3 albums to be processed, put title in hash with UPC as key
 (done with code above)

 Parse next 16 lines (3 tracks and artists on each line) and associate
 them with the proper song  artist arrays in the hash.

 I know this is rather confusing, but any help is appreciated!

 Kevin

 --
 Kevin Old [EMAIL PROTECTED]

I'd probably do something like:
my $albums = {};
my $line - KB;
while ($line) {
   my $title;
   ($title, $line) = process_album_title($line);
   $line = get_album_cuts($line, $title, $albums);
}

You are working with a profoundly nasty data format here, but that probably
can't be helped.  It does seem to have a cyclic regularity, but not on a
line-by-line basis.  Therefore, your looping shouldn't be based on lines.
That sort of looping is for data in much more regular formats.

Joseph




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how to extract data in specified format to another file

2003-10-21 Thread Kevin Pfeiffer
In article
[EMAIL PROTECTED],
Chandrasekaran Mythili wrote:

 HI,
 
 I am new to Perl and I need some help regarding tranfering the contents of
 one file to other file in specified format using perl.
 
 the problem is i have one file with data(data is in hex) as follows:
 48
 30
 20
 2E
 2E
 2E
 0
 0
 0
 
 i want to copy the contents of this file to another file till 0 is
 encountered.that is i want the resultant file to have
 
 4830202E2E2E
 
 what command should i use get all the data in the same line?

There is probably some subtlety of handling hexadecimal (just learned how to
add and subtract it yesterday) that I'm overlooking, but on the surface,
how about something as simple as:

while (DATA) {

chomp;
print;
last if /^0$/;
}

print \n;


-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how to extract data in specified format to another file

2003-10-21 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Kevin Pfeiffer wrote:
[...] 
 while (DATA) {
 
 chomp;
 print;
 last if /^0$/;
 }
 
 print \n;

Whoops, too fast for my own good (points off for carelessness):

while (DATA) {
chomp;
print unless /^0$/;
}

print \n;

__END__

But what I'm not sure about (being more cautious now) - could there be '0's
in the valid data? Or are they represented as '00' in hex? (Think so, but
have to look)


-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]