LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-04-2010, 05:17 AM   #1
smc2
LQ Newbie
 
Registered: Apr 2010
Posts: 29

Rep: Reputation: 0
Push All Special Varible Before Calling a Fucnction


Hi...

I have a code like this:
Code:
open (INPUT,"<file"){

while (<INPUT>){
. . . }
if ($_=~/(?:(Error|exception))/){ $error=$1; save_error($error); } if ($_=~ /somthinelse/) {
. . .
sub save_error($error){ open(ERRINP,">Err.txt") #open another file and save the error to that file print ERRINP $error close ERRINP; open(ERRINP,"<Err.txt") # open the error log file whlie (<ERRINP>){ # for checking some other condition in error file if $_=~/..../ { do_some_thing } pro
. .
}
opening another file while we have an open file will replace $_ and this cause problem for the second if becuase now $_ has been changed,

is there any way that I can push $_ and other file pointers and pop them after calling a function?


Thanks in advance..

Last edited by smc2; 11-04-2010 at 05:24 AM.
 
Old 11-05-2010, 02:29 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

It looks like you're writing in Perl.

Perl arrays can be used as stacks; you can "push" and "pop" anything you want, to your heart's content:

http://www.ebb.org/PickingUpPerl/pickingUpPerl_4.html

'Hope that helps!
 
  


Reply

Tags
perlscript


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
command result as varible mkiler Programming 1 03-10-2009 10:22 AM
Setting global varible Corrado Linux - Software 3 03-05-2007 02:24 PM
redirect stdout to a varible Furlinastis Programming 3 12-07-2005 06:01 AM
how to export a varible in the kernel firefoxii Programming 0 06-08-2004 04:06 AM
command output to varible!!! fooforon Programming 3 02-05-2004 08:41 PM


All times are GMT -5. The time now is 01:06 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration