Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How can I see the expanded file after all the require files are loaded

Reply
Thread Tools

How can I see the expanded file after all the require files are loaded

 
 
Ray Muforosky
Guest
Posts: n/a
 
      05-26-2006
Hello everyone, I'm lost.

How I do see or save the content of fileA after it has loaded all the
required files.


fileA
-----
#!perl
a="help"
require file1
require file2

How do I see or save the expanded fileA?

Thanks for all your help

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      05-26-2006
Ray Muforosky <(E-Mail Removed)> wrote:

> How I do see or save the content of fileA after it has loaded all the
> required files.



Why do you want to see or save the content of fileA after it has
loaded all the required files?

That is, what do you hope to gain by doing that?


> fileA
> -----
> #!perl
> a="help"
> require file1
> require file2



That is not Perl.

This is the Perl newsgroup.

Did you have any Perl code that you wanted to include?


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      05-26-2006
"Ray Muforosky" <(E-Mail Removed)> wrote:
> Hello everyone, I'm lost.
>
> How I do see or save the content of fileA after it has loaded all the
> required files.


There is nothing to see.

>
> fileA
> -----
> #!perl
> a="help"
> require file1
> require file2
>
> How do I see or save the expanded fileA?


There is no "expanded fileA". "require" is not a macro or preprocessor.

Xho



subspace/perl_misc> perl -MO=Deparse,-p
require Data::Table;
__END__
produces this output:

require Data::Table;
__DATA__

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
Ray Muforosky
Guest
Posts: n/a
 
      06-01-2006

Tad McClellan wrote:
> Ray Muforosky <(E-Mail Removed)> wrote:
>
> > How I do see or save the content of fileA after it has loaded all the
> > required files.

>
>
> Why do you want to see or save the content of fileA after it has
> loaded all the required files?
>
> That is, what do you hope to gain by doing that?
>
>
> > fileA
> > -----
> > #!perl
> > a="help"
> > require file1
> > require file2

>
>
> That is not Perl.
>
> This is the Perl newsgroup.
>
> Did you have any Perl code that you wanted to include?
>
>
> --
> Tad McClellan SGML consulting
> (E-Mail Removed) Perl programming
> Fort Worth, Texas



example:
file1:
===
#!/usr/local/bin/perl
$a =12;
require file2;
$b = $z;
require file3;
$c = $y;
print $a;


file2:
====
$z = 200;
1;


file3
===
$y = "foo";
1;


So, is it possible to save file1 after requiring file2 and file3
file1 becomes:

#!/usr/local/bin/perl
$a =12;
$z = 200;
$b = $z;
$y = "foo";
$c = $y;
print $a;

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      06-01-2006
Ray Muforosky wrote:
> Tad McClellan wrote:
> > Ray Muforosky <(E-Mail Removed)> wrote:
> >
> > > How I do see or save the content of fileA after it has loaded all the
> > > required files.

> >
> >
> > Why do you want to see or save the content of fileA after it has
> > loaded all the required files?
> >
> > That is, what do you hope to gain by doing that?
> >
> >
> > > fileA
> > > -----
> > > #!perl
> > > a="help"
> > > require file1
> > > require file2

> >
> >
> > That is not Perl.
> >
> > This is the Perl newsgroup.
> >
> > Did you have any Perl code that you wanted to include?

> example:
> file1:
> ===
> #!/usr/local/bin/perl
> $a =12;
> require file2;
> $b = $z;
> require file3;
> $c = $y;
> print $a;
>
>
> file2:
> ====
> $z = 200;
> 1;
>
>
> file3
> ===
> $y = "foo";
> 1;
>
>
> So, is it possible to save file1 after requiring file2 and file3
> file1 becomes:
>
> #!/usr/local/bin/perl
> $a =12;
> $z = 200;
> $b = $z;
> $y = "foo";
> $c = $y;
> print $a;


What makes you think that file1 "becomes" that? file1 is not changed
by anything you've demonstrated. The code from file2 and file3 is
included in the execution of file1, but the source itself is not
changed at all.

It's time for you to tell us what you're actually *trying* to do,
rather than simply telling us what you've already decided is the way to
go about doing that. I cannot think of any reason you would want to do
what you claim you want to do.

Paul Lalli

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      06-03-2006
Ray Muforosky <(E-Mail Removed)> wrote:
> Tad McClellan wrote:
>> Ray Muforosky <(E-Mail Removed)> wrote:
>>
>> > How I do see or save the content of fileA after it has loaded all the
>> > required files.

>>
>>
>> Why do you want to see or save the content of fileA after it has
>> loaded all the required files?
>>
>> That is, what do you hope to gain by doing that?



> require file2;



You need quotes around the argument to require.


> So, is it possible to save file1 after requiring file2 and file3
> file1 becomes:



Why do you want to save file1 after requiring file2 and file3?

That is, what do you hope to gain by doing that?


> #!/usr/local/bin/perl
> $a =12;
> $z = 200;
> $b = $z;
> $y = "foo";
> $c = $y;
> print $a;



This one-liner will make the changes to file1 that you seem to
be asking for...


perl -p -i.orig -e 's/require (\S*)\n/`head -1 $1`/e' file1


.... but I think you probably should be asking for something else.



What problem is it that you are ultimately trying to solve?



--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Ray Muforosky
Guest
Posts: n/a
 
      06-05-2006

Tad McClellan wrote:
> Ray Muforosky <(E-Mail Removed)> wrote:
> > Tad McClellan wrote:
> >> Ray Muforosky <(E-Mail Removed)> wrote:
> >>
> >> > How I do see or save the content of fileA after it has loaded all the
> >> > required files.
> >>
> >>
> >> Why do you want to see or save the content of fileA after it has
> >> loaded all the required files?
> >>
> >> That is, what do you hope to gain by doing that?

>
>
> > require file2;

>
>
> You need quotes around the argument to require.
>
>
> > So, is it possible to save file1 after requiring file2 and file3
> > file1 becomes:

>
>
> Why do you want to save file1 after requiring file2 and file3?
>
> That is, what do you hope to gain by doing that?
>
>
> > #!/usr/local/bin/perl
> > $a =12;
> > $z = 200;
> > $b = $z;
> > $y = "foo";
> > $c = $y;
> > print $a;

>
>
> This one-liner will make the changes to file1 that you seem to
> be asking for...
>
>
> perl -p -i.orig -e 's/require (\S*)\n/`head -1 $1`/e' file1
>
>
> ... but I think you probably should be asking for something else.
>
>
>
> What problem is it that you are ultimately trying to solve?


I inherited this code that I'm currently maintaning and it has perl
files scartered all over and uses require everywhere. So, I'm trying to
get a comprehensive listing of all the source code including all the
required files.

RM
>
>
>
> --
> Tad McClellan SGML consulting
> (E-Mail Removed) Perl programming
> Fort Worth, Texas


 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      06-05-2006
Ray Muforosky wrote:
> I inherited this code that I'm currently maintaning and it has perl
> files scartered all over and uses require everywhere. So, I'm trying to
> get a comprehensive listing of all the source code including all the
> required files.


There simply is no such thing. The code in the require()d modules is
not added to the main source file. If you'd like, you can examine the
%INC variable to get a list of all modules that have been included,
regardless of how many levels deep. Then read the documentation for
each of those modules. If the code is at all well written, it should
not be necessary to read the code in the order that the modules are
required. If the code is not well-written enough for that to be true,
then you have my sympathies.

Paul Lalli

 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      06-05-2006
>>>>> "RM" == Ray Muforosky <(E-Mail Removed)> writes:

RM> Tad McClellan wrote:

>> What problem is it that you are ultimately trying to solve?


RM> I inherited this code that I'm currently maintaning and it has perl
RM> files scartered all over and uses require everywhere. So, I'm trying to
RM> get a comprehensive listing of all the source code including all the
RM> required files.

a classic XY problem. why didn't you state this to begin with? the
solution is much easier that you realize. the %INC hash (see perldoc
perlvar) has the path to all source files that have loaded by
require/use. just dump that before the program starts (in a INIT block
should work) and you will have all of the files used by your
program.

uri

--
Uri Guttman ------ (E-Mail Removed) -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
AJAX Treeview How to keep expanded nodes expanded during AJAX postback ton ASP .Net 2 12-10-2008 04:11 PM
How to store treeview expanded node status after page reload ? TMT32 ASP .Net 0 07-12-2006 06:29 AM
Plugin type discovery/registration - How do I discover what classes were loaded when I dynamically require in ruby files from a directory? Jeff Barczewski Ruby 4 02-27-2006 09:19 PM
List text files showing LFs and expanded tabs (was: Colorize expanded tabs) qwweeeit Python 2 12-14-2005 10:07 AM



Advertisments