On Jul 30, 10:55*am, Tad J McClellan <ta...@seesig.invalid> wrote:
> bdy <bdy120...@gmail.com> wrote:
> > On Jul 29, 9:46*pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> >> bdy <bdy120...@gmail.com> wrote:
> >> > I would like to print out the differences between the two variables
> >> > instead of just printing the varialbe again after it determines
> >> > someithing was added; I just want to print what was added. Any ideas?
>
> >> > #!/usr/bin/perl
>
> >> > use LWP::Simple;
>
> >> > $| = 1;
>
> >> Why do you think that you need to enable auto-flushing?
>
> >> > while (1) {
>
> >> Where do you expect to exit this loop?
>
> >> > $firstcopy = $_;
>
> >> What, exactly, are you expecting the value of $firstcopy to be here?
>
> >> > print ('', '', $_);
>
> >> Why have you supplied those particular first two arguments to print()?
>
> >> --
> >> Tad McClellan
> >> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
>
> It is bad manners to quote .sigs.
>
> Have you seen thePostingGuidelinesthat are posted here frequently?
>
> > Will answers to any of your questions help you answer this question:
>
> > Can I print the difference between two variables?
>
> Yes. That is why I asked them.
>
> Your code never puts anything into $_ before it copies it to
> $firstcopy, so you might as well have
>
> * *$firstcopy = undef;
> instead of
> * *$firstcopy = $_;
>
> You should always enable warnings when developing Perl code.
>
> > In this case, the difference between $_ =get("http://www.google.com")
> > and
>
> If the get() succeeds then $_ will not contain undef, and will
> probably also not contain the empty string, so
>
> * * $firstcopy ne $_
>
> will be true every single time.
>
> The code you posted made no sense at all.
>
> My questions were an attempt to draw some sense from it.
>
> If you post a short and complete program *that we can run*, then
> we can surely help you solve your problem. If you don't, then
> we probably can't.
>
> Have you seen thePostingGuidelinesthat are posted here frequently?
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"- Hide quoted text -
>
> - Show quoted text -
>If you post a short and complete program *that we can run*, then
we can surely help you solve your problem. If you don't, then
we probably can't.
OK, so my problem is that I don't have a run-able program; so I may be
better off explaining what I'd like to do and what I've constructed
thus far:
I would like to assign a variable the content of a URL via "get,";
have Perl commit that to memory; then wait for a determined amount of
time; get via "get" the content of the same URL as the one committed
to memory earlier, and then compare the old, memory-committed version
of the URL to the recently retrieved content.
What I have so far is a program commits the two instances of the
retrieved URL and compares them, but I can only print out the second
instance if they are different, not the difference itself.
I've also used File::Compare, but that doesn't yield any results;
perhaps I'm using it wrong; I'm running it from a command prompt on
Windows XP; the following is the program:
#!/usr/bin/perl
use LWP::Simple;
use File::Compare;
$| = 1;
$firstcopy = get("http://www.google.com");
sleep 10;
$secondcopy = get("http://www.google.com");
if ($firstcopy ne $secondcopy) {
print ('There has been a content change');
}
|